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

1087 Commits

Author SHA1 Message Date
Matthew Brown
cd5f727d2e Collect explicit references to classes/methods 2017-02-26 23:09:18 -05:00
Matthew Brown
8db6921f1c More graceful early exit if not checking variables 2017-02-24 21:27:52 -05:00
Matt Brown
182f715b62 Add dead code detection for possibly unused public methods 2017-02-23 19:52:23 -05:00
Matt Brown
0049e4deb4 Fix #105 and also the issues found in its wake 2017-02-23 19:36:51 -05:00
Matthew Brown
fa3b292fd4 Fix #101 - restrict the values of pass-by-ref variables 2017-02-23 00:25:28 -05:00
Matt Brown
444a56f4f5 Nest file class registration in conditional 2017-02-22 17:26:20 -05:00
Matthew Brown
47de866601 Fix issue using abstract methods from traits 2017-02-22 01:25:51 -05:00
Matthew Brown
12cb72ae4b Prevent recursion when checking for initialisations 2017-02-22 00:51:34 -05:00
Matthew Brown
48335b6fee Fix potential invalid arg 2017-02-22 00:42:50 -05:00
Matthew Brown
b2957ef4e4 Remove redundant property 2017-02-22 00:06:31 -05:00
Matt Brown
c85b6b376b Merge do vars in scope 2017-02-21 17:48:12 -05:00
Matt Brown
a56456a719 Add merging of vars_possibly_in_scope back 2017-02-21 17:41:54 -05:00
Matt Brown
fa35c0efa9 Remove changed vars from clauses in while loop to prevent re-application of logic 2017-02-21 17:19:15 -05:00
Matt Brown
2c7ffb6f4c Add support for negating some while assertions 2017-02-21 16:52:27 -05:00
Matt Brown
c6a625c16e Fix #102 - be more lenient about whether a type can be reconciled 2017-02-21 16:15:39 -05:00
Matthew Brown
59d1e63b5c Add possibly-false values to getFileName 2017-02-21 02:13:40 -05:00
Matthew Brown
45577f123c Don’t add Symony and Composer to predefined (Reflectable) classes 2017-02-21 02:07:43 -05:00
Matthew Brown
4348888b3e Prevent error when no params are given 2017-02-21 01:56:43 -05:00
Matthew Brown
30c5977825 Fix issue with do statement breaking 2017-02-18 17:49:34 -05:00
Matthew Brown
e61ea17db5 Move FileChecker functionality into separate, better-contained classes 2017-02-18 13:41:27 -05:00
Matthew Brown
9137727993 Fix #99 - treat null coalesce more respectfully 2017-02-17 20:50:47 -05:00
Matthew Brown
870a4486a8 Fix socket return types 2017-02-17 19:52:37 -05:00
Matthew Brown
7cd1b27ff1 Add more support for logical and/or 2017-02-16 21:00:45 -05:00
Matthew Brown
9579460c59 Fix #97 - is_callable shouldn’t prevent evaluation of calls to existing functions 2017-02-16 20:51:53 -05:00
Matthew Brown
2d58531631 Fix #98 - add support for logical and/or 2017-02-16 20:43:23 -05:00
Matthew Brown
32dd5d5512 Be better about dealing with byref args when not checking functions 2017-02-15 01:47:03 -05:00
Matthew Brown
8ae4bf6a18 Add initial support for server mode 2017-02-15 00:16:29 -05:00
Matt Brown
83a978ea80 Fix array_filter on string-keyed arrays 2017-02-13 19:16:25 -05:00
Matthew Brown
0277ca49ba Add config creation utility 2017-02-12 23:59:43 -05:00
Matthew Brown
500044dac1 Make sure $argv and $argc are not globally available 2017-02-12 22:12:31 -05:00
Matthew Brown
1001e03f8a Prevent empty typeof types 2017-02-12 19:51:48 -05:00
Matthew Brown
4f43a7eccb Fix possible nullref 2017-02-12 19:31:35 -05:00
Matthew Brown
1d09616e9d Prevent template types from leaking when no generics are provided 2017-02-12 19:26:23 -05:00
Matthew Brown
a87ea78efc Fix variable-scoped byref issue 2017-02-12 19:07:25 -05:00
Matthew Brown
a4323359d3 Fix ternary/which/for conditionals 2017-02-12 18:47:02 -05:00
Matthew Brown
81e24de76f Fix invalid NullPropertyFetch warning 2017-02-12 18:06:18 -05:00
Matthew Brown
9061d36566 Don’t emit InvalidArrayAccess if ignoring null arrays 2017-02-12 17:13:03 -05:00
Matthew Brown
2635744f4e Simplify array inferred type 2017-02-12 16:58:04 -05:00
Matthew Brown
e0e92785f8 Complain about unevaluated code in more concrete fashion 2017-02-12 16:49:32 -05:00
Matthew Brown
b80628b1c4 Convert all templated properties to most acceptable type 2017-02-12 14:10:34 -05:00
Matthew Brown
e75436fdc7 Fix reporting level grab 2017-02-12 13:38:41 -05:00
Matthew Brown
d6c25c90b3 Alert user if !object assertion has issues 2017-02-12 13:27:42 -05:00
Matthew Brown
d2e92131f5 Always set global vars, even when it might be an error 2017-02-12 13:27:02 -05:00
Matthew Brown
3f0a87f6fe Add more specific __toString error issue 2017-02-12 13:26:24 -05:00
Matthew Brown
a31ef0ae5f Always save property assignments for analysis 2017-02-12 13:25:59 -05:00
Matthew Brown
2ecffbdd6f Always check methods with global scope 2017-02-12 13:16:40 -05:00
Matthew Brown
2f2b487236 Fix #96 2017-02-12 12:31:39 -05:00
Matthew Brown
59fa0977f9 Do not panic when encountering errant global var 2017-02-12 12:23:05 -05:00
Matthew Brown
8e7ab59e2b Add return types for core vars 2017-02-12 12:22:39 -05:00
Matthew Brown
b1f7cfb08e Make file return type more specific 2017-02-12 12:22:10 -05:00
Matthew Brown
2a3c4ee63a Fix msg_receive byref params 2017-02-12 11:34:38 -05:00
Matthew Brown
7876c7ffb9 Allow mixed to override null in byref assignment 2017-02-12 11:34:07 -05:00
Matthew Brown
1029e68341 Allow TNamedObject to be coerced to TObject 2017-02-12 00:50:37 -05:00
Matthew Brown
bb9221ba01 Analyze die/exit expressions 2017-02-11 19:42:12 -05:00
Matthew Brown
f32fabd798 Remove dead code 2017-02-11 19:30:06 -05:00
Matthew Brown
8ff6634e7b Add issue for possibly unused variables in public/private methods
also changed a lot of access
2017-02-11 18:56:38 -05:00
Matthew Brown
deb11c9402 Change some errors from InvalidReturnType to MoreSpecificReturnType 2017-02-11 18:25:44 -05:00
Matthew Brown
35e4b380cc Add collection of PossiblyNull* issues 2017-02-11 17:55:08 -05:00
Matthew Brown
708f6e39de Fix array_slice implenentation 2017-02-11 00:34:07 -05:00
Matthew Brown
c05d5926f9 Add missing args to array_slice implementation 2017-02-11 00:25:23 -05:00
Matthew Brown
dbddedb20b Don’t create objectlike if we some properties are untyped 2017-02-10 23:35:34 -05:00
Matthew Brown
14c487d3e6 Always supply default template params as return type 2017-02-10 22:51:47 -05:00
Matthew Brown
1d6c441d16 Use a more fault-tolerant version of php-parser 2017-02-10 21:27:12 -05:00
Matthew Brown
9b3b536254 Fix issue where self::$property_name doesn’t use Context self 2017-02-10 20:41:18 -05:00
Matt Brown
32d85e20da Remove unused vars 2017-02-10 19:10:13 -05:00
Matt Brown
2c1622e7de Find more unreferenced variables by ignoring mass context ops 2017-02-10 19:08:55 -05:00
Matt Brown
0d2581f961 Fix possibility of break when getting property in quick evaluation 2017-02-10 18:45:11 -05:00
Matt Brown
c0a6fc9125 Fix #90 - add genericised stubs for common array functions 2017-02-10 18:12:59 -05:00
Matthew Brown
8ffd45407c Add support for namespaced templates 2017-02-10 00:14:44 -05:00
Matthew Brown
4a82c0a09a Add support for nested types in templates 2017-02-09 22:57:23 -05:00
Matthew Brown
04d9854ce0 Don’t check function return types if it has template types 2017-02-09 22:54:06 -05:00
Matthew Brown
5e8a40a5a1 Merge pull request #94 from vimeo/template-tags
Add support for templating
2017-02-09 20:51:23 -05:00
Matthew Brown
98b0ed280c Add support for templating 2017-02-09 20:35:17 -05:00
Matthew Brown
41f7dc4a52 Fix #93 - fix MethodSignatureMismatch checks on builtin class methods 2017-02-09 17:49:13 -05:00
Matthew Brown
66d98a023f Allow false return value 2017-02-08 22:45:18 -05:00
Matthew Brown
585cf91ef0 If using assertions for type, count as a soft type check 2017-02-08 22:17:16 -05:00
Matthew Brown
6934b8ee45 Do not emit signature error for constructors 2017-02-08 21:19:47 -05:00
Matthew Brown
5cbd25fccc Allow generator to be used as a traversable 2017-02-08 20:58:50 -05:00
Matt Brown
8cd83a581a Also unset possibly-in-scope vars 2017-02-08 11:27:06 -05:00
Matthew Brown
09ca483e7d Do not ignore object vars in hasVariable 2017-02-08 02:33:29 -05:00
Matthew Brown
64cbe005f3 Remove more false positives 2017-02-08 02:23:41 -05:00
Matthew Brown
cedb70b0b4 Reduce false positives for unused variables 2017-02-08 01:59:49 -05:00
Matthew Brown
ce63c07e42 Fix snippets on very long lines 2017-02-08 01:39:49 -05:00
Matthew Brown
89a5f109e8 Fix method reference 2017-02-08 00:42:53 -05:00
Matthew Brown
cdcacc395d Rename DeadCode to UnusedVariable, UnusedMethod and UnusedClass 2017-02-08 00:28:26 -05:00
Matthew Brown
65ef5ba8b7 Improve native understanding of docblock-less variadics 2017-02-07 22:02:46 -05:00
Matt Brown
34980fc718 Remove dead code and fix config.xsd 2017-02-07 18:27:28 -05:00
Matt Brown
f4857eb0dd Make dead code check emit an issue 2017-02-07 18:18:33 -05:00
Matt Brown
6b2bb7d917 Store first code location for all variables in a statement list 2017-02-07 18:09:12 -05:00
Matthew Brown
01beb97413 Fix #87 - array types from docblocks can be reasoned about safely 2017-02-03 22:07:14 -05:00
Matthew Brown
11859e9cc0 Bump PhpParser version 2017-02-03 20:14:48 -05:00
Matt Brown
ba4f47a41c Config for caching file hashes during run 2017-02-02 12:39:39 -05:00
Matthew Brown
0fbf8b5619 Remove more dead code 2017-02-02 00:45:23 -05:00
Matthew Brown
ec65f31aaa Improve dead code analysis and fix errors found 2017-02-02 00:20:58 -05:00
Matthew Brown
5ec2a9742b Fix union type simplification of float|int eradicating int 2017-02-01 19:39:40 -05:00
Matthew Brown
1051ba9fc1 Wait to evaluate property defaults until analysis 2017-02-01 18:27:24 -05:00
Matthew Brown
76b6bc9b3d Prevent Psalm from storing unnecessary checkers 2017-02-01 18:11:00 -05:00
Matthew Brown
bf042772bd Get config constants after autoload script 2017-02-01 14:56:10 -05:00
Matthew Brown
e925e8b4db Fix #86 - remove empty array from type on !empty check 2017-02-01 13:51:26 -05:00
Matthew Brown
a0711de023 Update config key to be more accurate ref #85 2017-02-01 10:13:37 -05:00
Matthew Brown
d3abc0011d Fix #80 - add dead code checks via command line 2017-01-31 23:24:33 -05:00
Matthew Brown
eeccf791ad Add unused method & unused class analysis ref #80 2017-01-31 20:47:16 -05:00
Matt Brown
004fd42062 Fix #83 - add support for stubbing 2017-01-31 19:21:33 -05:00
Matthew Brown
ce93c4ef2d Assert smart things when offset is variable 2017-01-31 01:35:44 -05:00
Matthew Brown
7f8a3d798e Improve clause resolution in while loops 2017-01-31 01:30:11 -05:00
Matthew Brown
965a79251d Fix #82 by updating how isset calls are handled 2017-01-31 00:34:06 -05:00
Matthew Brown
7d912fc214 Remove vars when they’ve been changed 2017-01-30 22:26:41 -05:00
Matthew Brown
95ebf5178a Add array_slice call to methods whose return types we can infer 2017-01-30 22:26:31 -05:00
Matt Brown
8c68861cc3 Fix #81 - interface inheritance checks were broken 2017-01-30 18:38:23 -05:00
Matthew Brown
4114456bf4 Key off lowercase classname and reduce dead code false positives 2017-01-30 00:26:17 -05:00
Matthew Brown
cc500e8228 Eliminate dead code 2017-01-30 00:25:16 -05:00
Matthew Brown
1ece3071f9 Add reference counting for methods and remove dead code 2017-01-29 23:44:05 -05:00
Matthew Brown
e9ba513250 Add classlike reference counts 2017-01-29 22:30:27 -05:00
Matthew Brown
d978966db4 Fix #37 - check parent calls for staticness 2017-01-29 22:13:53 -05:00
Matthew Brown
a45c47776b Fix #79 - check anonymous class statements 2017-01-29 13:20:12 -05:00
Jon Ursenbach
c66082897d Fixing a typo in the ClassLikeChecker exception message. 2017-01-29 00:34:42 -05:00
Matthew Brown
fe803129cf Fix #77 with correct range param 2017-01-29 00:24:55 -05:00
Matthew Brown
aaec895e15 Do not stop dead when a property cannot be evaluated 2017-01-28 16:12:04 -05:00
Matthew Brown
a9203b63f8 Allow phan-like use of assert 2017-01-28 15:17:14 -05:00
Matthew Brown
199686c4db Add back local vars when descending into method call 2017-01-28 03:55:19 -07:00
Matthew Brown
1bf0882bfc Allow commas at the end of @param lines 2017-01-28 00:37:52 -07:00
Matthew Brown
2e4aa3d3b1 Do not suggest mixed types 2017-01-27 22:44:52 -07:00
Matthew Brown
f8a70dc707 Limit size of preview snippet 2017-01-27 22:39:16 -07:00
Matthew Brown
c868781731 Fix multiline docblock issue reporting issue 2017-01-27 22:24:25 -07:00
Matthew Brown
6714e28f5d Fix line numbers for return typehints 2017-01-27 19:09:40 -07:00
Matthew Brown
a35f2e0792 Don’t unset $this when calculating scope changes 2017-01-27 18:54:27 -07:00
Matthew Brown
4c3dacbbed Prevent erroneous __toString conversion in method check 2017-01-27 18:06:11 -07:00
Matthew Brown
ea06f62d72 Fix registration of private trait properties 2017-01-27 17:57:59 -07:00
Matthew Brown
3c3d22164c Add private properties to context 2017-01-27 08:49:37 -07:00
Matthew Brown
e51763328c Shortcut for generator, which does not extend anything 2017-01-27 08:41:32 -07:00
Matthew Brown
c485a3d056 Check for not-set-in-constructor errors across traits too 2017-01-27 08:28:21 -07:00
Matthew Brown
98d4ced24f Make location of not-set-in-constructor errors more precise 2017-01-26 23:40:22 -07:00
Matthew Brown
63801c38c0 Make location of constructor error more specific 2017-01-26 23:32:03 -07:00
Matthew Brown
6bcc763414 Fix #3 by checking inside __constructor calls for initialisations 2017-01-26 23:23:12 -07:00
Matthew Brown
ff46487353 Be more discerning about unaryminus/plus inferred type 2017-01-25 21:50:34 -07:00
Matthew Brown
c14a19370f Improve UnaryPlus/Minus still more 2017-01-25 20:23:06 -07:00
Matthew Brown
f03807e7b7 Fix unaryplus/minus type inference 2017-01-25 20:02:19 -07:00
Matthew Brown
4fa0055092 Remove unnecessary var_dump 2017-01-25 17:09:31 -07:00
Matthew Brown
7e7743d6fb Do not complain about missing void return types if config set 2017-01-25 17:07:28 -07:00
Matthew Brown
15e8c1b904 Fix simplifyUnionType so classes with __toString aren’t confused with string 2017-01-25 17:01:01 -07:00
Matthew Brown
ea63fd7ae3 Fix #75 - allow inteeger offsets for object-like arrays 2017-01-25 00:11:24 -07:00
Matthew Brown
0da9c10d36 Don’t complain when adding array and object-like array 2017-01-23 15:40:55 -07:00
Matthew Brown
58aee6340d Remove var_dump (shame on me) 2017-01-23 15:17:35 -07:00
Matthew Brown
df1d6abd7c Make brand-new return types more accurate 2017-01-23 15:16:13 -07:00
Matthew Brown
daa923e243 Stop analysis if parent class cannot be located 2017-01-23 13:36:06 -07:00
Matthew Brown
3ad6ec2e34 Be more resilient if we ignore that parent class does not exist 2017-01-23 13:21:40 -07:00
Matthew Brown
374dc65de1 Fix #39 by checking for ArrayAcces interface 2017-01-20 00:23:58 -05:00
Matthew Brown
894b25487f Fix #71 - prevent instantiation of abstract classes 2017-01-20 00:10:10 -05:00
Matthew Brown
9d1b382820 Fix #48 by recording class definition line number & file path 2017-01-19 23:45:21 -05:00
Matt Brown
d0207b6098 Check that class exists before checking for ArrayAccess inheritors 2017-01-19 19:02:00 -05:00
Matt Brown
86201e71b2 Make arguments of SplFileObject::fputcsv optional 2017-01-19 17:58:34 -05:00
Matt Brown
c1e62a09e7 Merge suppressed issues with source’s issues 2017-01-19 17:58:08 -05:00
Matt Brown
d3a9452cde Make sure we don’t lose type information while reconciling 2017-01-19 17:45:42 -05:00
Matt Brown
a67800cac7 Ignore cloning of mixed variables 2017-01-19 15:00:05 -05:00
Matt Brown
2a8e51f544 Fix scalar assignment 2017-01-19 14:49:49 -05:00
Matt Brown
77ff99206e Inherit all parent properties when analyzing method 2017-01-19 13:11:45 -05:00
Matt Brown
8a21191ebd Prevent improperly emiting InvalidToStringCast 2017-01-19 12:16:19 -05:00
Matt Brown
fd290c41d4 Fix tests 2017-01-19 12:15:42 -05:00
Matt Brown
7116585e85 Be more robust when ignoring UndefinedClass errors 2017-01-19 11:45:25 -05:00
Matt Brown
0ba02f304f Make project checker always aware of file paths to classes 2017-01-19 10:55:58 -05:00
Matthew Brown
a14b03c057 Fix issue with array_merge, and then bugs revealed by that 2017-01-19 01:32:35 -05:00
Matthew Brown
27a018095b Fix invalid InvalidParamDefault error when comparing to false 2017-01-19 01:12:19 -05:00
Matthew Brown
3510757d89 Prevent potentially confusing output calculating array_keys 2017-01-19 00:52:02 -05:00
Matthew Brown
8acaaa2194 Fix checking whether mock objects are contained by any other 2017-01-18 23:52:43 -05:00
Matthew Brown
3b18f58cae Add missing param 2017-01-18 23:38:21 -05:00
Matthew Brown
77c9d1ecbd If extending FileChecker, inline included stmts 2017-01-18 23:35:23 -05:00
Matthew Brown
87871e61f2 Allow checking of folders not in project directories 2017-01-18 23:34:56 -05:00
Matthew Brown
de1ce36a5c Fix method mutation transference 2017-01-18 23:19:36 -05:00
Matt Brown
a2750a92aa Evaluate loop part of for after body 2017-01-18 17:13:20 -05:00
Matt Brown
b23c55e570 Fix #70 by allowing string to be a numeric 2017-01-18 11:07:38 -05:00
Matt Brown
686891f30f Make directory recursion robust and windows-safe 2017-01-18 09:36:16 -05:00
Matthew Brown
d7096df7a6 Don’t complain about non-user-defined class casing 2017-01-18 00:33:48 -05:00
Matthew Brown
b438e4c305 Revert "Don’t complain about incorrectly cased builtin classes"
This reverts commit 20558c6039.
2017-01-18 00:23:17 -05:00
Matthew Brown
20558c6039 Don’t complain about incorrectly cased builtin classes
As they can never cause autoloader issues
2017-01-18 00:20:24 -05:00
Matthew Brown
e3b9f0fd83 Fix multiple duplicate namespaces constant confusion 2017-01-17 23:55:08 -05:00
Matthew Brown
e78e710eef Be more resilient in the face of class_exists checks 2017-01-17 23:34:17 -05:00
Matt Brown
875717bb96 Fix #63 by adding directory separators 2017-01-17 22:10:21 -05:00
Matt Brown
c0898aa6e5 Fix issue where inferred return type contained subclasses 2017-01-17 12:51:09 -05:00
Matt Brown
6b47741528 Remove extraneous check 2017-01-17 11:20:28 -05:00
Matt Brown
dae7718ae8 Support array_combine types and introduce a MoreSpecificReturnType issue 2017-01-17 11:17:49 -05:00
Matthew Brown
bc668e2c7a Change variadic docblock param to match language syntax 2017-01-17 01:14:43 -05:00
Matthew Brown
693811abed Allow non-array docblock typehints for variadic params 2017-01-17 00:26:40 -05:00
Matthew Brown
e4769fd04a Don’t give up when faced with variadic type 2017-01-17 00:07:58 -05:00
Matthew Brown
b9bad01dbd Treat reflected interface parents correctly 2017-01-16 20:47:23 -05:00
Matthew Brown
0c40785660 Allow traversable to be given directly as iterable 2017-01-16 20:06:34 -05:00
Matthew Brown
3cdb1753d5 Update to the more accurate TypeChecker::isContainedBy 2017-01-16 20:00:51 -05:00
Matthew Brown
317eab8730 Add support for ?A types in docblock 2017-01-16 19:17:46 -05:00
Matthew Brown
9220b958eb Fix phpcs errors 2017-01-16 19:06:39 -05:00
Matthew Brown
4073986844 Merge pull request #65 from Fleshgrinder/feature/auto-creation-of-cache-directory
Auto-create cache directory
2017-01-16 18:39:48 -05:00
Matthew Brown
b3726c9de5 Use getcwd() for the project’s base, not the config file parent directory 2017-01-16 18:33:04 -05:00
Matthew Brown
37bdd7d024 Fix #64 - if type is from docblock, return mixed in error case 2017-01-16 16:02:46 -05:00
Richard Fussenegger
42fee8d3a6 Auto-create cache directory
Signed-off-by: Richard Fussenegger <fleshgrinder@users.noreply.github.com>
2017-01-16 21:58:35 +01:00
Matthew Brown
69e185eb17 Use absolute cache directory paths everywhere ref #63 2017-01-16 15:32:03 -05:00
Matthew Brown
98454f8644 Remove anti-windows exception 2017-01-16 14:17:47 -05:00
Matthew Brown
e3a9cb98c3 Add extra issue for invalid clone and fix issue reporting; 2017-01-16 12:59:09 -05:00
Matthew Brown
4b283564ca Allow variadic params to be passed by reference 2017-01-16 12:39:38 -05:00
Matthew Brown
315e7029fe Fix non-full-dir Psalm checks 2017-01-16 11:51:42 -05:00
Matthew Brown
856870cf37 Fix #62 - die quickly and explicitly if files cannot be located 2017-01-16 11:41:57 -05:00
Matthew Brown
2e2f2f4ffb Add new suppressable error for missing closure return types 2017-01-16 01:22:36 -05:00
Matthew Brown
5315fd15ad Fix namespaced functions in regular use statements 2017-01-16 00:49:12 -05:00