Bruce Weirdan
394f7347de
Add missing dataflow population in array spreads ( #5059 )
...
Fixes vimeo/psalm#5057
2021-01-29 11:47:34 +01:00
Matt Brown
6f598464a9
Mixed array access should mark vars as used just in case
2021-01-29 11:47:14 +01:00
orklah
b084e2c4bd
add annotation @psalm-param-out ( #4717 )
...
* add annotation @psalm-param-out
* add tag in documentation
2021-01-29 11:47:02 +01:00
orklah
005373bbc2
Detect redundant cast ( #4695 )
...
* detect redundant cast
* fix redundant cast issues
* fix redundant cast in tests
2021-01-29 11:46:25 +01:00
Matt Brown
0b14b6968e
Fix #4472 - if something flows into a byref var it’s used
2021-01-29 11:46:13 +01:00
Matt Brown
4a8c98257e
Add closure-use termination for byref flows
2021-01-29 11:46:10 +01:00
Matt Brown
ad840e4b7a
Fix #4547 - mark unused uses
2021-01-29 11:46:10 +01:00
Matt Brown
c1d57ba6a5
Uses by ref should be assigned that way
2021-01-29 11:46:10 +01:00
Matt Brown
9f87b99fac
Fix #4435 - ensure casts are always flow-sensitive
2021-01-29 11:44:35 +01:00
Matt Brown
26352d0e39
Fix #3625 - getIterator call is used inside loop
2021-01-29 11:41:12 +01:00
Matt Brown
d7a0b718ec
Fix #4372 - count implicitly-used short-closure vars as used
2021-01-29 11:41:12 +01:00
Matt Brown
b3e423fd03
Fix #4368 - improve handling of try with finally
2021-01-29 11:41:12 +01:00
Matt Brown
c43c29880c
Fix #4336 - don’t merge sources twice for null coalesce
2021-01-29 11:39:56 +01:00
Matt Brown
8d1de7757d
Use more accurate arguments count
2021-01-29 11:39:55 +01:00
Matt Brown
a6e3d46d62
Treat func_get_args as using function params
2021-01-29 11:39:44 +01:00
Matt Brown
63953d5676
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
2021-01-29 11:39:44 +01:00
Brown
ee2149342e
Add more unused variable tests
2021-01-29 11:39:43 +01:00
Brown
f5019d92e2
Fix unused var in finally false-positive
2021-01-29 11:39:43 +01:00
Brown
d666d93950
Add more tests for unused variables
2021-01-29 11:39:42 +01:00
orklah
e3e5a55907
unused use statements ( #4228 )
2021-01-29 11:39:42 +01:00
Brown
d40cc0b35b
Skip currently-failing undefined variable test
2021-01-29 11:39:41 +01:00
Brown
364f8f1a01
Add back necessary suppression
2021-01-29 11:39:40 +01:00
Brown
c288dac4de
Fix tests
2021-01-29 11:39:40 +01:00
Brown
376a825161
Fix regression – detect unused params with defaults again
2021-01-29 11:39:37 +01:00
Brown
29481ed1bd
Fix #4127 - improve error message for unused closure var
2021-01-29 11:38:58 +01:00
orklah
db45ff1ba4
More return types ( #4173 )
...
* add native return types
* redundant phpdoc
2021-01-29 11:38:57 +01:00
orklah
61512da144
add native return types ( #4116 )
...
* add native return types
* remove redundant phpdoc
2021-01-29 11:38:53 +01:00
Brown
c96ba8d1f5
Add some backwards-incompatible changes for 4.x
2021-01-29 11:38:48 +01:00
Bruce Weirdan
dabfb16e34
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
2021-01-29 11:38:04 +01: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