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

300 Commits

Author SHA1 Message Date
Brown
5770a6c904 Add support for compact 2019-07-24 17:24:23 -04:00
Brown
59dd6393f5 Fix #1953 - support third arg for explode 2019-07-17 14:13:34 -04:00
Matthew Brown
da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00
Matthew Brown
aa3df3f7a5 Add better support for preg_replace_callback 2019-07-05 10:40:05 -04:00
Matthew Brown
220fa31404 Fix suppression 2019-06-30 11:14:05 -04:00
Brown
5943f6036e Fix #1859 - allow function_exists introspection when function exists 2019-06-28 10:48:30 -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
Brown
84e002e9a7 Fix #1816 - convert array_filter strings to full closures 2019-06-19 17:42:42 -04:00
Matthew Brown
7155ed4e06 Fix #1811 - improve expected argument count 2019-06-19 09:05:07 -04:00
Matthew Brown
a553adb232 Fix test array spacing 2019-06-16 09:42:34 -04:00
Matthew Brown
2d5f332ebf Fix #1781 by improving handling of callmap options 2019-06-15 16:10:48 -04:00
Brown
c81a9a8737 Fix #1742 - allow is_countable assertion to mean something 2019-06-07 15:49:10 -04:00
Brown
29eda50ed9 Fix #1716 - no notice when using single arg in min 2019-06-03 10:33:54 -04:00
Matthew Brown
4002504ff0 Allow trait_exists to inform type for ReflectionClass 2019-05-31 09:43:46 -04:00
Matthew Brown
e31cdf3be5 Fix #1701 - allow count to be called on SimpleXMLElement 2019-05-29 07:56:06 -04:00
Brown
a89892a41f Prevent more broad template types being captured 2019-05-28 11:54:07 -04:00
Brown
29c869ed67 Ignore nullable issues on just-coerced types 2019-05-21 12:59:06 -04:00
Brown
4ecf370900 Coerce mixed values when passed as arguments 2019-05-21 11:51:41 -04:00
Lars Moelleken
0b5680f72f fix return type of "array_combine()" && "array_replace()" 2019-05-12 19:37:46 -04:00
Brown
d7ee952084 Infer closure param type for array_filter/array_map
Fixes #664
2019-05-07 16:27:25 -04:00
Brown
0e4c8ce482 Split apart TypeCoercion issues, allowing more granular issue filtering 2019-04-25 18:02:19 -04:00
Brown
97f53a6486 @voku’s fixes for issues found by their callmap update 2019-04-11 11:02:46 -04:00
Brown
1a33b25264 Fix #1536 - prevent fatal error when filtering null array 2019-04-09 17:22:30 -04:00
Brown
5173c18cce Fix calls after updating callmap 2019-04-09 16:52:32 -04:00
Brown
3dc3d659f1 Fix #1534 - allow unpacked args to be interpreted properly by overloaded functions 2019-04-09 14:48:51 -04:00
Brown
41c722448a Fix #1531 - improve hrtime return type 2019-04-03 17:08:37 -04:00
Brown
f82a55d836 Fix #1512 - check args to mktime are all ints 2019-03-29 10:46:48 -04:00
Matthew Brown
c772914910 Add some formatting 2019-03-23 14:27:54 -04:00
Matthew Brown
f0ddc6f3bc Fix array_reverse implementation 2019-03-17 18:14:30 -04:00
Brown
441d3c4693 Fix #1470 - array_reverse should preserve count 2019-03-15 16:39:31 -04:00
Matthew Brown
82e6876011 Fix #1397 - fix get_class behaviour for new instances 2019-03-02 18:02:11 -05:00
Bruce Weirdan
9bdc9f774f More provider typing 2019-03-02 08:43:19 -05:00
Brown
601f303de2 Fix position of invalid param 2019-02-27 16:00:44 -05:00
Matthew Brown
3d4710c9d3 Add better checks for invalid array_map/array_filter args 2019-02-22 00:50:41 -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
079ac44263 Prevent pass by ref when type type is given 2019-02-20 17:43:12 -05:00
Matthew Brown
75104f4712 Fix #1359 - error on bad iterable args 2019-02-18 16:35:23 -05:00
Matthew Brown
c58100e3af Fix #1313 - don’t allow mixed function calls 2019-02-10 16:15:52 -05:00
Matthew Brown
c383e61805 Fix #1296 - array_filter should allow scalar values 2019-02-07 13:05:17 -05:00
Matthew Brown
17541b415f Fix #1191 - allow Psalm to check against different versions of PHP 2019-02-07 12:25:57 -05:00
Matthew Brown
f8f5ddfb04 Add support for string range 2019-02-07 10:50:42 -05:00
Brown
9edbae2bdc Fix possible fatal when builtin function is called in array_filter 2019-01-28 17:54:50 -05:00
Brown
f33415827e Add checks for rounded values 2019-01-28 11:57:49 -05:00
Matthew Brown
cd4d2027d0 Fix #1249 - allow iterator_to_array to respect getIterator method 2019-01-27 14:50:05 -05:00
Brown
184ee76176 Remove erroneous regular namespace check
Fixes #1235
2019-01-24 10:41:06 -05:00
Matthew Brown
99569e8ee3 Fix #1173 - transform const X = true to a true type 2019-01-21 16:55:50 -05:00
Matthew Brown
1c17d2e2f2 Extract template params from string/array callables cc @weirdan
The culmination of what you were getting at
2019-01-19 20:18:45 -05:00
Matthew Brown
ed68cb973d Fix #1109 - add bad usort protection 2019-01-19 18:11:49 -05:00
Brown
8d61cb4816 Fix #1200 - no fatal error in array_map when not checking functions 2019-01-15 17:53:23 -05:00
Matthew Brown
214fd7d461 Add DuplicateFunction issue
Fixes #49
2019-01-06 16:40:44 -05:00
Matthew Brown
43b4c1c0a3 Fix #1168 - better return type for range 2019-01-06 13:02:46 -05:00
Matthew Brown
c7723df8ff Allow gettype vars to be compared to strings 2019-01-05 16:23:18 -05:00
Matthew Brown
f5378bdca8 Improve function call resolution 2019-01-05 14:50:11 -05:00
Matthew Brown
9d8c2792e2 Add array-key type and improve general type handling
Fixes #1144
2019-01-05 00:15:53 -05:00
Matthew Brown
2dc3d9651f Separate iterable into its own type
Fixes #1151
2019-01-04 14:54:40 -05:00
Andrii
36f6930e0c 🐛 #1163 Fix handling for default option in filter_var 2019-01-02 13:27:53 -05:00
Matthew Brown
c4d024a72d Check variable static calls
Fixes #1142 and #1160
2019-01-02 09:00:45 -05:00
Matthew Brown
901596281c Fix #1143 - check some variable new calls 2019-01-02 06:58:49 -05:00
Brown
fb848d62e9 Add checks for if (count($a)) and if (count($a) [operator] [number]) 2018-12-19 16:15:19 -05:00
Matthew Brown
ea89a6ba29 Revert "First pass"
This reverts commit 9ed047234f.
2018-12-19 08:45:14 -05:00
Matthew Brown
20f7147af1 Revert "Maybe bad idea"
This reverts commit 03c817be08.
2018-12-19 08:44:56 -05:00
Matthew Brown
03c817be08 Maybe bad idea 2018-12-19 01:59:26 -05:00
Matthew Brown
9ed047234f First pass 2018-12-19 01:59:14 -05:00
Matthew Brown
f0969cb3bb Fix getId calls on callable return types
Ref #1119
2018-12-08 14:10:06 -05:00
Matthew Brown
6ef79a0432 Improve handling of byref vars passed into functions
Fixes #1066
2018-11-21 12:38:51 -05:00
Brown
dc834fdb01 Default allowStringToStandInForClass to true and fix errors found 2018-11-12 12:03:55 -05:00
Matthew Brown
4688b25fd9 Move internal classes to own namespace 2018-11-12 11:20:59 -05:00
Brown
b7099aaf3f Make sure array changes are noticed 2018-11-09 11:19:44 -05:00
Brown
496018f84a Fix #1024 - add support for filter_var 2018-10-23 14:38:36 -04:00
Brown
a2e7a65f3a Add better types for microtime 2018-10-10 16:03:00 -04:00
Brown
8e73b34469 Fix #1009 - improve handling of print_r 2018-10-10 10:58:47 -04:00
Matt Brown
6e5a9bf076 Fix #986 - use better return type for array_slice 2018-09-07 10:53:56 -04:00
Matt Brown
5d6fb4efdf Copy inferred type when suppressing errors 2018-09-04 13:57:05 -04:00
Matt Brown
e1bc9c65fc Add ksort to list of no-op by ref functions (vis-a-vis their argument shape 2018-09-04 13:14:44 -04:00
Matt Brown
f844f86a6c Improve type coercion checks in strict mode 2018-08-28 17:42:39 -04:00
Matt Brown
1037485a60 Convert InvalidScalarArgument to InvalidArgument when declare(strict_types=1) is set 2018-08-28 12:37:25 -04:00
Matt Brown
4ef2aafdd8 Fix #955 - always check third argument of array_splice 2018-08-24 16:12:07 -04:00
Matt Brown
366f625c83 Improve handling of coerced-to-array strings in array_splice 2018-08-14 11:51:17 -04:00
Matthew Brown
abc19d7136 Fix #915 - never care about falsable/nullable issues when matching functions from callmap 2018-08-08 23:28:30 -04:00
Matthew Brown
695ececc22 Add tests for 7c10a09 2018-08-08 22:44:02 -04:00
Matthew Brown
c9a2ca9321 Allow output of get_parent_class to be used in new without check 2018-08-02 13:43:13 -05:00
Matthew Brown
d3fc9a51e0 Improve callmap with PHPStan’s additions
cc @TysonAndre
2018-07-22 19:15:40 -04:00
Matthew Brown
1589b2a01e Fix #269 - allow trigger_error to count as exit statement 2018-07-13 18:36:25 -04:00
SignpostMarv
3eb027d371 875 addendum (#876)
* testing port

* testing return values with port

* removing redundant assertions

* forgot to return ¬_¬

* Fix build
2018-07-10 00:08:53 -04:00
Matt Brown
166706a35d Fix #875 - improve return types for parse_url 2018-07-09 14:37:14 -04:00
Matthew Brown
cd4bb75d80 Fix #871 - handle gettimeofday args 2018-07-07 20:35:24 -04:00
Matt Brown
7e09f59825 Fix #868 - improve return type of version_compare 2018-07-06 13:09:05 -04:00
Matt Brown
376c3c54c0 Add better checks for array_reduce
Fixes #846
2018-06-28 16:01:53 -04:00
Matt Brown
740279352e Fix #830 - unpack template param args appropriately 2018-06-20 10:40:50 -04:00
Matthew Brown
4688cf7a92 Fix #831 - ignore falsable issues when getting callmap function params 2018-06-20 09:09:03 -04:00
Matt Brown
3afd6053fd Fix #819 - only add is_a assertion if static::class known 2018-06-15 10:51:30 -04:00
Bruce Weirdan
6ecea35837 array_column return type inference (#787)
* Exception message typo fixed

* array_column return type inference

It takes a safe approach and only tries to be smart when array row type
is definite single shape

* cs fix
2018-05-31 21:14:06 -04:00
Matthew Brown
a3e2b98f7c Fix #743 - put InvalidArgument messages before PossiblyFalseArgument 2018-05-20 13:14:31 -04:00
Matt Brown
f2a70fef85 Fix #745 - give iterator_to_array back its type info 2018-05-18 18:10:10 -04:00
Matthew Brown
b0733254bb
Use individual type objects for each string (#757)
* Experiment with individual types for each string

* Fix bunch of errors

* Fix a few more issues

* Fix a whole bunch of bugs

* Fix most remaining bugs

* Fix isset warnings

* Fix psalm errors in psalm

* Limit big string size

* Fix falsiness of ints

* Fix issue with type widening, allowing value set in nested if to be altered

* Don’t complain if type is mixed

* Add skipped-for-now test

* Add specific test to address issue
2018-05-18 11:02:50 -04:00
Matthew Brown
c00fdd0fe3 Add better type inference for next and prev
Fixes #738
2018-05-13 19:20:05 -04:00
Matthew Brown
b36b50784d Fix #703 - prevent undefined param offset 2018-04-30 22:18:41 -04:00
Matt Brown
6e67030925 Fix #702 - prevent bad array to iterable cast 2018-04-30 13:17:09 -04:00
Matt Brown
1f3837d972 Fix #686 - allow undefined class inside class_exists call 2018-04-19 12:16:00 -04:00
Matt Brown
3cc549384f Type explode more accurately 2018-04-16 16:03:04 -04:00
Radosław Kowalewski
15c1a82d8c Few fixes to make tests pass on windows
* changed / to DIRECTORY_SEPARATOR in expected messages
* cahnged most occurences PHP_EOL to "\n" in tests and src
* added output buffering in test to avoid marking test as risky
2018-04-12 22:41:13 -04:00
Matt Brown
fe46e4e63d Make tests a bit more specific 2018-04-10 15:47:04 -04:00
Matt Brown
6eabdf326d Fix display of closure objects 2018-04-09 16:45:54 -04:00
Matthew Brown
0b95f1017e Fix issues with callmap callable types 2018-04-08 12:57:56 -04:00
Matthew Brown
3fe9a0606e Fix #654 - warn about MixedArgument when inferredType property does not exist
And handle str_replace more leniently when args unknown
2018-04-07 15:16:46 -04:00
Matt Brown
4927dfd337 Fix issue with InvalidArrayOffset from falsable 2018-04-05 13:57:01 -04:00
Matthew Brown
78d5adb17d Make key work with typed arrays 2018-04-05 00:21:14 -04:00
Matthew Brown
4ff7db09f9 Fix var_export return type
Fixes #636
2018-04-02 22:19:58 -04:00
Matthew Brown
c8c216edb2 Fix #610 - add slightly hacky check for multiple callmap options 2018-03-30 18:51:59 -04:00
Matthew Brown
3ef7073862 Add callmap updates from Phan 2018-03-27 01:05:37 -04:00
Matthew Brown
58115599a1 Add support for callable(...) syntax
Ref #580
2018-03-26 22:13:10 -04:00
Matthew Brown
0defe84e01 Allow use of $argv and $argc in function use statements 2018-03-18 17:11:14 -04:00
Matt Brown
d6e0708e88 Fix #577 - allow int in second param of strpos 2018-03-15 17:32:03 -04:00
Matt Brown
822d0a116e Reflect all numeric types passed to abs
Fixes #576
2018-03-14 18:05:36 -04:00
Matt Brown
56bdb924f5 Fix #563 - improve error message and ignore falsable issues for strtotime 2018-03-08 14:04:00 -05:00
Matt Brown
d8825701f5 Fix #556 - closure params with defaults can still accept extra 2018-03-05 10:29:19 -05:00
Matthew Brown
67cad2063d Fix #555 - fix function name mapping class 2018-03-05 09:01:24 -05:00
Matthew Brown
ee6a9b98fb Allow arrays to be called (ugh) 2018-03-02 00:49:53 -05:00
Matthew Brown
54cbee1265 Add TooManyArguments for closure test 2018-03-02 00:12:41 -05:00
Matthew Brown
cc19f50c04 Prevent missing classes from confounding callable arg checks 2018-03-01 23:43:52 -05:00
Matthew Brown
6660aa8a00 Fix #548 - check array_map/array_filter args for param matches 2018-03-01 23:33:21 -05:00
Matt Brown
9d165bee7b Fix generic return type for array_map
Ref #541
2018-02-26 10:39:48 -05:00
Matthew Brown
a6b54a3607 Fix #513 - make sure numeric is treated like a number 2018-02-15 19:50:50 -05:00
Matthew Brown
e862e4ddb1 Make all plugin methods static
cc @TysonAndre
2018-02-11 20:56:34 -05:00
Matthew Brown
217233472c Fix #457 - fix objectlike property isset check 2018-02-10 23:30:40 -05:00
Matt Brown
7f4be858c2 Fix #498 - add better issue type for docblock contradiction 2018-02-07 15:20:47 -05:00
Matt Brown
1df4c3d196 Add DocblockTypeContradiction to find possible issues with docblock types
Fixes #491
2018-02-06 18:44:53 -05:00
Matthew Brown
861d907845 Add more information to TooMany/TooFewArguments issues
Fixes #481
2018-02-02 11:26:55 -05:00
Matthew Brown
3482ee3b39 Split UntypedParam into MissingParamType and MissingClosureParamType 2018-01-28 20:03:47 -05:00
Matt Brown
1a2d13ae32 Ignore falsable issues from core functions 2018-01-25 13:07:36 -05:00
Matt Brown
543872f186 Allow @psalm-ignore-falsable-return annotation
Downgrades issues around use of current(), reset(), end() etc.
2018-01-24 18:52:58 -05:00
Matt Brown
f46cf729bb Allow null checks against preg_replace and related 2018-01-24 17:07:03 -05:00
Matthew Brown
c0a22d5f55 Increase CallChecker code coverage 2018-01-22 00:17:16 -05:00
Matthew Brown
9b6b03ff9f Create Config before ProjectChecker, and remove test-specific code from FileChecker 2018-01-21 10:22:04 -05:00
Matt Brown
4b4e09277c Fix #450 - add checks for duplicate array keys
And fix the embarassing errors in tests
2018-01-18 17:16:50 -05:00
Matt Brown
a253ca68bc Allow array_filter to inspect closure bodies 2018-01-17 16:07:46 -05:00
Matthew Brown
573260b16d Don’t warn about null array access if we’re ignoring null issues 2018-01-12 18:04:11 -05:00
Matt Brown
2120d258a4 Fix formatting of return type adder 2018-01-11 15:50:58 -05:00
Matthew Brown
8e4f8fabe3 Fix getenv calls
Fixes #386
2018-01-08 00:09:22 -05:00
Stéphane Bour
9b2cfdc669 fix: add preserve_keys on array_reverse function 2018-01-03 21:57:11 -05:00
Matthew Brown
84260c5edc Prohibit array pass by ref 2017-12-22 15:21:23 +01:00
Matthew Brown
17edb2bbe6
Add better understanding of arrays with keyed integer offsets (#400)
* Add tests for keyed integer assignemnt

* First pass to get keyed integer assignment working

* Fix array assignment to object-like with different key type

* Improve treatment of objectlikes for callable and iterable comparisons

* Fix array assignment to strings and addition

* Convert expression to CNF

* Do better at merging property types

* Fix array_rand key type
2017-12-18 18:47:17 -05:00
Matthew Brown
31ce716647 Widen empty array checks 2017-12-10 16:17:27 -05:00
Matthew Brown
a8a1489a8f Fix closure naming convention so it doesn’t confuse method id checks 2017-12-05 01:47:49 -05:00
Matthew Brown
ccc0583bf8 Fix issue with bad assign after array_pop/array_shift 2017-11-19 23:46:32 -05:00
Matthew Brown
75b6e21801 Fix #315 - improve checking of object-like arrays in function params 2017-11-19 13:05:35 -05:00
Matthew Brown
a0a9128375 Fix #285 - add PossiblyInvalidArrayAccess 2017-11-11 21:22:11 -05:00
Matthew Brown
2f1e3652b7 Fix #274 - improve array addition inference for objectlike arrays 2017-11-11 14:19:57 -05:00