1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
Commit Graph

638 Commits

Author SHA1 Message Date
Matthew Brown
4312ef380b Fix issues found by improved Psalm checks
cc @TysonAndre, found with RedundantCondition checks
2017-11-24 12:10:30 -05:00
Matthew Brown
fd3de443b2 Update loop with union of existing types 2017-11-21 22:13:46 -05:00
Matthew Brown
e3b688b06d Fix #316 - self resolves to proper class 2017-11-21 21:50:39 -05:00
Matthew Brown
b1a35d6a6e Remove numeric types with !is_numeric check, fix #330 2017-11-21 20:58:08 -05:00
Matthew Brown
f5f7849d3a Fix erroneous merging of types 2017-11-20 20:06:00 -05:00
Matt Brown
a069cf4ea9 Don‘t turn a string into an array|string by accident 2017-11-20 17:10:05 -05:00
Matt Brown
0c2ea418e3 Fix #327 - prevent null array value from killing assignment 2017-11-20 16:19:40 -05:00
Matt Brown
f46fd0b79f Fix array access on objects 2017-11-20 11:49:26 -05:00
Matthew Brown
9d025fad8f Only replace ? where appropriate 2017-11-20 00:32:40 -05:00
Matthew Brown
957600623c Fix issue with byref template params leaking 2017-11-20 00:12:17 -05:00
Matthew Brown
ccc0583bf8 Fix issue with bad assign after array_pop/array_shift 2017-11-19 23:46:32 -05:00
Tyson Andre
cea5dca5dc Allow using nullable shorthand (?) within an array (#326) 2017-11-19 23:36:37 -05:00
Matthew Brown
ae799da8d0 Add root array var when updating array key type in if 2017-11-19 23:25:14 -05:00
Matthew Brown
381eb2157a Avoid undefined notice in var comparison 2017-11-19 23:19:49 -05:00
Matthew Brown
5698b2d363 Update root var with more accurate object-like type 2017-11-19 22:28:52 -05:00
Matthew Brown
90bcd99eab Fix issue where array_shift/array_pop didn’t mark array as modified 2017-11-19 21:36:09 -05:00
Matthew Brown
8b2df09f0f Fix issue with object-like reassignment 2017-11-19 21:24:29 -05:00
Matthew Brown
3418eb494a Always set a fallback mixed type on a mixed property fetch 2017-11-19 14:58:48 -05:00
Matthew Brown
942bc0a663 Add new MixedTypeCoercion issue, fixes #320 2017-11-19 13:42:48 -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
5ff4badf33
Refactor array analysis to improve reliability and accuracy (#325) 2017-11-19 12:33:43 -05:00
Matthew Brown
1a39224abc Fix issues that improved array checks found 2017-11-19 12:14:02 -05:00
Matt Brown
39baa00fd3 Fix issue with nested object-like array updating 2017-11-17 16:33:36 -05:00
Tyson Andre
1c25ca1a0c Fix false positives, add tests of @psalm-seal-properties (#318) 2017-11-17 16:19:48 -05:00
Matt Brown
2a96e323e7 Fix assignment to arrays after object-like 2017-11-17 12:27:16 -05:00
Matthew Brown
965352c711 Fix #312 - support parsing object-like arrays without keys 2017-11-17 01:18:13 -05:00
Matthew Brown
a08306973a Fix #302 - add a way to seal objects with magic properties 2017-11-16 20:47:58 -05:00
Matthew Brown
440db3be89 Fix #313 - correctly analyse closure self return types 2017-11-16 20:06:00 -05:00
Matthew Brown
7d33db0d19 Fix issue with array unification after scanning 2017-11-16 01:11:46 -05:00
Matthew Brown
36a760657d Fix #311 and introduce PossiblyInvalidArrayOffset 2017-11-16 00:27:11 -05:00
Matthew Brown
6c9cdd896b Separate InvalidArrayAccess and InvalidArrayOffset 2017-11-15 21:10:07 -05:00
Matthew Brown
f136fc3296 Fix #305 by making test error message checks more accurate 2017-11-15 21:04:25 -05:00
Matthew Brown
abe7c003ab Fix #309 - borrowing fix from @TysonAndre 2017-11-15 20:45:53 -05:00
Matt Brown
a99135c4d0 Fix #300 - add PossiblyInvalidPropertyFetch 2017-11-15 11:44:13 -05:00
Matt Brown
c5faa2d06a Fix #299 - add PossiblyInvalidMethodCall 2017-11-15 11:34:40 -05:00
Matt Brown
9111b1c725 Fix #301 - add PossiblyInvalidPropertyAssignment 2017-11-15 11:15:03 -05:00
Matthew Brown
f96f3a467d Fix #296 - add issue for raw object iteration 2017-11-14 22:55:48 -05:00
Matthew Brown
2e6b93e4d0 Fix #289, make inferred type of yield from expressions mixed 2017-11-14 22:29:15 -05:00
Matthew Brown
23e4c8f68b Fix #290 - check for yields in assignments 2017-11-14 22:08:15 -05:00
Matthew Brown
3ade4b9559 Fix #293, be case invariant to self & static 2017-11-14 21:56:29 -05:00
Matthew Brown
b2ae9a2892 Fix #291, #292 and #297 by improving docblock parsing 2017-11-14 21:43:31 -05:00
Matt Brown
7e8ae33d56 Fix #288 - get rid of MethodSignatureMismatch issues where PHP doesn’t worry 2017-11-13 16:31:33 -05:00
Matthew Brown
a0a9128375 Fix #285 - add PossiblyInvalidArrayAccess 2017-11-11 21:22:11 -05:00
Matthew Brown
4f2a200b45 Fix #283 - add more refined PossiblyUndefinedMethod check 2017-11-11 14:53:35 -05:00
Matthew Brown
2f1e3652b7 Fix #274 - improve array addition inference for objectlike arrays 2017-11-11 14:19:57 -05:00
Matthew Brown
b79ad3c64b Fix #282 - detect legacy functions with variadic behaviour 2017-11-11 01:06:39 -05:00
Matt Brown
59265ef2bf Fix #276 - fix false positive in magic call 2017-11-10 18:08:26 -05:00
Matt Brown
e49573e7f6 Fix #279 - make sure referenced vars updated always in or 2017-11-09 16:42:39 -05:00
Matthew Brown
765d82548d Remove more dead code 2017-11-08 23:27:51 -05:00
Matthew Brown
a7b32beb4e Add better checks for array_rand’s signature 2017-11-08 21:56:54 -05:00
Matthew Brown
dd86513fc5 Fix #271 - remove invalid complaint about private overridden method 2017-11-08 21:27:23 -05:00
Matt Brown
6d14bf65d7 Loosen restrictions on compact(), fix #267 2017-11-08 09:37:58 -05:00
Matthew Brown
44c40dff4f Fix #270 by looking at root ids when analysing array assignment in loops 2017-11-08 08:23:34 -05:00
Matthew Brown
d422bc85d6 Add (skipped) test for #270 2017-11-07 23:49:04 -05:00
Matt Brown
750d18d20a Fix #266 - do better analysis of array_rand
And also have better fallback when accessing string key on object-like array
2017-11-07 17:38:54 -05:00
Tyson Andre
a50783404f Fix build failure - MixedPropertyAssignment should be expected in test.
This is assigning to a property of type mixed?
2017-11-07 17:24:44 -05:00
Matt Brown
97de8f7684 Allow Psalm to check static call LHS vars 2017-11-06 15:37:49 -05:00
Matt Brown
81493a639e Add more robust property assignment when property not defined 2017-11-03 12:27:01 -04:00
Matthew Brown
a651fad6f0 Fix #263 - add support for @psalm-param and @psalm-var annotations 2017-11-02 21:45:17 -04:00
Matthew Brown
b618bd798d Add new issues for missing required files 2017-10-29 14:39:23 -04:00
Matthew Brown
45df0292b1 Never constrain by-ref array variables 2017-10-28 15:33:29 -04:00
Matthew Brown
30acb9e3b7 Improve array function byref understanding by hard-coding rules 2017-10-28 13:56:29 -04:00
Matt Brown
6e86c9070c Skip breaking test 2017-10-26 18:20:35 -04:00
Matt Brown
8b7d82ddf6 Fix #2 - suppress errors for single lines 2017-10-26 18:19:19 -04:00
Matt Brown
897c70f8f5 Add back support for switch-getclass ::class constants 2017-10-26 15:07:36 -04:00
Matthew Brown
122b354c4c Ignore get_class and instanceof checks for arbitrary classes in traits 2017-10-24 00:01:43 -04:00
Matthew Brown
467bbba593 Prevent falsy values from leaking into the type system 2017-10-23 22:04:07 -04:00
Matt Brown
c850ef644d Add PossiblyFalseReference and PossiblyFalseArgument issues
Useful for catching error cases
2017-10-23 11:47:00 -04:00
Matthew Brown
a34de5b79c Fix #257 - prevent collapsing callable into string 2017-10-23 08:00:28 -04:00
Matthew Brown
e41e1fa57d Fix #256 - don’t crash when encountering types that match one another 2017-10-23 07:35:28 -04:00
Matthew Brown
2c18686c8c Fix #247 - allow is_callable checks on array 2017-10-22 21:07:06 -04:00
Matthew Brown
a85cd1db8a Add support for get_class and get_type negation checks 2017-10-22 20:17:04 -04:00
Matthew Brown
4d32c72ef8 Fix #250 and fix #255 - handle switch statements like PHP does 2017-10-22 19:53:53 -04:00
Matthew Brown
c7d55bf6de Improve aseertion finding by digging deeper into trivial comparisons 2017-10-22 19:11:28 -04:00
Matthew Brown
f9032924e6 Allow == true comparisons to be evaluated to !falsy 2017-10-22 12:09:22 -04:00
Matthew Brown
f6e01b5925 Change empty type assertions to "falsy"
As empty has a special meaning
2017-10-22 11:57:41 -04:00
Matt Brown
dbcec1be38 Fix #249 - get out of nested class 2017-10-19 14:40:38 -04:00
Matthew Brown
657d154288 CacheProvider -> ParserCacheProvider 2017-10-15 11:57:44 -04:00
Matthew Brown
d455e24958 Make shallow type comparison case insensitive ref #240 2017-10-12 19:46:00 -04:00
Matt Brown
024bcbc371 Fix #239 - warn about bad brackets 2017-10-12 14:02:06 -04:00
Matthew Brown
deb489e82d Fix #232 - discard clauses when evaluating catch block 2017-10-10 23:09:19 -04:00
Matthew Brown
862d22e83c Fix #230 - invalidate root vars on $arr[]= assignment 2017-10-10 23:01:52 -04:00
Matthew Brown
b43c2d5f0c Fix #231 - add special case for === false checks 2017-10-10 22:36:33 -04:00
Matthew Brown
9774131876 Fix #224 - explicit string casts fail when no __toString present 2017-10-07 11:27:54 -04:00
Matthew Brown
6b4bd47ddb Fix #181 and #225 - resolve problems with self in comments/return statements 2017-10-07 10:22:52 -04:00
MacFJA
1c0bfc7e7a Fix call 2017-10-02 07:38:22 -04:00
MacFJA
e6e7462362 Add a test that validate code change (before modification fail / after modification work) 2017-10-02 07:38:22 -04:00
MacFJA
a38c36c597 Always generate report files, even if no errors and warnings 2017-10-02 07:38:22 -04:00
Matthew Brown
5bd6228708 Fix #220 - don’t worry about parent property access 2017-09-24 08:17:27 -04:00
Matthew Brown
3a8efec728 Add error for pass by reference 2017-09-16 13:16:21 -04:00
Matthew Brown
9a3cb742cb Refactor docblock manipulation and add tests for it 2017-09-16 12:45:20 -04:00
Matthew Brown
313e1c383c Fix edge-case issue with abstract class not fully implementing interface 2017-09-13 23:57:11 -04:00
Matt Brown
5b3531b5a5 Fix null coalescing on nullable output 2017-09-13 14:35:42 -04:00
Matt Brown
eee8442af6 Fix #199 - allow classes to suppress PropertyNotSetInConstructor warnings 2017-09-13 11:32:13 -04:00
Matt Brown
d1807cfb95 Improve checks for switch types 2017-09-11 11:58:11 -04:00
MacFJA
c4ce8bede9 Add XML as possible output format + add report generation (#206)
* Add XML as possible output format + add report generation

* Add missing xml root node

* Change XML generator (previous one don't escape '<' and '>')

* Change option (only one option) + unit test
2017-09-08 11:18:48 -04:00
Matthew Brown
e89a2929d5 Infer types from numeric operations 2017-09-06 21:44:26 -04:00
Matthew Brown
11aa3558b7 Make sure encapsulated strings can also coerce param types 2017-09-02 19:48:59 -04:00
Matthew Brown
a0c27cee4f Allow param types to be inferred from presence of concat ops 2017-09-02 19:23:00 -04:00
Matthew Brown
73694ab04e Suggest types when complaining of untype params
Ref #204
2017-09-02 18:15:52 -04:00
Matthew Brown
8aabcbce35 Introduce UntypedParam warnings when functions are missing param types 2017-09-02 11:18:56 -04:00
Matthew Brown
e4e6c2a6e6 Fix #201 - list/array assignment should invalidate clauses too 2017-08-18 23:14:38 -04:00
Matthew Brown
fbc6379275 Fix #202 - vars changed inside loops should invalidate clauses 2017-08-18 22:41:25 -04:00
Matt Brown
7f9529e8a3 Remove stray comma 2017-08-18 17:23:12 -04:00
Matt Brown
d65a777641 Fix test function declaration 2017-08-18 17:06:01 -04:00
Matt Brown
c626b7d68a Fix #200 - allow mapping of more callable strings, and callable arrays 2017-08-14 19:30:11 -04:00
Matt Brown
0b0e7aa662 Fix #197 - allow nested class and function definitions 2017-08-14 15:46:01 -04:00
Matt Brown
13d98b803d Check that callable string class exists first 2017-08-11 18:48:58 -04:00
Matt Brown
17a900ab54 Add ability to detect invalid callable functions 2017-08-11 18:30:58 -04:00
Matt Brown
4b5a5ead74 Fix paradox detection for multiple clauses 2017-08-07 18:38:38 -04:00
Matt Brown
69f494ccdc Add test for #169 2017-07-31 15:10:42 -04:00
Matthew Brown
4175295113 Isolate where we load static storage objects (#195)
* Move FileChecker::$storage calls to provider

* Add ClassLikeStorageProvider

* Use ClassLikeStorageProvider everywhere

* Move storage arrays into providers
2017-07-29 15:05:06 -04:00
Matthew Brown
c5952af6f0 Fix bug with trait implementing abstract method 2017-07-28 23:38:57 -04:00
Matt Brown
22b6dafe3c Fix #194 - carry over const definitions 2017-07-28 10:42:30 -04:00
Matthew Brown
22daecb8ad Fix phpcs error 2017-07-26 21:30:01 -04:00
Matt Brown
0e67565b2c Return null if path exists 2017-07-26 19:36:41 -04:00
Matthew Brown
df767e80a4 Move onto newline 2017-07-25 19:48:45 -04:00
Matt Brown
76ba419330 Group unused tests together 2017-07-25 17:04:58 -04:00
Matthew Brown
e29dd140e3 Refactor scanning and analysis, introducing multithreading (#191)
* Add failing test

* Add visitor to soup up classlike references

* Move a whole bunch of code into the visitor

* Move some methods back, move onto analysis stage

* Use the getAliases method everywhere

* Fix refs

* Fix more refs

* Fix some tests

* Fix more tests

* Fix include tests

* Shift config class finding to project checker and fix bugs

* Fix a few more tests

* transition test to new syntax

* Remove var_dump

* Delete a bunch of code and fix mutation test

* Remove unnecessary visitation

* Transition to better mocked out file provider, breaking some cached statement loading

* Use different scheme for naming anonymous classes

* Fix anonymous class issues

* Refactor file/statement loading

* Add specific property types

* Fix mapped property assignment

* Improve how we deal with traits

* Fix trait checking

* Pass Psalm checks

* Add multi-process support

* Delay console output until the end

* Remove PHP 7 syntax

* Update file storage with classes

* Fix scanning individual files and add reflection return types

* Always turn XDebug off

* Add quicker method of getting method mutations

* Queue return types for crawling

* Interpret all strings as possible classes once we see a `get_class` call

* Check invalid return types again

* Fix template namespacing issues

* Default to class-insensitive file names for includes

* Don’t overwrite existing issues data

* Add var docblocks for scanning

* Add null check

* Fix loading of external classes in templates

* Only try to populate class when we haven’t yet seen it’s not a class

* Fix trait property accessibility

* Only ever improve docblock param type

* Make param replacement more robust

* Fix static const missing inferred type

* Fix a few more tests

* Register constant definitions

* Fix trait aliasing

* Skip constant type tests for now

* Fix linting issues

* Make sure caching is off for tests

* Remove unnecessary return

* Use emulative parser if on PHP 5.6

* Cache parser for faster first-time parse

* Fix constant resolution when scanning classes

* Remove test that’s beyond a practical scope

* Add back --diff support

* Add --help for --threads

* Remove unused vars
2017-07-25 16:11:02 -04:00
Matthew Brown
b4542316fa Take out unnecessary analysis step 2017-07-16 15:41:45 -04:00
Matt Brown
592194e9f2 Fix #187 by splitting abs into int and float versions 2017-07-14 18:09:25 -04:00
Matt Brown
d163b28cbf Add skipped interface test for #175 2017-07-10 10:35:00 -04:00
Matthew Brown
e60f085741 Fix #178 - complain when encountering bad @return type 2017-07-09 20:32:35 -04:00
Matthew Brown
581cf5f7eb Don’t allow trait to override non-abstract method definition for parent class 2017-07-09 15:54:43 -04:00
Matthew Brown
32ff386b4a Fix #184 - prevent classes without reflected classes from breaking everything 2017-07-09 14:36:06 -04:00
Matthew Brown
67338c4bf5 Also detect non-inherited private constructors 2017-07-08 22:01:26 -04:00
Matthew Brown
c7b0f6685f Make Psalm a bit faster 2017-07-08 21:19:16 -04:00
Matthew Brown
91bdd65588 Fix #179 - check for abstract method instantiations 2017-06-30 10:24:47 -04:00
Matthew Brown
d8654b8389 Slow down Psalm by checking parent initialisations too 2017-06-30 01:24:45 -04:00
Matt Brown
3dceebc42f Make type combination less dependant on __toString 2017-06-29 17:40:25 -04:00
Matt Brown
fef589fb68 Fix issue with array access on property 2017-06-29 17:39:46 -04:00
Matt Brown
055e9768bd Fix typehints of testing trait 2017-06-29 10:25:41 -04:00
Matt Brown
ac70ea31b2 Change test assertion keying 2017-06-29 10:22:49 -04:00
Matthew Brown
8fd671bdc4 Fix #167 - prevent Empty type in assignment 2017-06-28 23:37:02 -04:00
Matthew Brown
bc35f88859 Fix issue with $this instanceof checks in traits 2017-06-23 00:39:37 -04:00
Matthew Brown
878696b72c Fix #173 - don’t emit MissingConstructor issues from trait constructor 2017-06-21 01:25:41 -04:00
Matt Brown
e5c25eae97 Fix #172 - make sure new coalesce vars escape brackets 2017-06-20 15:38:32 -04:00
Matt Brown
f0141cab4e Reproduce null coalesce issue 2017-06-20 14:38:58 -04:00
Matt Brown
10b511284a Improve null coalesce test and improve linting 2017-06-20 14:38:13 -04:00
Matt Brown
473040ca8f Fix #171 by supporting exit statements for fopen 2017-06-20 13:25:37 -04:00
Matt Brown
f4338c38e7 Fix #148 - suppress InvalidDocblock where appropriate 2017-06-13 14:00:41 -04:00
Matthew Brown
152d1512f1 Fix issue capturing method mutations in traits 2017-06-12 22:51:39 -04:00
Matthew Brown
72e1221a2f Fix #168 and add test case 2017-06-11 19:20:07 -04:00
Matt Brown
1745518c2c Fix #166 - prevent require loop 2017-06-06 10:11:34 -04:00
Matthew Brown
1fee30d065 Add trailing commas 2017-06-05 22:12:19 -04:00
Matthew Brown
81223c45e0 Fix #166 - return instead of looping infinitely 2017-06-05 21:46:04 +01:00
Matthew Brown
b79b9e9b8c Add breaking test 2017-06-05 15:21:03 +01:00
Matthew Brown
e99150b403 Refactor include tests to allow checking multiple files per test cc @ernunion 2017-06-01 23:16:45 -04:00
Matthew Brown
22a716f4da Improve formatting of phpdocs 2017-05-26 20:16:18 -04:00
Matthew Brown
d6909193ea Add additional formatting changes 2017-05-26 20:05:57 -04:00