1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 17:57:37 +01:00
Commit Graph

3142 Commits

Author SHA1 Message Date
Vincent
09fc43a4d8 Add support of docblock method using parent keyword (fix #7411) 2022-01-17 19:26:42 +01:00
Ricardo Boss
26dd4c5b8f
Try to provide literal int types when possible (fixes #6966) (#7071)
* Fixed vimeo/psalm#6966

* Only accept >= 0 values for mode argument in round()

* Made round() only return float or literal float values and remove unneeded test

* Registered RoundReturnTypeProvider

* Updated cast analyzer to handle single string literal int values as literal ints

* Fixed psalm errors

* Fix invalid property accesses

* Addressed comments

* Added Tests

* Marked RoundReturnTypeProvider as internal

* Fixed CS
2022-01-16 21:33:04 +01:00
orklah
5b82082bbd Merge remote-tracking branch 'upstream/4.x' into upstream-master2 2022-01-15 20:21:00 +01:00
orklah
9a9243e5fe
Merge pull request #7385 from b2pweb/handle-template-on-pseudo-method
Add support of template for docblock methods
2022-01-15 11:26:03 +01:00
orklah
75947c97c6
Merge pull request #7391 from b2pweb/docblock-method-inheritance
Handle inherited docblock method
2022-01-15 11:24:06 +01:00
orklah
b3e7f12933 Prevent NoValue when there is no phpdoc 2022-01-14 21:39:23 +01:00
orklah
d2faa5b94f fix errors after merge 2022-01-14 21:13:34 +01:00
orklah
b633619a2c Merge remote-tracking branch 'upstream/4.x' into upstream-master 2022-01-14 21:01:25 +01:00
orklah
4a85fed181 use Reconciler::RECONCILIATION_* 2022-01-14 19:39:18 +01:00
Vincent
a52362465b Handle inherited docblock method (fix #7198) 2022-01-14 10:30:09 +01:00
Vincent Langlet
9f84da4d6f Try another strategy 2022-01-13 23:57:02 +01:00
Vincent
fe7665aaaf Add support of template for docblock methods (fix #7320) 2022-01-13 11:04:37 +01:00
orklah
af37af7d8c
Merge pull request #7242 from zoonru/seal_all_properties
PHP 8.2: seal all properties configuration
2022-01-10 21:36:31 +01:00
Patrick Remy
a555543c0c
fix: pass static class name to ReturnTypeAnalyzer 2022-01-10 21:23:52 +01:00
b9e3979c3f
Cs-fix 2022-01-10 10:22:51 +01:00
a35ccfb0cb
Revert misguided changes 2022-01-10 10:19:12 +01:00
b530f23acc
PHP 8.2: seal all properties by default, add configuration key for lower versions 2022-01-10 10:11:28 +01:00
Matthew Brown
72fd3de886 Simplify return type for TypeExpander::expandAtomic 2022-01-09 16:19:04 -05:00
Matthew Brown
a435bc57b9 Rename was_static property to is_static to be more accurate 2022-01-09 14:45:07 -05:00
orklah
413da78568
Merge pull request #7326 from orklah/short_closures_returning_never
allow short closure to return never
2022-01-09 16:01:26 +01:00
orklah
c94e25fa7f refactor the TooFewArguments check to start checking with named arguments 2022-01-09 00:37:16 +01:00
orklah
ce2c6cf438 set the is_list flag for the array inferred for hrtime 2022-01-08 22:48:05 +01:00
Bruce Weirdan
1a1b5a9e6a
Merge branch '4.x' into upstream-master 2022-01-08 23:38:29 +02:00
orklah
afc3a76bc0 Seal the array inferred for hrtime 2022-01-08 22:22:21 +01:00
orklah
9d225086e9 replace empty checks on Union with dedicated method 2022-01-07 21:27:45 +01:00
Bruce Weirdan
762ef8dab4
Merge branch '4.x' into upstream-master 2022-01-07 08:44:32 +02:00
orklah
cbb0c6398f allow short closure with never 2022-01-06 21:36:34 +01:00
Fabien Villepinte
b9d8dd9d3f
Fix analysis when __invoke() exists 2022-01-06 21:22:18 +01:00
Bruce Weirdan
3fb3db3516
Merge branch '4.x' into upstream-master 2022-01-06 10:05:53 +02:00
Bruce Weirdan
b6559dcefb
Merge pull request #7315 from weirdan/rector-ClosureToArrowFunctionRector 2022-01-06 02:04:10 +02:00
orklah
bf4bf92cb2
Merge pull request #7313 from orklah/empty-arrays
replace `array<never, never>` as a way to detect empty arrays by a dedicated method
2022-01-05 23:58:45 +01:00
Bruce Weirdan
8726065d21
Applied ClosureToArrowFunctionRector 2022-01-06 00:48:04 +02:00
orklah
3c468b3eeb replace array<never, never> as a way to detect empty arrays by a dedicated method 2022-01-05 23:14:54 +01:00
orklah
e7bc6f273a don't crash when pushing a template to in_array 2022-01-05 22:33:20 +01:00
Bruce Weirdan
94395f18a4
Applied JsonThrowOnErrorRector 2022-01-05 19:32:43 +02:00
Bruce Weirdan
dd09450092
Applied NullCoalescingOperatorRector 2022-01-05 13:09:37 +02:00
Bruce Weirdan
5758d31161
Apply literal number separator rector
I opted for customary 3-digit groups, except version id, where 2-digit
groups are used to match the version id encoding.
2022-01-05 01:00:05 +02:00
Bruce Weirdan
401c2e9a83
Dropped deprecated TypeAnalyzer methods 2022-01-03 19:48:43 +02:00
Bruce Weirdan
b924032850
Mark internal classes @internal 2022-01-03 09:33:22 +02:00
Bruce Weirdan
ab60d311c2
Merge pull request #7188 from vimeo/muglug-use-invalidscalarargument-less 2022-01-03 06:04:42 +02:00
Bruce Weirdan
966b6ae2b2
Merge pull request #6808 from orklah/exitFunctions3 2022-01-03 06:04:01 +02:00
orklah
d912663da4
remove isEmpty 2022-01-03 04:10:41 +02:00
Matthew Brown
83911c7408
Remove unnecessary references to empty in TypeCombiner 2022-01-03 04:10:41 +02:00
Matthew Brown
2358b96f54
Fix merge errors 2022-01-03 04:10:39 +02:00
orklah
0747b48d06
remove TEmpty 2022-01-03 04:09:59 +02:00
orklah
b658b2738f
remove exitFunctions 2022-01-02 15:20:01 +02:00
Matthew Brown
b419c299e3
Use InvalidScalarArgument only when we can be sure PHP attempts coercion 2022-01-02 14:56:18 +02:00
orklah
8d6b781b3e
use consistent way to compare php version 2022-01-02 13:35:43 +02:00
Bruce Weirdan
5362f3be91
Deprecate Codebase::$php_major_version and Codebase::$php_minor_version properties
Removed in #6898 (Psalm 5)
2022-01-02 13:22:37 +02:00
Bruce Weirdan
36d5a2a83c
Merge pull request #7019 from zoonru/no_ksort_list 2022-01-02 07:37:21 +02:00
Bruce Weirdan
697db76dc1
Merge pull request #7252 from AndrolGenhald/feature/allow-assertions-on-mutable-object-properties 2022-01-02 07:29:02 +02:00
Bruce Weirdan
376d2a389e
Merge pull request #7259 from klimick/infer-this-context-for-psalm-if-this-is 2022-01-02 05:31:24 +02:00
orklah
de95fbdbf2 revert #7054 2022-01-01 19:34:17 +01:00
orklah
2a6f12296e
Merge pull request #7260 from orklah/6691
forbid calling impure callable in immutable context
2022-01-01 12:08:07 +01:00
adrew
0f69483cc1 Fix method storage fetching 2022-01-01 13:33:00 +03:00
orklah
8049438408 forbid calling impure callable in immutable context 2022-01-01 11:13:45 +01:00
adrew
79ea094433 Template resolving for psalm-if-this-is 2022-01-01 13:03:17 +03:00
adrew
878dfa2250 Variable types inference in method context when method marked with psalm-if-this-is 2022-01-01 13:03:17 +03:00
orklah
51ba96c09d
Merge pull request #7253 from orklah/5874
allow calling mutation_free function inside a mutation_free context
2021-12-31 00:24:29 +01:00
AndrolGenhald
dd631c0c85 Skip reference tests, allow assertions on magic properties (fixes #6770). 2021-12-30 16:23:59 -06:00
orklah
392402cf6d allow calling mutation_free function inside a mutation_free context 2021-12-30 22:29:36 +01:00
AndrolGenhald
3ac497c811 Allow assertions on mutable object properties.
All of the functionality is already there, we just have to not prevent it.
2021-12-30 14:07:55 -06:00
adrew
2355f1bcdb Remove unused use 2021-12-30 22:46:18 +03:00
adrew
4a903c71a1 Checking psalm-if-this-is before applying psalm-this-out 2021-12-30 21:48:25 +03:00
7c24d33bb2
cs-fix 2021-12-30 11:36:56 +01:00
915ddcc620
Add new RedundantFunctionCall issues 2021-12-30 11:36:32 +01:00
82e24d5c1d
Disallow ksorting lists 2021-12-30 11:30:33 +01:00
Bruce Weirdan
03b7e94748
Merge pull request #7232 from trowski/issue-7196 2021-12-30 10:03:17 +02:00
orklah
81ac645990 remove commented old code 2021-12-29 00:44:48 +01:00
orklah
f047d5bc53 allow suppressing unevaluatedCode 2021-12-29 00:44:48 +01:00
orklah
0b3e1299de overwritten properties 2021-12-27 23:46:23 +01:00
orklah
5f6bb39888 if with common parts 2021-12-27 23:08:19 +01:00
orklah
2baf3b560a unnecessary statements 2021-12-27 23:00:40 +01:00
Aaron Piotrowski
87160c8711
Handle first-class callable in yield types 2021-12-27 15:55:31 -06:00
orklah
926a56a97c
Merge pull request #7230 from orklah/cleanup6
code grooming
2021-12-27 22:54:39 +01:00
orklah
094ffb36f9 phpdoc issues 2021-12-27 22:30:10 +01:00
orklah
3828db52b9
Merge pull request #7229 from orklah/cleanup5
remove always true/false conditions
2021-12-27 22:08:06 +01:00
Aaron Piotrowski
e23a915bb1
Fix first-class callables when used with magic method, built-in, or undefined methods
Closes #7196.
2021-12-27 14:29:33 -06:00
orklah
3ae80983cc fix unused and CS 2021-12-27 20:10:39 +01:00
orklah
9029e1d613 remove always true/false conditions 2021-12-27 19:59:11 +01:00
adrew
c0ca383020 Contextual inference for closure param types 2021-12-27 19:35:37 +03:00
sji
a90456ed8b
trim whitespaces in namespaces specified at @psalm-internal 2021-12-27 02:31:11 +02:00
adrew
63a1c71c83
Remove trailing comma 2021-12-27 00:45:25 +02:00
adrew
d6d0fc6704
Remove undefined variables 2021-12-27 00:45:25 +02:00
adrew
2e4d75d6bd
Fix closure param type inference in generic context 2021-12-27 00:45:22 +02:00
orklah
2827c3e87b
Merge pull request #7203 from orklah/6389
flag the context as "inside_conditional" when analyzing leftover cases to prevent emitting unused error
2021-12-23 22:22:46 +01:00
orklah
2c9541c1ed flag the context as "inside_conditional" when analyzing leftover cases to prevent emitting unused error 2021-12-23 22:18:27 +01:00
Tomasz Mlynski
c94364631b
Normalize variable name 2021-12-22 20:23:11 +01:00
Tomasz Mlynski
b3da242e78
Remove redundant projectDirs/extraDirs checks 2021-12-22 19:49:12 +01:00
Philip Hofstetter
d45cb64827
allow marking enum cases as @deprecated 2021-12-22 06:16:42 +01:00
orklah
cc9111ff48
Merge pull request #7161 from dvz/improve-project-files-discovery
Improve project files discovery performance
2021-12-21 22:31:39 +01:00
orklah
ca25b0f815 always unflag before leaving a analyzer 2021-12-21 18:30:29 +01:00
orklah
b1a1c65714 CS changes 2021-12-21 18:30:29 +01:00
orklah
56369a7ba6 fix wrong handling of flags in context 2021-12-21 18:30:29 +01:00
orklah
1eca2c32ae only emit PossiblyNullArrayAccess if there was no successful destructuring 2021-12-20 22:48:27 +01:00
orklah
cc618bc916 allow successful destructuring to also be null if the source was nullable 2021-12-20 22:48:27 +01:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
Tomasz Mlynski
4034959c1b
Use $directory_filter with FileProvider::getFilesInDir() to skip ignored directories 2021-12-14 18:25:09 +01:00
Tomasz Mlynski
837075a378
Use cached ProjectAnalyzer::$project_files to build list of changed files 2021-12-14 17:57:19 +01:00
ralila
6ee3d44092 Conversion of misc 2021-12-14 02:52:44 +01:00
ralila
19b2a64ce8 Conversion of Psalm\Internal\Analyzer\**\*Analyzer 2021-12-14 02:31:26 +01:00
ralila
c0adde8f45 Conversion of Psalm\CodeLocation\DocblockTypeLocation|Raw 2021-12-14 02:31:26 +01:00
rarila
1c298c4605 Conversion of Psalm\Type 2021-12-14 02:31:22 +01:00
ralila
e32af3c05a Conversion of Psalm\Type\Atomic 2021-12-14 02:26:28 +01:00
adrew
a8d23538b7 Fix closure param type inference with named params 2021-12-12 13:17:15 +03:00
Bruce Weirdan
41ca7f7f7a
Merge pull request #7136 from klimick/forbid-positional-args-after-named 2021-12-12 02:22:51 +02:00
Bruce Weirdan
e08a4f2a2a
Drop unused use 2021-12-12 01:58:45 +02:00
orklah
f79f857ded
Merge pull request #7133 from AndrolGenhald/remove-unused-suppressed
Allow suppressing UnusedPsalmSuppress, remove unused suppressions.
2021-12-11 23:24:31 +01:00
orklah
b6638412b1
Merge pull request #7082 from dvz/fix-parser-cache-maintenance
Fix parser cache files maintenance
2021-12-11 23:14:30 +01:00
AndrolGenhald
225af970cc Add comments explaining condition for UnusedPsalmSuppress. 2021-12-11 16:14:25 -06:00
orklah
6632ddf884
Merge pull request #7135 from klimick/fix-closure-param-type-inference
Fix type inference of closure params
2021-12-11 23:10:32 +01:00
orklah
50cc629a43 fix cs 2021-12-11 23:03:10 +01:00
orklah
a1268d94d5 fix some more expressions that can be replaced by getSingleAtomic 2021-12-11 22:37:44 +01:00
adrew
6cf2e31c4a Forbid positional arg after named arg 2021-12-11 23:37:15 +03:00
adrew
989c3ada2e Fix type inference of closure params 2021-12-11 22:51:18 +03:00
AndrolGenhald
23b781163a Use getSingleAtomic() instead of array_values(getAtomicTypes())[0]. 2021-12-11 13:44:34 -06:00
AndrolGenhald
bfe7f96b56 Allow suppressing UnusedPsalmSuppress, remove unused suppressions. 2021-12-11 13:23:00 -06:00
orklah
0ba5b0b30a
Merge pull request #7130 from AndrolGenhald/bugfix/fix-class-property-suppression
Class property issue suppression fixes.
2021-12-11 19:12:49 +01:00
AndrolGenhald
51d9652b70 Class property issue suppression fixes.
Fix @psalm-suppress and @psalm-allow-private-mutation being ignored if nothing else is in the docblock.
Fix @psalm-suppress not allowing extra text after the issue name.
Fix PossiblyUnusedProperty and UnusedProperty suppression not working at the property level.
Fix MissingPropertyType suppression not working at the property level.
2021-12-11 11:45:06 -06:00
Matthew Brown
4229045c23 Remove array properties that are never read 2021-12-11 11:55:37 -05:00
Matthew Brown
b558748db2 Detect unused properties that are written to inside arrays 2021-12-11 11:42:05 -05:00
orklah
76bb8bc655
Merge pull request #7113 from trowski/first-class-callables
Added support for first-class callables
2021-12-10 22:40:16 +01:00
Aaron Piotrowski
3c5e99ed1e
Revert reorder of getting method return type and checking args
Skipping checking args for first-class callables, but fixes handling of other methods.
2021-12-09 19:02:58 -06:00
orklah
ae765dfba8
Merge pull request #7054 from orklah/6933
fix missing case for displaying varId
2021-12-09 23:54:37 +01:00
Aaron Piotrowski
d5519fc53a
Use $stmt->args directly instead of creating new VariadicPlaceholder 2021-12-09 15:51:48 -06:00
Aaron Piotrowski
1f3a37ff02
Add support for first-class callables 2021-12-09 10:54:49 -06:00
orklah
eefdb95765
Merge pull request #7093 from orklah/7090
don't stop analyzing array, even if we already have a type and we can't create an object like
2021-12-08 22:37:57 +01:00
AndrolGenhald
ba881c80bf Use maybeAdd instead of accepts. 2021-12-08 12:15:32 -06:00
AndrolGenhald
b29fc6ad3c Allow operator overloading for Decimal extension (fixes #3938). 2021-12-08 10:59:37 -06:00
Matthew Brown
8daf9c42a9 Remove useless chunk of code in ScopeAnalyzer 2021-12-07 23:42:17 -05:00
orklah
c17af4128e don't stop analyzing array, even if we already have a type and we can't create an object like 2021-12-07 19:38:52 +01:00
Bruce Weirdan
2530b33dbd
Merge pull request #7076 from klimick/fix-generic-assertion 2021-12-07 08:08:48 +02:00
orklah
257d237192 ignore ComplexMethod: didn't see any easy refactoring 2021-12-06 20:13:33 +01:00
orklah
75312d93b1 Don't crash when checking purity of __callStatic in a trait 2021-12-06 19:00:37 +01:00
Tomasz Mlynski
e4b0b9b305
Remove redundant condition 2021-12-06 18:17:52 +01:00
Tomasz Mlynski
5c73d77f28
Remove unused methods 2021-12-06 18:16:07 +01:00
Tomasz Mlynski
7e54c5172d
Deprecate unused methods 2021-12-06 17:59:43 +01:00
Tomasz Mlynski
0fcad43581 Simplify parser cache files maintenance
Delete files that were not modified during a no-diff run
2021-12-06 17:57:44 +01:00
Ricardo Boss
2ec77fe29c Make name property of enum cases return non-empty-strings (vimeo/psalm#6964) 2021-12-06 00:33:57 +01:00
adrew
dee3fc4358 try to fix generic assertions for list and array 2021-12-06 02:25:40 +03:00
rarila
39402c233d
Return type hints (#7065)
Co-authored-by: ralila <>
2021-12-05 19:51:26 +02:00
orklah
f67a0ca143
Merge pull request #7068 from klimick/fix-yield
Detect yield in array expression
2021-12-05 16:25:21 +01:00
Ricardo Boss
8a230110e8 Fix vimeo/psalm#6968 2021-12-05 15:43:38 +01:00
adrew
bc61547bce detect yield in array expression 2021-12-05 15:33:18 +03:00
Bruce Weirdan
e9d9481ea6
Merge pull request #7060 from rarila/codingstyle-convert-fqn 2021-12-05 02:46:03 +02:00
ralila
9902898c4d Remove unnecessary bug circumvention and generate new baseline 2021-12-05 01:15:29 +01:00
Matthew Brown
1956b85c41
Remove always-false args (#7056) 2021-12-04 10:40:52 -05:00
ralila
f833085a15 Fix fqn usage in php-doc 2021-12-04 03:37:19 +01:00
orklah
2612f5a5f1 fix missing case for displaying varId 2021-12-03 23:46:12 +01:00
ralila
30a65685a2 Import instead of using fqn classes 2021-12-03 21:40:18 +01:00