1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
Commit Graph

3805 Commits

Author SHA1 Message Date
d5bac4d51d Emit AfterCodebasePopulatedEvent even on partial scans 2023-12-07 12:46:34 +01:00
Theodore Brown
b5ee6e0d8b Replace remaining POSIX only absolute path detection
These were missed in #10441. Fixes "Could not resolve config path" error on Windows (#10418).
2023-12-06 13:48:06 -06:00
4ed0fe934f Fix shaped array class string key combination 2023-12-06 14:12:19 +01:00
390df68966
Merge branch '5.x' into fix_literal_union_key 2023-12-03 20:55:05 +01:00
37cf82ea52
Merge branch '5.x' into fix_literal_union_key 2023-12-03 20:50:05 +01:00
18a6c0b6e9 Implement by-ref closure use analysis 2023-12-03 15:28:51 +01:00
orklah
0659967d05
Merge pull request #10429 from tscni/fix/trait-call-static
Fix static magic method pureness not being inherited from traits
2023-12-02 14:30:49 +01:00
orklah
794bdaac4f
Merge pull request #10422 from tscni/fix/match-null-coalesce
Restore support for null coalesce on match expressions
2023-12-02 14:29:20 +01:00
f652cf09d8 Merge branch 'fix_array_key_exists_negation' into fix_literal_union_key 2023-12-01 16:31:24 +01:00
2e249ab3fa Create keyed arrays when assigning literal union keys 2023-12-01 16:03:08 +01:00
ef169893aa cs-fix 2023-12-01 15:07:55 +01:00
edf2d1e4b6 Fix 2023-12-01 15:03:17 +01:00
461cd184e5 cs-fix 2023-12-01 12:25:30 +01:00
8111319fc3 Fix 2023-12-01 12:25:04 +01:00
eabb57ff02 Use correct file path while adding unused suppressions for virtual __constructs 2023-12-01 12:03:24 +01:00
Tinjo Schöni
4f458b46bc
Fix static magic method pureness not being inherited from traits
https://github.com/vimeo/psalm/pull/10385 "broke" this by propagating pseudo static methods from traits to using classes.
`AtomicStaticCallAnalyzer` was then not capable of dealing with this, because now these static pseudo methods actually exist.

