1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00
Commit Graph

311 Commits

Author SHA1 Message Date
orklah
4f7c1d05c1
remove support for allowPhpstormGenerics 2022-01-02 15:06:04 +02:00
ff7abec2bd
Fix tests 2021-12-30 12:01:25 +01:00
Tomasz Mlynski
1da6893451
Add resolveSymlinks condition for project directories 2021-12-14 20:25:27 +01:00
Bruce Weirdan
85f2083acb
Flag duplicate constants
Fixes vimeo/psalm#6882
Addresses p1 from vimeo/psalm#6471
2021-11-11 00:44:17 +02:00
Bruce Weirdan
b49c25ae76
Fixed tests
* Added new issue to the config.xsd
* Marked NoEnumProperties as PHP 8.1 issue
2021-11-06 22:22:38 +02:00
orklah
943db37ec2 deprecate exitFunctions in XML 2021-11-04 00:39:09 +01:00
orklah
3db477e3c5 deprecate allowPhpStormGenerics 2021-10-19 23:37:35 +02:00
orklah
8b07e69645
Merge pull request #6514 from zoonru/if-this-is
Add if-this-is
2021-10-04 09:49:26 +02:00
Guillaume Messier
84e40ea04f
Merge branch 'vimeo:master' into hotfix/gmessier-xml-include 2021-09-22 08:35:51 -04:00
Guillaume Messier
d2f3ff09ee
Add possibility to include xml config located in subdirectory
Fix the config.xsd file to accept "xml:base" attribute in tags and be able to include partial configuration located in another directory then the main configuration file.
2021-09-21 15:15:15 -04:00
15fccc6a07
Add docs 2021-09-21 17:35:44 +02:00
7e0b489efe
Merge remote-tracking branch 'origin/master' into if-this-is 2021-09-21 12:12:15 +02:00
Bruce Weirdan
b4f024b1fe
Basic enum checks
* Duplicate cases
* Duplicate case values
* Invalid case values: value on a pure enum case, missing value on a
backed enum case, backing type / case type mismatch
* Literal expression evaluation for case values

