1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-15 10:57:08 +01:00
Commit Graph

298 Commits

Author SHA1 Message Date
Brown
2b060b75d3 Fix #4052 - foreach over an iterable is impure 2020-08-25 11:24:57 -04:00
Bruce Weirdan
5bf7cc6434
Resolve typedefs that are used in var docblocks of foreach (#4037)
Fixes vimeo/psalm#4029
2020-08-22 08:20:05 -04:00
Brown
12798d1cab Prevent access to possibly unset var 2020-08-17 15:25:13 -04:00
Brown
b6d9ee5eb1 Fix things 2020-08-07 12:16:35 -04:00
Brown
e61765ff9b Fix #3954 - catch ComplicatedExpressionException with added workaround 2020-08-07 08:20:35 -04:00
Brown
76bd5b6278 Refactor type comparison 2020-07-21 19:40:35 -04:00
Brown
3c9028c182 Fix #3808 - allow detection of paradoxes in switch condition function calls 2020-07-14 10:51:12 -04:00
Brown
bf7bcc0dca Fix #3779 - allow ParadoxicalCondition of default to be suppressed 2020-07-08 14:51:20 -04:00
Brown
1b498e6dae Remove unused variable 2020-07-06 17:41:07 -04:00
Brown
eb3ce8d368 Remove unused code 2020-07-06 15:39:52 -04:00
Brown
44d7f51857 Generalise init vars inside for loops
Ref #3085
2020-07-03 11:13:44 -04:00
Brown
1745f5cafa Fix too-long line 2020-07-02 15:32:13 -04:00
Brown
0c582e9993 Fix #3685 - improve handling of if conditionals inside do 2020-07-02 13:59:59 -04:00
Brown
dd25b81d3a Fix #3670 - taint mixed foreach access 2020-06-24 19:16:30 -04:00
Brown
bbada7ba8d Ensure correct vars are used 2020-06-15 17:16:12 -04:00
Brown
05cb39814c Improve performance of long switch checks 2020-06-15 16:23:19 -04:00
Brown
9ca6c868b7 Fix #3563 - add workaround for == true 2020-06-12 10:58:44 -04:00
Matthew Brown
c9ee691595
Fix suppression 2020-06-04 09:55:32 -04:00
Brown
fd74d3284d Add support for PHPParser 4.5.0 2020-06-03 14:58:08 -04:00
Brown
ef53ee3a3b Fix crash on aliased exception
Ref #3465
2020-05-27 08:09:58 -04:00
Brown
0b2da18f1e Break up StatementsAnalyzer 2020-05-19 12:56:30 -04:00
Brown
5ee1487a01 Make ExpressionAnalyzer more beautiful 2020-05-18 15:13:27 -04:00
Matthew Brown
f6342a40d9 Remove unnecesary conditional check for do
Fixes #3378
2020-05-16 16:32:36 -04:00
Brown
3554aa4435 Fix crash newly introduced 2020-05-11 09:34:07 -04:00
Brown
8f2f2617d4 Improve refactor 2020-05-10 22:45:01 -04:00
Brown
5f4d162dd5 Break out type expander into separate class 2020-05-10 22:39:18 -04:00
Matthew Brown
4b388a2951 Fix ref 2020-05-10 11:35:35 -04:00
Brown
55222573ea Mark as possibly-undefined any variable that wasn’t present when the loop began
Fixes #3332
2020-05-10 11:17:50 -04:00
Brown
9e6797d297 Add protection from ComplicatedExpression 2020-04-30 22:23:07 -04:00
Brown
189cd2bdc8 Fix key stringg 2020-04-27 00:50:07 -04:00
Brown
755ada9114 Fix #3234 - infer iterator key types properly 2020-04-27 00:41:34 -04:00
Brown
e1c6fcc707 Fix #3215 - suppress PossiblyUndefinedMethod in synthetic call 2020-04-24 00:11:32 -04:00
Brown
b0455adced Fix #3177 - prevent crash by using inherited templates 2020-04-18 11:48:22 -04:00
Brown
e17cfd8dba Fix #3125 - only apply clauses where applicable 2020-04-12 21:50:10 -04:00
Brown
d530fce4b3 Fall through with PossiblyInvalidIterator issue 2020-04-11 11:17:54 -04:00
Brown
556d5625b5 Prevent Throwable being intersected with itself 2020-04-10 00:10:31 -04:00
Brown
b2e010b431 Fix #3102 - identify issues with possibly-mixed output 2020-04-08 14:07:09 -04:00
Brown
550ba0a4c9 Compare to real outer context, not if one
Fixes #3091
2020-04-07 15:13:17 -04:00
Brown
61c979136f Fix #3091 - simplify elseif negated clauses where possible 2020-04-07 13:04:24 -04:00
Brown
067104e170 Fix #3084 - keep track of upper and lower bounds of inferred template types 2020-04-07 00:13:56 -04:00
Matthew Brown
b46e147735 Add some limits on switch case assertion calculation
Ref #2728
2020-03-30 00:20:00 -04:00
Matthew Brown
86a89b2d27 Fix #3034 - expand out while expressions for more accurate variable initialisation 2020-03-28 18:22:08 -04:00
Matthew Brown
47c1470e3b Refactor reference checks to use more appropriate properties 2020-03-28 16:30:56 -04:00
Tyson Andre
e560858b23
Fix grammar nit in "is can never happen" message (#3025)
Should either be "is impossible" or "can never happen"
2020-03-27 17:32:49 -04:00
Brown
971ae50bea Do prep work for #3024 - improve handling of absent class references 2020-03-26 12:35:27 -04:00
Matthew Brown
c85fa9083d Fix #2915 - prevent "if (true)" and similar 2020-03-15 22:23:31 -04:00
Matthew Brown
b6380ae595 Fix false-positives around unevaluated code 2020-03-15 14:43:05 -04:00
Matthew Brown
6c7f89b0ab Fix #2920 - track unevaluated code after nested returns 2020-03-15 14:31:41 -04:00
Matthew Brown
43189b3d55 Allow types to be traversed 2020-03-14 23:54:51 -04:00
Matthew Brown
54d38e562f Fix #2970 - use correct unreferenced vars when analysing do 2020-03-13 11:41:17 -04:00
Matthew Brown
bfb919d26a Break out methods into their own classes 2020-03-11 23:04:52 -04:00
Sergey Melesh
a5da866d97 Ignore exceptions already caught by previous catch 2020-03-08 20:19:56 -05:00
Matthew Brown
d3bfb96431 Fix #2808 - improve yield type discernment 2020-02-15 10:47:07 -05:00
Brown
f141f7c526 Improve --diff checks by including trait-using classes in dependents 2020-02-11 16:39:33 -05:00
Matthew Brown
5eb2ebc508 Add more type-system protections for bad array args 2020-01-29 23:41:17 -05:00
Brown
15808458cc Better understand nesting loops and switches
Fixes #2700
2020-01-27 12:17:12 -05:00
Brown
53b0650c6c Fix #2688 - foreach loop evaluation should allow changing loop var 2020-01-24 13:55:30 -05:00
Matthew Brown
1c8af2fdc7 Fix #2658 - catch exceptions thrown inside catch 2020-01-17 12:05:37 -05:00
Matthew Brown
4888ae67a6 Fix #2558 - remove wedge clauses when they’re the only thing left 2020-01-06 08:56:50 -05:00
Matthew Brown
8ecb8555e2 Fix count 2020-01-04 13:12:22 -05:00
Matthew Brown
37fb15250c Add check for only simplest conditionals 2020-01-04 13:09:55 -05:00
Matthew Brown
8cbc26c2f1 Add range checks to identify for loops that always enter 2020-01-04 13:05:23 -05:00
Matthew Brown
9fa2db1b6c Move Union::getTypes to Union::getAtomicTypes 2020-01-04 12:20:26 -05:00
Matthew Brown
ba6d0df048 Fix #2546 properly 2020-01-04 11:16:53 -05:00
Brown
0e39759ed6 Improve solution to #2546 slightly 2020-01-03 10:56:47 -05:00
Brown
ca1e65b29b Handle iterators better 2020-01-02 10:41:43 -05:00
Matthew Brown
25e7039f02 The current method is used
Fixes #2540
2020-01-01 18:33:12 -05:00
Matthew Brown
c79ba0b09e Include non-empty-string type in more places 2019-12-30 07:25:36 -05:00
Matthew Brown
55c2f7faa2 Fix #2508 - don’t replace templated types with generic ones inside own function 2019-12-28 18:38:02 -05:00
Matthew Brown
ce9435da19 Fix #2521 - use correct context class when analysing trait 2019-12-28 15:56:26 -05:00
Matthew Brown
4c8730c5a3 Improve handling of unset array, ensuring that keys don’t persevere 2019-12-22 01:42:39 +00:00
Matthew Brown
a4191171bf Fix #2483 - treat intersecting PHPDocs from interfaces better 2019-12-20 01:42:57 +00:00
Brown
2469f04715 Improve reconciliation of arrays with constant offsets 2019-12-13 17:17:14 -05:00
Brown
05783eb616 Find issues with impossible property values 2019-12-11 17:08:02 -05:00
Brown
e476eed111 Fix issue where inside_conditional is forgotten 2019-12-11 12:06:10 -05:00
Matthew Brown
02fbf12337 Only warn about clauses in the currently-scanned conditional 2019-12-08 16:35:56 -05:00
Matthew Brown
83b10bb9af Fix #2426, or at least some of it 2019-12-08 00:49:34 -05:00
Matthew Brown
2b6831ba10 Fix too-long line 2019-12-07 01:38:24 -05:00
Matthew Brown
df395944f8 Change how $changed_var_ids is communicated 2019-12-07 01:23:35 -05:00
Brown
ef44bd104e Consolidate some fixes from the binaryop branch 2019-12-06 12:47:27 -05:00
Brown
8ff33ee64d Fix #1943 - give up analysing really complicated conditionals 2019-12-05 10:26:53 -05:00
Brown
821f3528d2 Fix #701 - indicate issues fixable with Psalter 2019-12-02 15:24:01 -05:00
Matthew Brown
e40aaafe61 Allow explicit @var mixed docblocks
Fixes #2397
2019-12-01 10:19:42 -05:00
Brown
1f07ea7ee7 Tighten up Psalm’s inference 2019-11-25 15:20:31 -05:00
Brown
1add42b691 Fix switch handling 2019-11-25 11:51:34 -05:00
Brown
0bcb7863f3 Use better system for storing inferred types and assertions 2019-11-25 11:44:54 -05:00
Brown
7b719915f5 Fix style things 2019-11-12 10:21:27 -05:00
Brown
7f5af741f7 Improve assertion calculation on mixed vars 2019-11-12 10:12:07 -05:00
Matthew Brown
b1aae0d1a5 Fix more try/catch stuff 2019-11-12 00:52:10 -05:00
Brown
51557c44ea Evaluate finally blocks at the end of every catch 2019-11-11 18:38:33 -05:00
Brown
da03902f76 Fix handling of do... while vars defined in try 2019-11-11 18:24:43 -05:00
Brown
f22266b2ff Improve reasoning around try/catch possibly-undefined vars 2019-11-11 17:42:46 -05:00
Brown
1a54aa5752 Fix test 2019-11-11 17:07:26 -05:00
Brown
cd2f8e7d65 Fix memory corruption 2019-11-11 16:56:44 -05:00
Brown
935bad9d2c Fix erroneous unused variable 2019-11-11 16:52:55 -05:00
Brown
d15989c975 Allow catch to assume no try statements completed 2019-11-11 15:17:53 -05:00
Brown
fbd1cf0a71 Fix #2322 - don’t update outer context if elseif has no leaving statements 2019-11-11 11:46:27 -05:00
Brown
96586f16c0 Fix phpcs issues 2019-11-11 10:11:42 -05:00
Matthew Brown
94d4b876ba Fix #2177 - mark variables in try block as potentially undefined 2019-11-09 12:25:30 -05:00
Matthew Brown
62a3598ed3 Fix #2197 - prevent false positive from try in while 2019-11-09 11:01:48 -05:00
Matthew Brown
7028a64440 Fix #2204 - fix try/catch false-positive 2019-11-09 10:39:21 -05:00
Matthew Brown
233977a764 Fix undefined array offset when too few iterator params supplied 2019-10-21 07:13:33 -04:00
Matthew Brown
4aeb28aceb Fix #2244 - correctly check do while expression before use 2019-10-20 14:18:30 -04:00
Brown
2be489c527 Fix regression when identifying clauses in error 2019-10-18 15:06:37 -04:00
Matthew Brown
e8618371fb Refine isset checks 2019-10-17 01:09:21 -04:00
Matthew Brown
54a31f8cff Be more scrupulous about mixed vars 2019-10-17 00:29:51 -04:00
Matthew Brown
29902c8b99 Fix #2237 - suppress reconciling issues when inherited clauses couldn’t be resolved into types 2019-10-16 21:55:11 -04:00
Brown
16c33d1565 Add support for list type
Fixes #2209
2019-10-08 18:44:46 -04:00
Brown
6b012f8fa6 Use smarter type merging when analysing if statements 2019-10-08 13:07:28 -04:00
Brown
f8f8b633b1 Suppress a bunch of PossiblyUndefinedArrayOffset issues 2019-10-01 15:44:43 -04:00
Brown
cf799d0926 Fix #2173 - remove @var annotations automatically 2019-09-26 15:08:05 -04:00
Matthew Brown
fdbea45534 Fix #2159 - only apply elseif conditions to vars that exist in main context 2019-09-21 16:58:31 -04:00
Brown
c5ef2516b5 Fix #2150 - add detection for unnecessary @var annotations
And also remove them from codebase
2019-09-19 11:59:43 -04:00
Matthew Brown
853e92e7fc Fix #2073 - better understand assignments inside elseif 2019-08-26 22:55:28 -04:00
Matthew Brown
25487a5b63 Break out if conditional analysis 2019-08-26 22:55:01 -04:00
Brown
febd60dade Add better handling of catch-reassigned vars
Ref #2052
2019-08-26 11:41:15 -04:00
Brown
80d9b5dc29 Add support for iterating over SimpleXMLElement 2019-08-23 14:15:20 -04:00
Brown
9835943294 Fix #2041 - make sure property is always set 2019-08-21 11:25:08 -04:00
Brown
95c61db513 Add a PossibleRawObjectIteration issue 2019-08-20 12:06:02 -04:00
Brown
b5614d03f8 Add detection for unused function calls 2019-08-13 13:15:23 -04:00
Brown
10b8a94564 Fix #2007 - improve unused variable detection in always-entered loops 2019-08-12 16:01:24 -04:00
Matthew Brown
50bd18c404 Fix #1985 - prevent complicatedExpressionException from breaking analysis 2019-08-06 22:58:53 -04:00
Brown
c67e38aded Rename var to be more uniform 2019-07-31 17:14:00 -04:00
Matthew Brown
2c89a97f91 Fix #1970 - make sure reconciled types are templated 2019-07-25 08:33:27 -04:00
Tyson Andre
5d5a9c6eac Remove redundant casts and unused use statements (#1955)
* Remove redundant casts

(not sure about older versions of php-parser)

* Remove unused use statements
2019-07-18 23:37:36 -04:00
Matthew Brown
30ecde2272 Overwrite var when try exits 2019-07-07 14:00:49 -04:00
Matthew Brown
cd715a60fd Fix #1909 - populate var scope if try always leaves 2019-07-07 13:52:43 -04:00
Matthew Brown
678d4e5286 Fix #1901 - improve loop-based handling of vars after continue 2019-07-04 20:38:52 -04:00
Matthew Brown
6dd549b8a6 Fix #1900 - discard old references to code after an assignment 2019-07-04 17:35:33 -04:00
Tyson Andre
af52ad245a Remove unused variables (#1898) 2019-07-04 15:17:28 -04:00
Matthew Brown
9ab3161675 Fix issues found by Psalm 2019-06-29 21:13:02 -04:00
Matthew Brown
436ccae819 Fix SwitchAnalyzer memory leak 2019-06-29 19:20:09 -04:00
LeSuisse
f29826b958 Fully qualify constants and function calls (#1849)
This should give a small performance boost.
Part of #1837.

The change is enforced via phpcs and can be autofixed
with phpcbf.
2019-06-26 16:52:29 -04:00
Matthew Brown
c66a106622 Improve performance by doing less cloning
Ref #1837
2019-06-26 00:14:06 -04:00
Matthew Brown
c0b86bd40d Use uppercase template_type_extends keys 2019-06-24 23:43:04 -04:00
Brown
0246f600f4 Fix #1813 - convert object&Foo into Foo after template resolution 2019-06-19 12:00:19 -04:00
Brown
ddd287fb3d Move exception classes 2019-06-05 11:33:04 -04:00
Matthew Brown
ad4e2f72e2 Add means to guess PSR4 file path 2019-06-05 08:50:24 -04:00
Brown
f309c755f8 Add ability to move classes 2019-06-05 08:50:24 -04:00
Matthew Brown
2b0a17c1c8 Add simple tool to move static methods 2019-06-02 01:10:50 -04:00
Matthew Brown
909e02d441 Move var docblocks within function 2019-06-01 12:25:57 -04:00
Matthew Brown
dc5a5bcd9d Simplify var docblock parsing signature 2019-06-01 11:53:32 -04:00
Matthew Brown
cd969c51e5 Generate missing param types from callers
Fixes #1707
2019-05-31 01:47:35 -04:00
Matthew Brown
962d8f30a1 Fix #710 - treat keyed intersections of iterators properly 2019-05-29 19:58:54 -04:00
Brown
0e6d07c4e9 Add ancillary var types 2019-05-28 11:58:15 -04:00
Matthew Brown
790bc53bfd Fix #1681 - interpret parent annotation properly 2019-05-25 11:51:09 -04:00
Brown
8c653b0312 Improve dead code detection a little more 2019-05-20 18:25:11 -04:00
Brown
2637156f45 Properly fix #1128 with additional check 2019-05-20 12:01:18 -04:00
Brown
83a2122f8c Fix #1464 and fix #1128 - reduce try/catch UnusedVariable false positives 2019-05-20 11:54:21 -04:00
Matthew Brown
1c10ae11bf Fix #1580 - look for no-returns in try/catch statements 2019-05-14 21:22:29 -04:00