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

403 Commits

Author SHA1 Message Date
Brown
d7ee952084 Infer closure param type for array_filter/array_map
Fixes #664
2019-05-07 16:27:25 -04:00
Matthew Brown
4f8d6a50d8 Don’t emit MissingClosureReturnType when inside call and type can be inferred 2019-05-06 20:47:55 -04:00
Brown
fec1a60e90 Ref #1600 - partial fix inferring param types when none is available 2019-05-06 18:44:10 -04:00
Brown
751253ddf0 Fix #1603 - prevent invalid covariant template classes from being passed 2019-05-06 16:38:08 -04:00
Brown
640c1d13a6 Fix unused variables now found in Psalm’s code 2019-05-02 17:21:23 -04:00
Brown
08bf101f48 Fix #1598, catching unused variables followed by try inside loop 2019-05-02 17:21:02 -04:00
Brown
86bf159bd0 Avoid false positive for param 2019-05-02 15:33:47 -04:00
Brown
4f26c8d749 Fix #1597 - ternary else should only know about first conditional expression 2019-05-02 13:43:18 -04:00
Matthew Brown
ae531506de Fix #1591 - allow variable typed to string to be compared to literal in reverse order 2019-05-02 00:50:35 -04:00
Matthew Brown
e08944cae0 Allow diff mode with --find-dead-code 2019-04-27 17:38:24 -04:00
Matthew Brown
59e53acd56 Fix new template class array key coercion to mixed - when we don’t know, assume bottom type 2019-04-26 07:54:21 -04:00
Tyson Andre
dbcedd300b Fix error messages for $boolVar !== null
Seen for this example:

    $b = rand() % 2 > 0;
    if ($b !== null) { ... }
