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

246 Commits

Author SHA1 Message Date
Matt Brown
516141a380 Rename ControlFlowGraph to more appropriate DataFlowGraph 2020-10-13 16:49:03 -04:00
orklah
10f2966dcb
return types (#4311)
* return types

* remove willReturn for void methods
2020-10-12 15:02:52 -04:00
Matt Brown
939297484c 4.x - rename TFn to TClosure 2020-10-04 23:32:01 -04:00
Matt Brown
fc001cdf65 Treat func_get_args as using function params 2020-09-30 13:08:01 -04:00
Matt Brown
14efde286f 4.x - refactor unused variable detection
This turns unused variable detection into an explicit control-flow problem, where before we had a more simplistic mark-and-sweep algorithm
2020-09-30 12:28:13 -04:00
Brown
19f88a2e31 Add improvements from unused variable checks 2020-09-28 00:45:02 -04:00
Brown
da65a4327f Move taint graph functionality into its own object 2020-09-25 00:37:40 -04:00
Brown
56cddd16bf Rename TaintGraph to ControlFlowGraph because it’s about to do more 2020-09-20 23:59:52 -04:00
Brown
abb9502921 Rename Taint object to TaintGraph 2020-09-20 18:27:02 -04:00
orklah
a9a364e363
Misc improvements (#4216)
* misc changes

* fix CI
2020-09-20 08:55:28 -04:00
Brown
f973937aec Fix #4209 - allow hinting arrow function return type 2020-09-19 14:59:19 -04:00
orklah
191495328a
Fix errors in return types (#4189)
* FunctionLikeAnalyzer::verifyReturnType returns void

* ArrayFunctionArgumentsAnalyzer::checkArgumentsMatch returns void

* AssertionFinder::scrapeAssertions can't return null
2020-09-16 17:35:55 -04:00
orklah
da47588f91
replace return; by return null; in every non-void method, add return null; when mising, add return types, remove redundant phpdoc (#4176) 2020-09-13 16:39:06 -04:00
Brown
9ed09d2679 Fix #4127 - improve error message for unused closure var 2020-09-12 17:03:11 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
orklah
8c7423505a
add native param types (#4137)
* add native param types

* redundant phpdoc

* add more param types and adds "?" to nullable types

* remove redundant phpdoc

* add more param types and remove redundant phpdoc

* add more param types and remove redundant phpdoc
2020-09-06 19:36:47 -04:00
orklah
f66d57f19d
add native return types (#4116)
* add native return types

* remove redundant phpdoc
2020-09-04 16:26:33 -04:00
orklah
73f6fcde48
Short list syntax (#4102)
* Short list syntax

* revert unrelated CS
2020-09-02 00:17:41 -04:00
Brown
efe143a396 Fix #4077 - always track closure purity 2020-08-28 12:42:55 -04:00
Saif Eddin G
5a20092fbd
add pure-callable type (#4066) 2020-08-26 16:51:22 -04:00
Brown
4e10a0ed6f Fix #4036 - add immutable annotations automatically too 2020-08-24 19:29:00 -04:00
Brown
94cec15598 Only add pure when not overriding upstream 2020-08-23 22:16:03 -04:00
Brown
02a2e99d42 Only add pure to functions with params 2020-08-23 18:41:31 -04:00
Brown
10f7031080 Prevent use of $this in pure functions 2020-08-23 18:37:46 -04:00
Brown
4026b717b9 Allow function manipulators to work in threaded mode 2020-08-23 18:05:48 -04:00
Matthew Brown
8a975d7c20 Don’t add pure annotation when closure is impure 2020-08-23 14:07:19 -04:00
Matthew Brown
6efaf474d4 Don’t add @psalm-pure for void-returning functions 2020-08-23 13:58:34 -04:00
Matthew Brown
9418be79cc Restrict pure annotation addition a little more 2020-08-23 13:34:32 -04:00
Brown
67f9adb33c Allow adding pure annotations to functions
Ref #4036
2020-08-23 10:28:26 -04:00
Brown
dbcf154036 Add fixer for mismatching param names 2020-08-14 15:25:21 -04:00
Brown
c0b0036109 Fix #3934 - prevent unsafe use of new static 2020-08-05 19:39:27 -04:00
Brown
6919e88423 Add performance logging under a --debug-performance flag 2020-07-30 15:30:19 -04:00
Matthew Brown
ab714a40c4 Allow binding of static to current final class
Ref #3892
2020-07-25 17:26:07 -04:00
Brown
344a732829 Warn about simple assignments 2020-07-23 02:40:35 -04:00
Brown
3848fa6872 Fix #3870 - mark properties as reference-free only for externally-immutable classes 2020-07-23 01:48:06 -04:00
Brown
76bd5b6278 Refactor type comparison 2020-07-21 19:40:35 -04:00
Joe Hoyle
0b6d682964
Fix going to definition on return type (#3806)
* Fix going to definition on return type

If a return type of a method or function is set incorrectly (with the PHP doc), then the references are not added for the `function() : MyClass` symbol, so the "Go to definition" feature of the LSP won't work. I don't believe an invalid return type or not should stop the symbol location being tracked (and not allowing code navigation).

In moved the symbol location tracking to be before the return early short circuit.

* Update SymbolLookupTest.php

Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-11 17:14:39 -04:00
Joe Hoyle
11af82a97f
Fix jumping to definition on nullable parameters (#3804)
Currently it's not possible to "Go to definition" (LSP) on nullable args like `function( ?MyClass )` as the reference is stored a `MyClass|null` in the reference map, which will now resolve to a class name.

This PR removed any nullable type from the union before adding it to the reference map (as the reference map is only use to indicate a symbol was used in a given location, I think this makes sense).
2020-07-11 17:12:03 -04:00
Brown
95bf7f835b Improve handling of array_map, faking out calls where nececssary 2020-06-25 13:05:34 -04:00
Brown
9aa0aca949 Fix handling of coerced callmap args 2020-06-24 11:51:31 -04:00
Brown
c29b3744ec Change storage of out types 2020-06-24 11:51:31 -04:00
Brown
96d05ab06b Fix #3654 - use correct function id for namespaced functions 2020-06-23 16:53:11 -04:00
Brown
b1c836e5f3 Improve specialisation after call 2020-06-19 01:59:45 -04:00
Brown
8f2e28c36b Improve tainting of specializable classes 2020-06-19 01:22:51 -04:00
Matthew Brown
081a284759 Fix #3567 - remember which variables a callable sets byref in use 2020-06-14 11:58:50 -04:00
Matthew Brown
187b944680 Add faster taint analysis 2020-05-22 12:33:29 -04:00
Brown
a4141a7581 Fix #3327 - convert void to null when comparing conditional type with nullable 2020-05-19 19:48:11 -04:00
Brown
111303d913 Add non-empty-lowercase-string type 2020-05-15 10:18:05 -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
Brown
20bcfb096a Fix #3305 - use the same issue type for short closures as closures 2020-05-06 09:57:02 -04:00
Brown
21f4deed3b Fix #3268 - infer generator return for closure 2020-04-29 16:52:37 -04:00
orklah
8571746f8a
Add hook for plugins after FunctionLikeAnalysis (#3258) 2020-04-28 15:30:51 -04:00
Brown
8f57d0c738 Fix #3204 - normalise function ids where possible 2020-04-20 21:38:35 -04:00
Brown
35d376cbe7 Fix #3164 - allow nested templates in conditional classes 2020-04-17 00:46:27 -04:00
Brown
da729cfbc6 Don’t check params when mutations are being collected 2020-03-31 15:49:43 -04:00
Matthew Brown
194f02507d Allow conditional types to reference class constants 2020-03-29 13:37:37 -04:00
Matthew Brown
5395183837 Use more accurate means of determining whether function did return 2020-03-28 23:37:42 -04:00
Matthew Brown
93735712f0 Fix #3032 - always replay docblock issues when analysing files 2020-03-28 19:54:55 -04:00
Matthew Brown
47c1470e3b Refactor reference checks to use more appropriate properties 2020-03-28 16:30:56 -04:00
Brown
971ae50bea Do prep work for #3024 - improve handling of absent class references 2020-03-26 12:35:27 -04:00
Brown
1bfc61d402 Allow final classes to bypass static checks 2020-03-24 18:14:10 -04:00
Brown
ec34a16291 Warn about invalid static returns 2020-03-24 18:00:20 -04:00
Matthew Brown
0aca01faea Improve fix to #2805 2020-03-14 01:09:12 -04:00
Matthew Brown
96fbcd5a64 Break out more methods 2020-03-11 23:38:49 -04:00
Matthew Brown
bfb919d26a Break out methods into their own classes 2020-03-11 23:04:52 -04:00
Matthew Brown
3cc4c2b37e Fix #2721 - only warn about deprecated classes exactly where they are used 2020-02-22 01:12:19 -05:00
Brown
f4485cc529 Fix #2847 - use fully-qualified function name 2020-02-21 16:44:31 -05:00
Matthew Brown
653353709a Use MethodIdentifier object instead of string 2020-02-14 20:54:26 -05:00
Brown
210d65d0d6 Add a few lowercase-string types 2020-02-13 17:52:23 -05:00
Brown
f141f7c526 Improve --diff checks by including trait-using classes in dependents 2020-02-11 16:39:33 -05:00
Brown
d8f5ad190b Improve invalidation of inherited properties 2020-02-10 17:03:51 -05:00
Matthew Brown
da541dbb51 Remove some unnecessary errors 2020-02-06 23:10:18 -05:00
Brown
8fb810350a Don’t cache no-effects hashes when checking for initialisations 2020-02-04 17:53:26 -05:00
Brown
8f95c5679e Fix #2720 - allow throwing self 2020-01-30 18:00:31 -05:00
Brown
da43b8188f Fix #2632 - detect invalid by-ref assignments in pure functions 2020-01-23 14:21:34 -05:00
Brown
eb7c3dcc11 Fix #2611 - fix combination of inferred closure return types 2020-01-13 10:23:58 -05:00
Matthew Brown
9fa2db1b6c Move Union::getTypes to Union::getAtomicTypes 2020-01-04 12:20:26 -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
11433dc9d0 Fix references 2019-12-18 14:43:15 +00:00
Matthew Brown
cb797c6159 Fix inherited class methods as well
Ref #2478
2019-12-18 14:39:37 +00:00
Matthew Brown
f40b6625eb Fix #2431 - allow null in template defaults 2019-12-13 21:40:09 -05:00
Matthew Brown
97de060df9 Fix #2279 - add parameter typehint by default 2019-12-03 01:49:43 -05:00
Brown
821f3528d2 Fix #701 - indicate issues fixable with Psalter 2019-12-02 15:24:01 -05:00
Matthew Brown
d1fbd1fa26 Add working arrow-functions implementation 2019-11-26 23:52:26 -05:00
Brown
1f07ea7ee7 Tighten up Psalm’s inference 2019-11-25 15:20:31 -05:00
Brown
0bcb7863f3 Use better system for storing inferred types and assertions 2019-11-25 11:44:54 -05:00
Matthew Brown
2369bac943 Preserve self refs where possible 2019-11-16 19:59:08 -05:00
Brown
55bf6a2db3 Migrate static return types 2019-11-15 16:50:43 -05:00
Brown
4747ba709a Migrate more things 2019-11-15 15:34:25 -05:00
Brown
96586f16c0 Fix phpcs issues 2019-11-11 10:11:42 -05:00
Brown
895737d8be Fix style 2019-11-08 12:49:53 -05:00
Brown
ac6256e645 Fix #2312, improve understanding of template replacement 2019-11-08 11:56:41 -05:00
Brown
1f42843d42 Fix #2296 - use case insensitive closure ids 2019-11-04 14:48:02 -05:00
Matthew Brown
5910a362ea Improve report output of taint analysis 2019-10-19 17:59:10 -04:00
Brown
dda68228f3 Fix #2247 - don’t crash when yielding from class with too many template params 2019-10-18 11:01:16 -04:00
Matthew Brown
c419e0e798 Fix #2222 - check for @throws docblock inheritance 2019-10-10 22:44:21 -04:00
Brown
3658771bff Fix #2221 - variadic args are lists 2019-10-10 17:46:20 -04:00
Matthew Brown
a9d0296252 Fix #2182 - allow modification to cloned objects inside 2019-09-30 22:07:20 -04:00
Matthew Brown
a5f79353ed Fix #2157 - don’t merge closures and callable params 2019-09-22 00:58:30 -04:00