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
4b401f0a77
Add more unused variable tests
2020-09-27 18:12:53 -04:00
Brown
4f28b38556
Fix unused var in finally false-positive
2020-09-25 10:20:22 -04:00
Brown
d879b4d199
Add more tests for unused variables
2020-09-25 00:14:27 -04:00
orklah
37a2f8a33d
unused use statements ( #4228 )
2020-09-22 01:10:46 -04:00
Brown
b501db6dd2
Skip currently-failing undefined variable test
2020-09-21 16:01:14 -04:00
Brown
6334c50c07
Add back necessary suppression
2020-09-20 21:25:35 -04:00
Brown
ef612ea598
Fix tests
2020-09-20 20:58:34 -04:00
Brown
17a0ecb60e
Fix regression – detect unused params with defaults again
2020-09-14 10:58:36 -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
f66d57f19d
add native return types ( #4116 )
...
* add native return types
* remove redundant phpdoc
2020-09-04 16:26:33 -04:00
Brown
92239add4d
Add some backwards-incompatible changes for 4.x
2020-08-30 11:44:14 -04:00
Bruce Weirdan
1cf5153700
Test parallelization ( #4045 )
...
* Run tests in random order
Being able to run tests in any order is a pre-requisite for being able
to run them in parallel.
* Reset type coverage between tests, fix affected tests
* Reset parser and lexer between test runs and on php version change
Previously lexer was reset, but parser kept the reference to the old
one, and reference to the parser was kept by StatementsProvider. This
resulted in order-dependent tests - if the parser was first initialized
with phpVersion set to 7.4 then arrow functions worked fine, but were
failing when the parser was initially constructed with settings for 7.3
This can be demonstrated on current master by upgrading to
nikic/php-parser:4.9 and running:
```
vendor/bin/phpunit --no-coverage --filter="inferredArgArrowFunction" tests/ClosureTest.php
```
Now all tests using PHP 7.4 features must set the PHP version
accordingly.
* Marked more tests using 7.4 syntax
* Reset newline-between-annotation flag between tests
* Resolve real paths before passing them to checkPaths
When checkPaths is called from psalm.php the paths are resolved, so we
just mimicking SUT behaviour here.
* Restore newline-between-annotations in DocCommentTest
* Tweak Appveyor caches
* Tweak TravisCI caches
* Tweak CircleCI caches
* Run tests in parallel
Use `vendor/bin/paratest` instead of `vendor/bin/phpunit`
* Use default paratest runner on Windows
WrapperRunner is not supported on Windows.
* TRAVIS_TAG could be empty
* Restore appveyor conditional caching
2020-08-23 10:32:07 -04:00
Brown
afce2dc66f
Tighten up rules around instantiation a bit more
2020-08-06 10:18:55 -04:00
Brown
fd4ced42a7
Don’t register new assignment inside isset expr
2020-07-31 12:44:01 -04:00
Brown
e55fe0a0e8
Fix #3188 - register global variables as by-reference ones
2020-04-19 13:15:04 -04:00
Matthew Brown
47c1470e3b
Refactor reference checks to use more appropriate properties
2020-03-28 16:30:56 -04:00
Matthew Brown
c85fa9083d
Fix #2915 - prevent "if (true)" and similar
2020-03-15 22:23:31 -04:00
Matthew Brown
b6380ae595
Fix false-positives around unevaluated code
2020-03-15 14:43:05 -04:00
Matthew Brown
aaf74f084a
Fix #2954 - filter out used vars before checking params
2020-03-13 20:21:49 -04:00
Matthew Brown
54d38e562f
Fix #2970 - use correct unreferenced vars when analysing do
2020-03-13 11:41:17 -04:00
Matthew Brown
75a3412a42
Downgrade error when using unknown variable in mixed method
2020-03-05 21:24:08 -05:00
Matthew Brown
b2678d40aa
Revert "Fix #2909 - don’t treat args of unknown calls as possible by-reference vars"
...
This reverts commit 105fe012c4
.
2020-03-05 21:10:29 -05:00
Matthew Brown
0644f5ab3a
Remove unnecessary test
2020-03-04 23:55:38 -05:00
Matthew Brown
105fe012c4
Fix #2909 - don’t treat args of unknown calls as possible by-reference vars
2020-03-04 23:49:06 -05:00
Matthew Brown
2aebc522f1
Fix #2705 - mark by-ref args as used if not variables already
2020-01-29 21:46:30 -05:00
Brown
15808458cc
Better understand nesting loops and switches
...
Fixes #2700
2020-01-27 12:17:12 -05:00
Matthew Brown
ba6d0df048
Fix #2546 properly
2020-01-04 11:16:53 -05:00
Brown
4263417ac3
Fix #2546 - ignore vars set inside loop
2020-01-03 10:33:32 -05:00
Brown
de0fad2197
Fix #2541 - check variable var assignment
2020-01-02 14:07:02 -05:00
Matthew Brown
9d8ca08fb9
Fix #2479 - analyse undefined function arguments too
2019-12-18 16:37:48 +00:00
Brown
133921b33f
Add a few tests
2019-12-06 14:47:05 -05:00
Brown
19838fc7f5
Fix #2423 - pass by ref variable status after byref assignment
2019-12-05 13:37:03 -05:00
Matthew Brown
e40aaafe61
Allow explicit @var mixed docblocks
...
Fixes #2397
2019-12-01 10:19:42 -05:00
Brown
81f513bb4c
Fix #2358 - always analyse new XXX(...) in unknown method calls
2019-11-18 16:14:21 -05:00
Brown
c9e7dcfa92
Fix false positive UnusedVariable
2019-11-13 14:32:27 -05:00
Brown
7516b7b0cf
Fix #2336 - detect used variable in mixed array offset
2019-11-13 13:38:34 -05:00
Matthew Brown
b1aae0d1a5
Fix more try/catch stuff
2019-11-12 00:52:10 -05:00
Brown
51557c44ea
Evaluate finally blocks at the end of every catch
2019-11-11 18:38:33 -05:00
Brown
935bad9d2c
Fix erroneous unused variable
2019-11-11 16:52:55 -05:00
Matthew Brown
62a3598ed3
Fix #2197 - prevent false positive from try in while
2019-11-09 11:01:48 -05:00
Matthew Brown
7028a64440
Fix #2204 - fix try/catch false-positive
2019-11-09 10:39:21 -05:00
Matthew Brown
4aeb28aceb
Fix #2244 - correctly check do while expression before use
2019-10-20 14:18:30 -04:00
Brown
c5ef2516b5
Fix #2150 - add detection for unnecessary @var annotations
...
And also remove them from codebase
2019-09-19 11:59:43 -04:00
Matthew Brown
853e92e7fc
Fix #2073 - better understand assignments inside elseif
2019-08-26 22:55:28 -04:00
Brown
febd60dade
Add better handling of catch-reassigned vars
...
Ref #2052
2019-08-26 11:41:15 -04:00
Brown
57386ab26e
Fix #2023 - no UnusedVariable complaint when method is undefined
2019-08-15 09:51:40 -04:00
Brown
e25ce152d6
Fix #2014 - prevent unusedvariable false positive when redefined in assignment ||
2019-08-15 09:43:43 -04:00
Brown
7622f11a20
Add a couple of skipped tests
2019-08-14 17:15:35 -04:00
Brown
d6e084ec9c
Remove false-positive for callmap function arg
2019-08-13 14:53:31 -04:00
Brown
0468d11158
Detect function in array access op
2019-08-13 14:07:45 -04:00
Brown
10b8a94564
Fix #2007 - improve unused variable detection in always-entered loops
2019-08-12 16:01:24 -04:00
Brown
5254b7501e
Fix #1996 - detect unused variable in static property name
2019-08-09 12:55:47 -04:00
Brown
8cb5d012d9
Check expressions in variable name static calls
2019-07-25 09:45:11 -04:00
Brown
e22e0ac92c
Fix unused ref in assign op
...
Fixes #1968
2019-07-24 16:53:14 -04:00
Matthew Brown
da42be175f
Apply PHPCS fixes
...
Fixes #1880
2019-07-05 16:27:53 -04:00
Matthew Brown
20b7ff1f9d
Add unused test
2019-07-04 22:25:49 -04:00
Matthew Brown
6dd549b8a6
Fix #1900 - discard old references to code after an assignment
2019-07-04 17:35:33 -04:00
Matthew Brown
d0f6f85dba
Fix #1899 - detect dead code after array assignment
2019-07-04 16:38:31 -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
41cdde514f
Fix #1784 - detect missing end brackets
2019-06-15 17:57:40 -04:00
Brown
8c653b0312
Improve dead code detection a little more
2019-05-20 18:25:11 -04:00
Brown
2637156f45
Properly fix #1128 with additional check
2019-05-20 12:01:18 -04:00
Brown
83a2122f8c
Fix #1464 and fix #1128 - reduce try/catch UnusedVariable false positives
2019-05-20 11:54:21 -04:00
Brown
0bd4dbcbc4
Bump to PHP 7.1
...
Fixes #1650
2019-05-16 18:36:36 -04:00
Matthew Brown
7c2fe53446
Fix #1391 - find dead code in assignments to self
2019-05-12 23:31:36 -04:00
Matthew Brown
307cdbbbb3
Fix #1626 - detect dead code found in #1624
2019-05-12 20:49:37 -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
Matthew Brown
e9afd3a6f3
Examine arrays in unknown function calls
2019-03-27 22:13:06 -04:00
Matthew Brown
c772914910
Add some formatting
2019-03-23 14:27:54 -04:00
bugreportuser
42137f6054
Ignore unused superglobals
2019-03-22 10:19:39 -04:00
bugreportuser
aafb3ee6d6
Ignore unused static vars
2019-03-22 09:50:47 -04:00
Matthew Brown
848b070946
Fix #1413 - don’t complain about byref use param
2019-03-10 16:36:35 -04:00
Brown
bd372e93af
Add config flags for findUnusedVariables and findUnusedCode
2019-03-05 15:45:09 -05:00
Bruce Weirdan
ec85096c96
Fixed identified issues
2019-03-02 08:43:19 -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
a6755cc523
Fix default test versions to 7.3
2019-02-07 15:27:43 -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
b43a6a31f1
Enable casing plugin and fix issues it found
2019-01-12 10:52:23 -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
901596281c
Fix #1143 - check some variable new calls
2019-01-02 06:58:49 -05:00
Brown
f5e788ec1f
Increase limits of literal strings to 50 characters
2018-11-27 17:48:23 -05:00
Brown
dc834fdb01
Default allowStringToStandInForClass to true and fix errors found
2018-11-12 12:03:55 -05:00
Brown
110ca66692
Namespace test providers under Internal cc @TysonAndre
2018-11-12 11:20:59 -05:00
Matthew Brown
4d79b61e93
Change _checker to _analyzer
2018-11-12 11:20:59 -05:00
Matthew Brown
4688b25fd9
Move internal classes to own namespace
2018-11-12 11:20:59 -05:00
Matthew Brown
9056353b7f
Fix #1065 - allow interface methods to be used in abstract classes
2018-11-10 19:05:51 -05:00
Brown
9ea2009cd2
Add a closure in scope just in time for analysis
2018-10-04 16:42:40 -04:00
Brown
d0bd10d143
Improve provider architecture, upping test coverage
2018-09-30 11:34:51 -04:00
Bruce Weirdan
c1e21fcf5d
Update PHPUnit ( #888 )
...
* upgrade phpunit, test with low and high deps
* work around possibly-anonymous test cases introduced by newer PHPUnit
* Alternative TestCase::getName() nullability workaround
Previous workaround was failing due to PHP warnings on 7.1 or 7.2
(depending on specific signature). There's just no signature that would
be working for all 4 variants of (ver / dep) matrix.
* don't disable xdebug if it's not enabled
* allowed 7.0/high to fail until PHPUnit 6.5.10 is released
see sebastianbergmann/phpunit#3209
2018-07-13 17:44:50 -04:00
Matthew Brown
5ed062257b
Allow dead code detection to capture last do checks
2018-06-30 11:08:51 -04:00
Matt Brown
72b110af3f
Analyse RHS of instanceof expressions if expression
2018-06-27 10:07:40 -04:00
Matthew Brown
5867ef45ff
Check method args even if the methods themselves cannot be checked
2018-06-25 19:38:15 -04:00
Matthew Brown
5ddd74e7d2
Catch unused foreach key when it’s already in scope
2018-06-17 00:52:32 -04:00
Matthew Brown
805bfa6f2d
Improve handling of switch statement assignments
2018-06-17 00:12:26 -04:00
Matthew Brown
89affb6c2c
Fix #822 - improve dead code detection on assignop expressions
2018-06-16 23:40:25 -04:00
Matthew Brown
fa51c39902
Improve dead code analysis of switch statements
2018-06-16 21:54:44 -04:00
Matthew Brown
f38da967dd
Fix a few issues with dead code detection
2018-06-16 21:14:19 -04:00