As long as the methods from traits aren't actually transferred to the using class, it seems right that the logic in `AtomicStaticCallAnalyzer` uses `::getDeclaringMethodId()` instead of `::getAppearingMethodId()` for this purpose.
2023-11-29 23:22:14 +01:00
kkmuffme
4f25ccee40 update define types to be correct 2023-11-29 08:51:15 +01:00
Tinjo Schöni
d91aab15be
Restore support for null coalesce on match expressions
https://github.com/vimeo/psalm/pull/10068 added isset restrictions that didn't consider null coalesces on match expressions.
This restores that support by converting the match expression to a virtual variable for the isset analysis, similar to other incompatible expressions.
2023-11-29 02:08:23 +01:00
1e2e2248d9 Fix wrong type 2023-11-26 19:34:49 +01:00
e386b072f3 Fix 2023-11-26 13:33:25 +01:00
35f194e9e8 Fix backtick analysis 2023-11-26 13:12:11 +01:00
kkmuffme
00bed512af suppress false positive 2023-11-18 08:55:20 +01:00
kkmuffme
adb8677f20 Fix optional args not enforced in callable (fix for non-closure/arrow functions of https://github.com/vimeo/psalm/issues/8438) Fix array callables not treated as callable https://psalm.dev/r/23f3787207 (this is needed to fix the optional args enforcement for array callables too) 2023-11-18 08:55:20 +01:00
kkmuffme
5eacd301e9 Fixed ReturnTypeWillChange false positive https://psalm.dev/r/91c6992bf1 with missing return type signature 2023-11-18 08:55:20 +01:00
kkmuffme
0252bbbd7c Fixed https://psalm.dev/r/7f112fd745 - MethodComparator only reported an error for this if the parent class was user defined (= not in stubs), which is wrong, since this will cause a fatal error when running the code 2023-11-18 08:55:20 +01:00
kkmuffme
c5655c510d Fix param providers for native methods not working Fix array_filter params callable incorrect required params depending on the 3rd argument value (at this commit psalm doesn't report an error, due to https://github.com/vimeo/psalm/issues/8438, which gets fixed by this PR later on though) Fix https://github.com/vimeo/psalm/issues/3047 and further improve types for array_multisort and add errors for invalid params Fix SimpleTypeInferer failing on bitwise operations with constants 2023-11-18 08:55:20 +01:00
kkmuffme
88e3cda3b9 remove unused function, fix unusedVariable error after suppress 2023-11-13 20:24:58 +01:00
kkmuffme
dcd53cadab Suppressing NoValue should not treat subsequent code as unevaluated
Fix https://github.com/vimeo/psalm/issues/10302
2023-11-13 18:57:41 +01:00
orklah
7acc50eef0
Merge pull request #10318 from danog/finalize
Finalize all internal classes
2023-11-03 20:57:06 +01:00
07b45b8116 Get rid of legacy 7.3 logic 2023-10-26 17:18:33 +02:00
ec23f998ea Finalize all internal classes 2023-10-26 17:00:29 +02:00
Daniel Linjama
a375f441f2 fix @param-out with named arguments 2023-10-23 10:39:09 +03:00
4c656f0a2b Revert 2023-10-21 20:50:08 +02:00
596ee11d0d cs-fix 2023-10-21 20:48:06 +02:00
3b66272aa0 More rector fixes 2023-10-21 20:45:09 +02:00
cddf6a9a57 Rector fixes 2023-10-21 20:44:04 +02:00
8ca610ae60 Fix 2023-10-19 11:23:24 +02:00
576e4d2bc4 Fix method calls and property accesses after extension_loaded 2023-10-19 11:16:20 +02:00
robchett
e2d1e83b87 Fix memory explosion with calls to method_exists 2023-10-17 19:15:23 +01:00
orklah
b432d812fb
Merge pull request #10274 from tuqqu/enum-case-value-type-from-class-constant
Fix inferring enum case value from a class constant
2023-10-16 20:25:11 +02:00
orklah
c9c3067044
Merge pull request #10279 from trusting-thompson/final-static-constant-type
fix final class constant type
2023-10-16 20:24:25 +02:00
orklah
7a7d6a25af
Merge pull request #10242 from cgocast/5.x
Allow tainted numerics except for 'html' and 'has_quotes'
2023-10-16 20:17:39 +02:00
Daniel Linjama
545e21b56b fix final class constant type 2023-10-13 14:18:58 +03:00
tuqqu
d0825b5fe2 Fix for inferring enum case value from a class constant, const test fix 2023-10-13 01:15:05 +02:00
tuqqu
6039e2be9b Fix for inferring enum case value from a class constant 2023-10-10 22:56:36 +02:00
orklah
3f7306d8df
Merge pull request #10254 from tuqqu/never-function-return-error-message
Fix error message for implicitly returning functions with `never` return type
2023-10-09 18:51:11 +02:00
cgocast
eea7c33309
Merge branch 'vimeo:5.x' into 5.x 2023-10-09 14:17:50 +02:00
tuqqu
a4cebb2cb8 Disallow never type for parameters 2023-10-08 20:47:37 +02:00
robchett
d874aab881 Add alias support to psalm-check-type 2023-10-08 17:46:59 +01:00
tuqqu
2a910d1f17 Changed error message for never return error 2023-10-04 21:00:04 +02:00
tuqqu
413f1d6ce3 Fix error message for returning function with never return type 2023-10-04 20:51:31 +02:00
tuqqu
9f9e5f1e18 Emit MethodSignatureMismatch when descendant does not return by reference 2023-10-03 03:41:11 +02:00
cgocast
e0c24cbe7a Remove unused parents_nodes 2023-10-02 15:38:01 +02:00
cgocast
6eb40e7897 Fix code style 2023-10-02 15:22:57 +02:00
cgocast
94a98ccddd Allow tainted numerics except for 'html' and 'has_quotes' 2023-10-02 15:08:26 +02:00
orklah
2d3a625379
Merge pull request #10230 from ging-dev/lsp
feat(LSP): Improve the autocomplete for nested array shape
2023-09-28 23:42:02 +02:00
orklah
f57088646b
Merge pull request #10191 from boesing/bugfix/inherited-conditional-return-types
Resolve inherited conditional return types
2023-09-28 23:08:20 +02:00
orklah
bbcf50396d
Merge pull request #10189 from boesing/feature/inherited-assertions-v2
Inherited assertions v2
2023-09-28 23:07:15 +02:00
tuqqu
09fbe99f5b Check for declare strict types block mode 2023-09-26 20:59:06 +02:00
ging-dev
45807e27b8 feat(LSP): Improve the autocomplete for nested array shape 2023-09-26 01:52:23 +07:00
robchett
03e8d19eec Only the binary op 'plus' works with two arrays
Treat the result of any other operation as int|float
Fixes #2123
2023-09-16 15:55:59 +01:00
Maximilian Bösing
7c8a5e8b09
bugfix: resolve recursive conditional return types containing templates
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-09-11 00:04:01 +02:00
Maximilian Bösing
ad463f38e9
bugfix: always gather class templates
No clue why there are conditions on when templates are allowed to get picked up. I've removed this check which actually solves a problem in inherited assertions.

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-09-10 22:17:30 +02:00
Bruce Weirdan
cd8fc46554
Flag invalid declares 2023-09-02 23:41:50 +02:00
robchett
d0c4d170b0
Apply psalm-inheritors to interfaces too 2023-08-31 23:12:10 +02:00
robchett
e23971ca29
InheritorViolation was only being triggered on grand-childen classes
Fixes #10167
2023-08-31 23:12:07 +02:00
Maximilian Bösing
66c01813c1
refactor: move assertion detection based on inherited classes/interfaces into internal resolver
This also enables `ExistingAtomicStaticCallAnalyzer` to detect those inherited assertions.

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-08-28 11:09:23 +02:00
Maximilian Bösing
2a0ce2fecc
qa: add newlines to prevent exceeding 120 character line-length limit
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-08-28 01:15:49 +02:00
Maximilian Bösing
5e520e6bff
bugfix: properly inherit assertions from parents or implemented interfaces
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-08-28 01:12:28 +02:00
Bruce Weirdan
1474340cf2
Fix crash on array access to undefined class 2023-08-20 23:45:30 +02:00
Nitamet
005eed3d06 Throw and catch exception when specified PHP version is invalid 2023-08-19 00:14:39 +03:00
Nitamet
18b74b1814 Add 8.3 as supported version 2023-08-19 00:01:17 +03:00
Nitamet
2c7391a649 Add versions 5.4-7.3 as supported 2023-08-18 20:32:05 +03:00
Nitamet
5f40d26539 Fix PHP version checking
Separate condition to check both cases if the specified string is a valid version and if it is supported
Remove unsupported versions up to 7.4 from regex
2023-08-18 20:09:17 +03:00
Bruce Weirdan
03f7c263fe
Correct type for $enum->name 2023-08-13 05:56:33 +02:00
Kuba Werłos
35183b9542 Add fix 2023-08-12 12:50:24 +02:00
Yannick Gottschalk
a4de6d9dc0 Fix #9997
- make SimpleXmlElement and SimpleXmlIterator not a universal object crate
- added typed magic __get method to SimpleXmlElement
- adjusted tests to reflect new behaviour of SimpleXmlElement
- added tests
2023-08-05 17:07:08 +02:00
Nitamet
f742af0221 Check if argument passed to isset() is valid 2023-08-01 14:39:10 +03:00
rhertogh
8d76314a48 Fixed PHPCS errors for CommentAnalyzer (Multi-line function calls must have a trailing comma after the last parameter). 2023-07-15 19:11:15 +02:00
rhertogh
65ad2f829e Fixed PHPCS errors for CommentAnalyzer 2023-07-15 19:04:52 +02:00
rhertogh
c362dd5af7 Ensure comment lines are terminated with a new line character (\n). 2023-07-15 19:00:28 +02:00
rhertogh
f378ef1cab Allow comments in types (e.g. array shape) 2023-07-15 18:43:47 +02:00
rhertogh
9935b2c71e Merge branch 'master' into inline_comments_in_types
# Conflicts:
#	tests/CommentAnalyzerTest.php
2023-07-15 15:46:01 +02:00
klimick
38f6d45155 Do not fill template result when arg is unpacked 2023-07-11 11:10:48 +03:00
klimick
9fccf201e3 Fix callable without params inference 2023-07-11 01:01:31 +03:00
rhertogh
2285c9d4bd Fixed codestyle for CommentAnalyzer and use plain instead of multibite string functions 2023-07-06 23:54:50 +02:00
rhertogh
356e6d7bbd First setup to allow comments in types (e.g. array shape) 2023-07-06 23:40:13 +02:00
rhertogh
242a38c184 Allow space before array shape opening brace and added unit tests for \Psalm\Internal\Analyzer\CommentAnalyzer::splitDocLine() 2023-07-06 00:01:00 +02:00
Yannick Gottschalk
5a2f7c0a71 Use getParts() instead of $parts on PhpParser\Node\Name.
also use getFirst(), getLast() and getString()
2023-06-28 03:13:25 +02:00
Tinjo Schöni
9939cae52d
Support project analysis with file diffing in tests 2023-06-24 14:29:28 +02:00
orklah
1b571a1649 improve perfs for switch by not creating reverse assertions against constants 2023-06-19 21:24:46 +02:00
orklah
e2dde5d200
Merge pull request #9922 from robchett/elseif_shouldnt_be_modifying_outer_scope
Don't update types of the outer scope when in an elseif conditional
2023-06-18 11:00:16 +02:00
robchett
7792b6c36c Don't update types of the outer scope when in an elseif conditional 2023-06-17 13:36:29 +01:00
robchett
721b65ce2f Add Type::getIntRange 2023-06-17 12:24:09 +01:00
robchett
338b50a959 Change __LINE__ to a positive-int 2023-06-17 12:24:09 +01:00
kkmuffme
16aaa3ae2b regex cleanup 2023-06-13 22:07:51 +02:00
kkmuffme
0a54c84055 readonly does not have write access, therefore is safe as long as the type is contained in the parent type
Fix https://github.com/vimeo/psalm/issues/9831#issuecomment-1569022701
2023-06-09 12:37:41 +02:00
orklah
c15860508b
Merge pull request #9853 from kkmuffme/multiple-psalm-assert-if-for-array-list
Allow if/false assert for same variable to allow array/list distinction
2023-06-04 22:59:37 +02:00
kkmuffme
fa644cbb34 code review init variables 2023-06-02 08:54:00 +02:00
orklah
75baaf7889
Merge pull request #9844 from kkmuffme/property-no-set-in-constructor-abstract-false-positive
PropertyNotSetInConstructor should not report for abstract constructors
2023-06-01 07:21:23 +02:00
kkmuffme
103e7b343c PropertyNotSetInConstructor should not report for abstract constructors
since they do not have any code

Fix https://github.com/vimeo/psalm/issues/9830
2023-06-01 01:38:33 +02:00
kkmuffme
c17564d27c code style and false positive shepherd 2023-06-01 01:25:46 +02:00
kkmuffme
1f2db5f31c Allow if/false assert for same variable to allow array/list distinction
Fix https://github.com/vimeo/psalm/issues/9037
2023-06-01 01:08:06 +02:00
Alies Lapatsin
174cd5c0fe Introduce and use IssueData constants for severity
they are not the same as Config::REPORT_* constants
2023-05-31 12:38:15 +02:00
kkmuffme
25c7f37a44 add test, fix wrong test and fix shepherd 2023-05-30 16:29:47 +02:00
Jack Worman
f279c39503 GH-9825 2023-05-26 18:03:05 -04:00
Jack Worman
f41da745d1 UnsupportedPropertyReferenceUsage 2023-05-12 14:12:12 -05:00
orklah
d4c5f85eb0
Merge pull request #9687 from robchett/limit_inheritance
WIP - Limit inheritance to a subset of classes #1450
2023-05-07 22:46:05 +02:00
RobChett
aa85669645 Change the Issue type and add documentation 2023-05-07 11:34:33 +01:00
RobChett
cad5288484 Support interfaces 2023-05-07 11:33:39 +01:00
RobChett
de877f1dcf Add support for @psalm-inheritors 2023-05-07 11:33:38 +01:00
fluffycondor
86fd504965 Allow dynamic properties from PHPDoc 2023-05-04 18:49:41 +02:00
orklah
7483f4d809
Merge pull request #9740 from edsrzf/better-property-error
Fix OverriddenPropertyAccess error message
2023-05-04 18:49:00 +02:00
andrew
a18eb447e0 Test match on class const fetch 2023-05-04 17:21:50 +03:00
Evan Shaw
d2f0f6ce30 Fix OverriddenPropertyAccess error message
The message previously didn't mention the base class, which made it
confusing.
2023-05-04 21:51:16 +12:00
klimick
ac8d489413 Fix ParadoxicalCondition with complex match expression 2023-05-04 11:58:39 +03:00
orklah
a5effd2d2d
Merge pull request #9681 from robchett/no-seal-methods_and_no-seal-propeties
Add support for @psalm-no-seal-properties and @psalm-no-seal-methods
2023-05-02 19:20:34 +02:00
tuqqu
46f5bc8bd7 Introduce BeforeExpressionAnalysisEvent, fix array comparison 2023-04-30 12:12:00 +02:00
tuqqu
38b40a9fe2 Introduce BeforeExpressionAnalysisEvent 2023-04-30 03:50:30 +02:00
orklah
4843a350a0
Merge pull request #9720 from Jean85/fix-ambiguous-constant-inheritance
Fix ambiguous constant inheritance false positive
2023-04-28 23:22:31 +02:00
Alessandro Lai
e8bc9a6209
Do not emit AmbiguousConstantInheritance when inheriting from the same statement 2023-04-28 22:52:22 +02:00
klimick
0ae1b31efc Fix UnevaluatedCode false positive at declare(strict_types=1) 2023-04-27 23:11:14 +03:00
8eacb0f003 Remove clone leftovers from immutable refactoring 2023-04-25 11:09:54 +02:00
orklah
720f3f1dc2
Merge pull request #9704 from Nicelocal/fix_new_template_object
Allow running new on template objects
2023-04-24 16:29:34 +02:00
8288b00ef9 Allow running new on template objects 2023-04-24 13:08:12 +02:00
orklah
eae04f25f6
Merge pull request #9693 from Nicelocal/fix_9692
Fix #9692
2023-04-24 12:48:20 +02:00
orklah
41796e324a
Merge pull request #9700 from klimick/method-contextual-closure-arg-inference
Contextual closure arg inference for class methods
2023-04-24 12:47:38 +02:00
Evan Shaw
82090f58c5 Handle included directory paths without crashing
If an include or require resolves to a directory, this now raises a
MissingFile error rather than throwing an unhandled UnexpectedValueException.
2023-04-24 11:09:48 +12:00
klimick
88c444a8cc Contextual closure arg inference for class methods 2023-04-23 23:40:44 +03:00
abead05303 Fix syntax 2023-04-21 12:38:02 +02:00
b8672949ec Fix #9692 2023-04-21 12:33:08 +02:00
orklah
a97b6b8a5e
Merge pull request #9685 from Nicelocal/avoid_wrong_assertions
Avoid wrong assertions when working with objects returned by methods
2023-04-21 11:34:15 +02:00
orklah
b781bd922e
Merge pull request #9679 from robchett/mixedAssignment_from_template_var
Don't throw UnnecesseryVarAnnotation when hinting a mixed template var
2023-04-20 23:52:52 +02:00
RobChett
74c1576b9c Return a non-empty-(lowercase-)string from mb_strtolower 2023-04-20 15:54:13 +01:00
efb5aed879 Avoid wrong assertions when working with objects returned by methods 2023-04-20 13:00:28 +02:00
RobChett
4d9d7cebd9 Add support for @psalm-no-seal-properties and @psalm-no-seal-methods 2023-04-20 07:47:50 +01:00
RobChett
0a40286830 Don't throw UnnecesseryVarAnnotation when hinting a mixed template var 2023-04-19 21:23:40 +01:00
WhizSid
782735e8b2 Fixed crash issue when using multiple literals for array_splice 2023-04-19 00:38:35 +05:30
adrew
ee0395247f Don't expand template for property fetch on TObjectWithProperties 2023-04-17 23:18:03 +03:00
orklah
a9bc87e729
Merge pull request #9656 from boesing/bugfix/issue-8981
(re-)implement object-shape assertions
2023-04-16 21:17:53 +02:00
Maximilian Bösing
66afbb1c33
feature: (re-)implement object-shape assertions
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-04-15 02:36:10 +02:00
Maximilian Bösing
ad5631497d
feature: provide support for templated value-of enum values
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-04-15 00:38:12 +02:00
orklah
3e50f68794
Merge pull request #9623 from klimick/contextual-inference-for-const-callable
Contextual inference for const callable
2023-04-14 16:22:53 +02:00
orklah
cee88f2c4b
Merge pull request #9643 from whizsid/array_splice
Fixed non empty arg issue in array_splice function
2023-04-13 19:24:16 +02:00
WhizSid
02f8f11736 Handle empty array possibilities from array_splice 2023-04-13 14:37:09 +05:30
tuqqu
ed2285f50a Flatten match arm conditions to check conditions independently 2023-04-13 01:30:14 +02:00
WhizSid
ae67589463 Fixed CI 2023-04-13 01:14:49 +05:30
WhizSid
b19c263fe5 Fixed non empty arg issue in array_splice function 2023-04-13 00:34:29 +05:30
Maximilian Bösing
6d5f999c75
bugfix: do not report required closure arguments as unused
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-04-10 01:54:03 +02:00
orklah
763116fab3
Merge pull request #9599 from boesing/feature/callable-object-intersection
Introduce callable object intersection
2023-04-09 11:48:45 +02:00