2019-04-26 00:19:46 -04:00
Brown
0e4c8ce482 Split apart TypeCoercion issues, allowing more granular issue filtering 2019-04-25 18:02:19 -04:00
Matthew Brown
3681762a9b Add detection for callable variable use 2019-04-23 22:31:38 -04:00
Matthew Brown
9be8013633 Add a way to ignore variable method & property calls 2019-04-20 17:49:49 -04:00
Brown
205fa36fb7 Add better error messages to unused code issues 2019-04-19 11:45:22 -04:00
Brown
d6de6ca5d5 Prevent removing properties on classes with variable assignment 2019-04-18 14:47:58 -04:00
Brown
4807ebe04a Always evaluate static calls when method call cannot 2019-04-18 13:51:34 -04:00
Brown
d51475bc03 Register magic property get/set propertyExists calls 2019-04-18 10:41:46 -04:00
Brown
a529f74473 Add support for tracking callables 2019-04-17 15:45:40 -04:00
Brown
80e28d6a4a Add support for unused method & property automated removal 2019-04-17 11:12:18 -04:00
Brown
ff14f671b1 Add hopefully-more-portable method for evaluating method/property usage 2019-04-16 16:07:48 -04:00
bugreportuser
8454c0db39 Support for bitwise not 2019-04-14 10:16:38 -04:00
Bruce Weirdan
8dda8a0ee4 cs fix 2019-04-13 12:35:49 -04:00
Bruce Weirdan
4daf94ca1d Case-insensitive checks for var_dump and shell_exec
Fixes vimeo/psalm#1547
2019-04-13 12:35:49 -04:00
Brown
26e2de93c7 Prepare to enable paralellised use of --find-dead-code
References #1548
2019-04-12 18:28:07 -04:00
Brown
b6d0ee0777 Prevent impossible === false comparison 2019-04-12 10:30:56 -04:00
Matthew Brown
39af691d2f Fix #1546 - catch impossible assertions to true 2019-04-12 09:38:56 -04:00
Matthew Brown
ea20a2bd04 Fix #1540 - use correct comparison for callable param types 2019-04-12 00:44:10 -04:00
Brown
be5a262deb Add better handling for non-edge-case function calls 2019-04-11 14:53:21 -04:00
Brown
8f1dbc072d Allow empty offset sets on arrayaccess objects 2019-04-10 17:25:25 -04:00
Brown
7f8b47c5cf Fix buggy behaviour around callable tests 2019-04-09 18:09:57 -04:00
Brown
808522c36f Add workaround SoapFault::__construct, fixing #1535 2019-04-09 15:06:10 -04:00
Brown
1348d634ed Improve handling of variadic parameters 2019-04-09 13:58:49 -04:00
Brown
9447cd2d98 Prevent scalar property assertion error 2019-04-03 10:59:27 -04:00
Brown
08a4573a1c Fix #1525 - allow scalar return types to accept false 2019-04-03 10:56:29 -04:00
Brown
21b1c04c1d Fix #1526 - ignore files if they weren’t picked up in scanning step 2019-04-03 10:43:48 -04:00
bugreportuser
f5e03715f3 Fix memory leak 2019-04-02 23:36:55 -04:00
Matthew Brown
ef8292cfc7 Fix #1510 - analyse mixed array offsets 2019-03-31 15:42:15 -04:00
bugreportuser
1a4b9ab25f Allow suppressing exception issues inline 2019-03-31 14:22:19 -04:00
bugreportuser
4fc7e4affc Give errors for all uncaught exceptions 2019-03-31 14:22:19 -04:00
Brown
09a8d68288 Use more specific location for return type issues 2019-03-29 15:36:13 -04:00
Brown
1ab6345bac Fix treatment of PDOStatement::setFetchMode
Fixes #1496
2019-03-29 13:26:13 -04:00
Matthew Brown
230680fd1c Fix #1513 - use correct param types when examining abstract trait methods 2019-03-28 22:47:17 -04:00
Brown
937eb42e8b Do not override parent return type 2019-03-28 10:43:49 -04:00
Matthew Brown
bd6fea0d57 Fix #1514 - catch static interface call 2019-03-28 08:22:44 -04:00
Matthew Brown
e9afd3a6f3 Examine arrays in unknown function calls 2019-03-27 22:13:06 -04:00
Matthew Brown
63a0e768b3 Improve type coverage in both good and bad ways 2019-03-25 22:30:40 -04:00
Brown
783f028f70 Fix #1498 - use template types from parent function 2019-03-25 11:25:43 -04:00
bugreportuser
8b12751007 Keep track of throw code locations 2019-03-24 23:03:37 -04:00
Tyson Andre
2e6a2f14ed Fix typos in psalm with codespell's dictionary 2019-03-24 23:01:20 -04:00
Tyson Andre
fc83f1c3ea Fix typo: "Arithmentic" -> "Arithmetic" 2019-03-24 23:00:51 -04:00
Matthew Brown
6bcc3d0261 Don’t stop analysing on var_dump 2019-03-23 10:58:26 -04:00
Matthew Brown
ee56419fd6 Improve accuracy and durability of mixed counts 2019-03-23 09:50:47 -04:00
Brown
9cf78e9097 Remove unused var 2019-03-22 19:12:06 -04:00
Brown
c221eccbf5 Tidy up method call analyser 2019-03-22 18:02:33 -04:00
Brown
cacd5a1946 Cast null array key to empty string
Fixes #1487
2019-03-22 16:45:17 -04:00
Brown
cc568422d8 Fix #1488 - allow inheritance when dummy template exists 2019-03-22 16:29:30 -04:00
Brown
b9ba24929d Refactor storage of template names to prevent clashes 2019-03-22 15:59:10 -04:00
Brown
ab6ca4dc35 Fix #1491 - allow comparison to typed value 2019-03-21 17:26:10 -04:00
Brown
8d06c6a700 Fix #1480 by remembering where a property was set 2019-03-19 19:43:18 -04:00
Brown
6081c742c5 Fix incorrect InvalidArgument for array value scalar mismatch 2019-03-19 16:45:26 -04:00
Brown
880b07783f Error should be InvalidScalarArgument 2019-03-19 16:12:38 -04:00
Matthew Brown
472ab29d74 Add PossiblyInvalidCast for more refined checks 2019-03-17 17:10:51 -04:00
Matthew Brown
bf586bf93b Fix #1471 - report issue with string casting inside string 2019-03-17 16:31:56 -04:00
Matthew Brown
9ee4a7414b Fix #1461 - check interfaces when analysing abstract method call 2019-03-17 14:16:52 -04:00
Matthew Brown
2f8bfffe95 Fix #1475 but, like, properly this time 2019-03-17 13:50:02 -04:00
Matthew Brown
ca765cba58 Fix errors caused by bad generic param counts
Fixes #1474
2019-03-17 12:20:57 -04:00
Matthew Brown
de7df3175b Fix #1368 - improve message formatting 2019-03-16 12:53:54 -04:00
bugreportuser
e31cfa503d Allow reconciling superglobal types 2019-03-16 12:49:38 -04:00
Matthew Brown
01d6caf6a2 Catch negated instanceof bugs 2019-03-16 12:34:48 -04:00
Matthew Brown
a0659a02f1 Fix #1418 - support templated union types 2019-03-16 11:15:25 -04:00
Matthew Brown
ab832207a4 Fix #1453 - traits are not valid classes 2019-03-15 22:12:35 -04:00
Matthew Brown
b82709897a Fix #1460 2019-03-15 21:50:16 -04:00
Brown
85f34f2aca Add defining class and increas string length 2019-03-12 12:58:04 -04:00
bugreportuser
0e9fb04f06 Define globals in more places 2019-03-11 15:53:21 -04:00
Matthew Brown
95b986d2d4 Fix #1367 - allow assertions on mixed arrays to define objectlike type 2019-03-10 23:38:30 -04:00
Matthew Brown
848b070946 Fix #1413 - don’t complain about byref use param 2019-03-10 16:36:35 -04:00
bugreportuser
57a4522ee7 Flesh out callable arg types 2019-03-07 23:24:50 -05:00
Matthew Brown
85f0fa6e7d Add support for literal templated defaults 2019-03-07 22:32:38 -05:00
Brown
5beb26659e Add special type for SQL select strings for plugins to consume 2019-03-07 14:56:18 -05:00
bugreportuser
b34dbe26e2 Allow setting superglobal types 2019-03-06 15:59:41 -05:00
bugreportuser
056e5a5b1e Allow setting globals in config 2019-03-06 15:59:41 -05:00
Brown
9442805763 Mutation checks should not care about return type 2019-03-06 11:12:36 -05:00
Brown
ae69695f89 Prevent tests in PHP 7.1 2019-03-05 18:27:25 -05:00
Matthew Brown
48b39a15b9 Don’t change value of $this by reference 2019-03-03 20:16:11 -05:00
Matthew Brown
a31420be5b Fix checks for existing vars used in by-ref assignments 2019-03-03 18:21:12 -05:00
Matthew Brown
b7320e2778 Remove unnnecessary param 2019-03-03 16:45:35 -05:00
Matthew Brown
fb9e9bea32 Fix const reference in current context 2019-03-03 16:43:24 -05:00
Matthew Brown
472cdf6bea Fix #1379 - allow @param-out to change type 2019-03-03 15:11:09 -05:00
Matthew Brown
82e6876011 Fix #1397 - fix get_class behaviour for new instances 2019-03-02 18:02:11 -05:00
Matthew Brown
4757c2fe8e Fix messaging 2019-03-02 15:19:59 -05:00
Matthew Brown
5e61f198e1 Fix #1419 - allow checks against empty arrays 2019-03-02 15:18:29 -05:00
Matthew Brown
efbcf7dc5b Fix #1417 - store root file path when scanning for manipulations 2019-03-02 15:07:26 -05:00
Matthew Brown
5c76ab35c8 Allow properties to be set regardless of visibility 2019-03-01 17:30:55 -05:00
Matthew Brown
4cc93644e5 Added more descriptive type for callables
Ref #1408
2019-03-01 09:06:37 -05:00
Matthew Brown
317f790bde
New plugin hooks (#1405)
* Add a bunch of new hooks

* Add more integrations

* Add some broken tests

* Add more things

* Fix remaining interfaces

* Suppress proper issue

* UndefinedMethod should not stop analysis

* Add handlers for two custom method return types
2019-03-01 08:57:10 -05:00
Matthew Brown
d1cf9d61ba Fix #1398 - improve casting rules for resource 2019-03-01 00:50:22 -05:00
Matthew Brown
55e125f495 Check method args before returning 2019-02-28 23:59:17 -05:00
Matthew Brown
b8b752ed01 Fix #1402 - don’t halt after suppressing static UndefinedMethod 2019-02-28 23:46:11 -05:00
Brown
815bf845dc Improve handling of method/function return types 2019-02-27 17:06:44 -05:00
Brown
119687f934 Fix redundant condition message when negating a docblock type 2019-02-27 14:02:02 -05:00
Matthew Brown
b310cc07b5 Array access on objects should always be treated as method call 2019-02-26 21:24:30 -05:00
Matthew Brown
8650f9eb1a Fix #1356 - improve assertion system to work better on function calls 2019-02-26 01:03:33 -05:00
bugreportuser
7f7125f334 Fix crash for empty string array access 2019-02-25 08:26:12 -05:00
Matthew Brown
4f770d356e Fix #1384 - evaluate array fetches even when we don’t know function 2019-02-24 09:58:11 -05:00
Matthew Brown
3ad1abece4 Add generation of json artifacts 2019-02-24 01:33:25 -05:00
Matthew Brown
cdae79b9fe Fix unnecessary params in Psalm codebase 2019-02-23 11:31:33 -05:00
Matthew Brown
ce4f2e6334 Fix #1364 - use proper types for extended getIterator calls 2019-02-21 23:01:34 -05:00
Matthew Brown
1c8a573b5f Change TGenericParam to TTemplateParam 2019-02-21 21:40:06 -05:00
Brown
154e1fa38b Fix #1375 - improve treatment of dynamically-declared namespaces 2019-02-21 18:19:12 -05:00
Brown
653555a8cc Remove unused var 2019-02-21 17:49:33 -05:00
Brown
41b133178a Improve handling of count comparisons 2019-02-21 17:17:10 -05:00
Brown
b7a0950aea Prevent passing casts to byref vars 2019-02-21 13:26:37 -05:00
Brown
1e2c29041f @param-out should not override @param byref type def
when checking for unuitialised vars
2019-02-20 18:53:42 -05:00
Brown
079ac44263 Prevent pass by ref when type type is given 2019-02-20 17:43:12 -05:00
bugreportuser
14ee221075 Fix errors 2019-02-20 10:55:36 -05:00
bugreportuser
cd23a19931 Allow concat for define first arg 2019-02-20 10:55:36 -05:00
bugreportuser
f603449745 Infer literal string for __namespace__ 2019-02-20 10:55:36 -05:00
Brown
348b8eef1f Fix #1366 - don’t complain about invalid array offset when possibly mixed 2019-02-19 11:42:24 -05:00
Matthew Brown
f49be31aeb Fix #1332 - use the correct identifier for trait property resolution 2019-02-18 16:52:09 -05:00
Matthew Brown
6b419452af Fix #1337 - don’t crash when examining __call methods in initialisation checks 2019-02-18 16:04:27 -05:00
Matthew Brown
709a5c31da Allow bitwise or ops to change type
Ref #1340
2019-02-18 12:53:55 -05:00
Matthew Brown
12f1ffca11 Fix issue reconciling mixed vars inside loop 2019-02-18 11:39:05 -05:00
Matthew Brown
5777e008c0 Remove var_dump 2019-02-17 13:18:23 -05:00
Bruce Weirdan
8408effe57 Dropped unused uses 2019-02-17 13:17:45 -05:00
Matthew Brown
40a91eab6e Fix #1339 - no crash when using self/static/parent in closure 2019-02-17 13:14:59 -05:00
Matthew Brown
0739d017ac Use information from .phpstorm.meta.php files in stubs 2019-02-16 11:16:52 -05:00
Matthew Brown
d76459e138 Move to a PHPStan-like return type provider class model 2019-02-15 18:00:40 -05:00
Brown
27c99aed2f Improve recovery from InvalidScalarArgument issue 2019-02-14 16:55:54 -05:00
Brown
50421b297a Don’t report undefined properties when collecting initialisations 2019-02-13 14:04:10 -05:00
Brown
3deea3980d Add checks for unitialized properties
Fixes #1328
2019-02-13 13:32:19 -05:00
Matthew Brown
c58100e3af Fix #1313 - don’t allow mixed function calls 2019-02-10 16:15:52 -05:00
Matthew Brown
62fb8035bf Fix #1309 - no PropertyNotSetInConstructor warnings for grandchild of class 2019-02-10 15:01:10 -05:00
Matthew Brown
c765d0e969 Fix #1307 - improve generator array type 2019-02-09 15:48:15 -05:00
Matthew Brown
83e22a10f8 Fix #1299 - vars defined in catches before throw are possibly-defined for finally 2019-02-09 15:39:30 -05:00
Matthew Brown
e6f3948f7b Fix #1297 - prevent false positive TypeDoesNotContainType for class const array offset 2019-02-07 16:24:31 -05:00
Matthew Brown
ed4ed957c8 Use more specific templated argument 2019-02-07 15:21:34 -05:00
Matthew Brown
c758678022 Fix remaining issues 2019-02-06 16:08:41 -05:00
Matthew Brown
dfe45e7d26 Fix #1290 - improve handling of more specific template 2019-02-06 15:56:40 -05:00
Matthew Brown
c83afc1af2 Fix element type inference for DOMNodeList 2019-02-05 13:34:59 -05:00
Matthew Brown
6033345694 Fix #1281 - improve handling of mixed property array assignment 2019-02-05 00:36:57 -05:00
Brown
bbf013bfb8 Fix #1279 - speed up analysis of large arrays 2019-02-04 16:06:14 -05:00
Matthew Brown
ab22634d23 Fix #1274 - fix parent:: call to templated method 2019-02-04 00:52:31 -05:00
Matthew Brown
f06ed8bf84 Fix #1273 - don’t change type with unpacked var 2019-02-03 16:36:10 -05:00
Matthew Brown
e97d4f85ee Break large CallAnalyzer funtions apart 2019-02-03 16:21:37 -05:00
Matthew Brown
194bb31221 Fix #204 - allow missing param types to be added with Psalter 2019-02-02 14:16:49 -05:00
Matthew Brown
3a01afbe0a Refine inferred type when possible 2019-02-02 12:10:52 -05:00
Matthew Brown
db89b3cc3f Add initial support for fixing MissingParamType 2019-02-02 11:28:48 -05:00
Matthew Brown
509709d6bc Fix #1267 - flesh out self static property types 2019-02-01 08:59:01 -05:00