Fixes vimeo/psalm#6426
Fixes vimeo/psalm#6427
2021-09-07 12:35:38 +03:00
Bruce Weirdan
7b11024886
Flag invalid backing types for enums
Fixes vimeo/psalm#6428
2021-09-05 20:12:24 +03:00
Guillaume Messier
f24b6aba1d
Use anyAttribute to prevent xml:base attributes added by XInclude to break the schema validation 2021-08-03 15:39:41 -04:00
Guillaume Messier
b814802426 Merge branch 'master' of https://github.com/gmessier/psalm 2021-08-02 18:54:15 +00:00
Guillaume Messier
610f500210 Add xml.xsd locally to prevent network issues 2021-08-02 18:53:17 +00:00
orklah
58dd3f6f94 change wording 2021-07-20 23:53:04 +02:00
orklah
acfdb82856 Basic implementation 2021-07-20 23:34:38 +02:00
Kevin Pageau
bd3fd93db2 Allow xml:base attribute
Allows including xml:base attribute in configuration elements. This
makes it possible to include split configuration located in a
subdirectory.
2021-07-07 15:46:38 -04:00
Bruce Weirdan
f24f361a95
Add documentation and schema entry for inferPropertyTypesFromConstructor
Fixes vimeo/psalm#5974
2021-06-22 21:20:10 +03:00
Bruce Weirdan
e552925af6
Emit separate type of issue when foreach value is unused (#5932)
* Emit separate type of issue when foreach value is unused

Fixes vimeo/psalm#5929

* Fixed var name case sensitivity
2021-06-17 00:40:24 -04:00
Matt Brown
47bf5ed567 Fix #5918 - add new issue to detect unquoted strings 2021-06-10 17:43:04 -04:00
Matthew Brown
6d09418a23
Detect unused return values (#5917)
* Detect unused return values

* Allow static-returning instance methods (presumed to be fluent)

* Make $is_used the default for Codebase::methodExists
2021-06-10 14:18:15 -04:00
Bruce Weirdan
86050df4d0
Formally deprecate allowCoercionFromStringToClassConst (#5897)
* Mark allowCoercionFromStringToClassConst as deprecated in xml schema

* Emit deprecation warning for `allowCoercionFromStringToClassConst`
2021-06-07 10:46:26 -04:00
Bruce Weirdan
c98b20247b
Flag unexpected tags on function docblocks (#5845)
* Flag unexpected tags on function docblocks

Fixes vimeo/psalm#5782

* Document new issue

* Fix spacing

Co-authored-by: Matthew Brown <github@muglug.com>
2021-05-28 09:47:39 -04:00
Matt Brown
012dafad79 Fix #5383 - prevent unsound use of new static for generics 2021-04-10 13:16:19 -04:00
Bruce Weirdan
a025311e39
Restrict errorLevel and type attributes to valid values (#5476)
This provides better validation and autocompletion for psalm.xml
2021-03-25 00:27:54 -04:00
AndrolGenhald
de5a031088
Improve @no-named-arguments support and variadics. (#5455)
* Improve @no-named-arguments support and variadics.

Handling of argument unpacking and variadics still needs a pretty big makeover, but this is a good start.

Fixes #5420
Improves #5453 (iterable works, array still causes issues)

* Remove unneeded imports.
2021-03-22 19:58:22 -04:00
Gregor Harlan
c606c89006
config.xsd: fix default errorLevel (#5339) 2021-03-11 00:05:23 -05:00
Matt Brown
f2d202e2bb Add less severe issue for docblock property type invariance cc @bdsl
This is less likely to break everything
2021-02-07 00:52:29 -05:00
Bruce Weirdan
04bb2b1182
Prevent invalid Traversable implementation (#5171)
* Prevent invalid Traversable implementation

Fixes vimeo/psalm#5167

* Document new issue

* CS fix
2021-02-06 22:10:05 -05:00
Barney Laurance
0cd5442c47
Enforce property type invariance (#5131)
* Implement NonInvariantChildProperty detection

See https://github.com/vimeo/psalm/issues/4184

* Delete test cases with 'parentSetsWiderTypeInConstructor'

As I understand it these are not valid test cases. They
emit NonInvariantPropertyType issues which seems correct - the property
type variation is I think a latent bug in the sample code.

* Reduce shortcode for NonInvariantPropertyType to 1+max used shortcode on master
2021-01-31 11:32:24 -05:00
Matthew Brown
7764a4ce6c Fix #4912 - detect mismatching property type 2020-12-29 16:37:03 +00:00
Matt Brown
e7f9ce6da0 Break out RedundantCast issues 2020-12-01 17:25:45 -05:00
Matthew Brown
60ac109c01
Add RedundantPropertyInitializationCheck (#4732)
* Add RedundantPropertyInitializationCheck

* add documentation for RedundantPropertyInitializationCheck (#4734)

Co-authored-by: orklah <orklah@users.noreply.github.com>
2020-11-29 11:57:20 -05:00
Matt Brown
ffabce19c5 Add complex issue error 2020-11-27 17:02:37 -05:00
Matt Brown
bf696bf82e Add complexity function name echoing 2020-11-27 05:28:55 -05:00
Matt Brown
2c77424e16 Fix #4656 - separate UnusedConstructor from UnusedMethod 2020-11-22 11:48:17 -05:00
Matt Brown
78d644d1a1 Change TaintedText to TaintedCallable 2020-11-19 19:01:19 -05:00
Lukas Reschke
78f4a0691c
Add dedicated types for 'file', 'header' and 'cookie' (#4630)
* [WIP] Add dedicated sinks for 'file', 'header' and 'cookie'

* Add documentation

* Add mapping for taint flows

* Add tests

* Fix test
2020-11-19 17:47:29 -05:00
Lukas Reschke
ddbfbb28e6
Split LDAP into custom category (#4604)
- Adds ldap_escape as sanitizer
- Defines the right parameters to ldap_search as sink
- Wrote documentation
- Added tests
2020-11-18 11:39:36 -05:00
Lukas Reschke
5ba4681c17
Add SSRF sinks (#4592) 2020-11-18 00:52:48 -05:00
Matt Brown
43af3b1a57 Break out TaintedInput issues into a lot of separate ones 2020-11-17 12:44:31 -05:00
Matt Brown
388e804ed8 Allow opt-in to strict return type checking 2020-11-05 18:20:04 -05:00
Matt Brown
579327a470 Detect when targets are incorrectly targeted 2020-10-30 13:28:45 -04:00
Matt Brown
82f35c1454 Ensure Stringable is always available to tests that need it 2020-10-29 19:41:10 -04:00
Matt Brown
f8eee22f77 Add basic support for PHP attributes
Ref #4367 - supports creation and argument checks
2020-10-24 00:10:22 -04:00
Niclas van Eyk
0261024aa6
Initial proposal for psalm-require-{extends, implements} (#4361)
* initial implementation of psalm-require-extends

* Added @psalm-require-implements

* Added shortcode for ExtensionRequirementViolation

* Docs & cofig entries for @pasalm-require-{implements,extends}

* Added requirement violations to issues.md
2020-10-19 15:08:18 -04:00
feek
8d2db4e673
feature: universal object crates (#3948)
* feature: universal object crates

* docs: document universal object crate config option

Co-authored-by: Matthew Brown <github@muglug.com>
2020-10-07 09:56:21 -04:00
Matt Brown
377dc8da8f 4.x - change/remove some default config values 2020-10-05 10:08:41 -04:00
Matt Brown
30795281c6 Add config and docs for InvalidNamedArgument 2020-10-02 20:35:23 -04:00
Brown
6ffe471525 Make new InvalidLiteralArgument issue for strpos refs
Ref #4070
2020-09-10 22:54:32 -04:00
orklah
c6ea274180
Config reportInfo to speed up analysis for big projects (#4095) 2020-09-01 09:22:05 -04:00
Bruce Weirdan
ffb316a9e6
Converted MissingPropertyType to property issue (#4099)
Fixes vimeo/psalm#2200
2020-09-01 09:21:03 -04:00
Brown
940459787a Catch unmatched matches 2020-08-31 22:59:47 -04:00
Brown
92239add4d Add some backwards-incompatible changes for 4.x 2020-08-30 11:44:14 -04:00
Tom Klingenberg
46013a35c8
Revert config schema, fix b/c break (#4046)
Previous in d5055ea the allowCoercionFromStringToClassConst attribute has
been removed from the XML configuration file per its schema.

While technically correct (was removed in 3.0), this breaks b/c between
minor versions, breaks with the release of 3.14.0.

Fix is revert.

Ref: d5055ea1d4
Caused-by: #3982
2020-08-24 00:56:45 -04:00
Brown
10f7031080 Prevent use of $this in pure functions 2020-08-23 18:37:46 -04:00
Matthew Brown
7e13ab9cc9 Fix docs 2020-08-23 13:03:25 -04:00
Michel Hunziker
3538fe1955
Add configuration attribute to find unused @psalm-suppress (#4041) 2020-08-22 10:01:26 -04:00
Olle
3630b4a2f9 Merge remote-tracking branch 'remotes/upstream/master' 2020-08-18 15:59:46 +00:00
Bruce Weirdan
7adc25c421
Improve import errors (#3997)
* Better errors for invalid type imports

Fixes vimeo/psalm#3885

* Finishing touches

Docs, schema, CS

* Drop unused import

* Drop more unused imports
2020-08-16 22:53:53 -04:00
Matthew Brown
72ecb57def Improve names of things 2020-08-14 00:27:33 -04:00
Bruce Weirdan
d5055ea1d4
Removed obsolete documenation (#3982)
`allowCoercionFromStringToClassConst` was removed in 3.0 and never
worked since.

Refs vimeo/psalm#3976
2020-08-11 07:30:09 -04:00
Brown
6def99d653 Add ConstructorSignatureMismatch issue distinct from MethodSignatureMismatch 2020-08-10 12:26:25 -04:00
Matthew Brown
6085e42fc1 Detect mismatching param names effectively 2020-08-10 09:58:43 -04:00
Brown
c0b0036109 Fix #3934 - prevent unsafe use of new static 2020-08-05 19:39:27 -04:00
Grégoire Paris
2f673fbbd7
Detect redundant identity with true (#3893)
Using === true on a known boolean results in the same boolean.
2020-07-25 17:27:45 -04:00
Nat Zimmermann
a1a403e046
make meta path optional (#3833) 2020-07-17 10:09:42 -04:00
kesselb
aaba3a08ec
Add option to supress a referenced but undefined global variable. (#3827) 2020-07-16 09:49:59 -04:00
Olle
0965fbf989 Add if-this-is mismatch to config.xsd 2020-07-12 20:16:01 +00:00
Jon Ursenbach
6aca4c169e
feat: adding a runTaintAnalysis option into the config (#3800) 2020-07-10 13:22:03 -04:00
Bruce Weirdan
e569f08f23
Drop missing issues from XSD schema (#3657)
Two unknown issues (that were only present in schema) are dropped and a
test to validate that all issues are covered by XSD schema is added.
2020-06-23 16:56:39 -04:00
Brown
078b8b7b1a Fix #3618 - add way to load non-analyzed files 2020-06-19 00:13:09 -04:00
Olle Härstedt
e1cc27f7a2
Add new config: sealAllMethods (#3578)
* Add new config: sealAllMethods

* Add some more tests

* Fix codesniffer issue with preg_quote

* Fix missing method in test

Co-authored-by: Olle <noemail>
2020-06-15 22:36:42 -04:00
Andrei Petre
3497ca07b6
Extending final class is prohibited #3037 (#3576) 2020-06-13 00:29:59 -04:00
Ivan Kurnosov
08943ea409
Fix #3517 - Changed ignoreInternalFunctionFalseReturn default to true (#3518)
In config.xsd and the documentation
2020-06-03 22:29:09 -04:00
Brown
953be61cf2 Allow limiting connected taint paths 2020-05-25 23:28:11 -04:00
Brown
3c5b4dec06 Add documentation for MixedClone 2020-05-18 17:20:57 -04:00
Evgeniy
04a576708c
Correct analyze clone expression (#3382)
* Correct analyze clone, add PossibleInvalidClone issue type

* Infer mixed type when possible incorrect clone

* Remove unused variable
2020-05-18 16:22:50 -04:00
m0003r
28f740fddb
@psalm-trace is now a specific low-level issue, because plain debug print breaks structured output (after #3080) (#3106) 2020-04-08 21:03:05 -04:00
Matthew Brown
0d62fbdf98 Detect erroneous abstract static method calls 2020-03-11 10:18:40 -04:00
Philip Hofstetter
d315822bfa make skipping of checks after invalid includes configurable
as suggested in the PR it's best to make the setting configurable.

In order not to break existing installations, we default to keeping the
old behaviour, but in a later version of psalm, we might change the
default.
2020-02-27 18:49:23 -05:00
Matthew Brown
a706f4d722 Fix #2242 - warn when using mutable dependencies 2020-02-22 10:04:46 -05:00
Brown
7d99a15072 Fix #2805 - forbid passing in mutable class to mutation-free context 2020-02-21 18:25:35 -05:00
Matthew Brown
2e4154d76e Add better defaults and documentation 2020-02-18 20:30:37 -05:00
Brown
520b646ef6 Add suppressMixedIssues config flag to hide mixed issues 2020-02-18 17:23:48 -05:00
Matthew Brown
320f3ec863 Update level config name 2020-02-17 22:43:13 -05:00
Matthew Brown
ced092874a Make config generation smarter 2020-02-17 22:05:58 -05:00
Orklah
5eabc2e6a9 add config missing from implementation in #2737 2020-02-10 17:10:42 -05:00
Philip Hofstetter
f6983fd883 allow setting php version from config or composer.json
if a composer.json is present and a PHP version requirement is
configured, we set the php version to the minimal PHP version that
satisfies the composer requirement.

Additionally, this adds a `phpVersion` attribute to the <psalm> tag. If
that's set, it takes precedence over what has been detected in
composer.json.

And finally, the --php-version command line flag continues to work and
takes precedence over the setting in the <psalm> tag

this fixes #2628
2020-01-30 08:48:53 -05:00
Matthew Brown
5c3ec7a531 Fix #2696 - make sure static property references are prevented in pure functions 2020-01-27 22:55:20 -05:00
Brown
0f659d996d Add documentation for new issue 2020-01-23 14:33:07 -05:00
Brown
083fbc55e1 Add more specific UndefinedMagicMethod issue 2020-01-06 14:23:33 -05:00
Matthew Brown
4e85967184 Fix tests 2020-01-05 21:58:18 -05:00
Brown
af5f83602e Break out more specific possibly defined offset errors 2019-11-11 09:59:56 -05:00
Bruce Weirdan
79acbadfad Added InvalidParent issue (#2320)
Refs vimeo/psalm#2304
2019-11-11 00:21:43 -05:00
Dalibor Karlović
d2161dcd73 docs: change boolean flags to be xs:boolean (instead of xs:string) (#2274)
The schema now better reflects the actual data model, with the more
exact type and the defaults, where known.
2019-10-25 16:07:52 +02:00
Brown
b0aaede9e1 Add support for checking integer array offsets 2019-10-04 11:08:08 -04:00