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

136 Commits

Author SHA1 Message Date
orklah
10c20dc8f3 mark variable used in backticks as used 2021-08-29 00:26:52 +02:00
Bruce Weirdan
052c7478cc
Unary plus and minus mark operand as used
Fixes vimeo/psalm#6145
2021-07-21 01:15:51 +03:00
Bruce Weirdan
a180dc6099
Flag staticness mismatch
This handles two new cases:
1. Accessing static property with `->` (produces notices and warnings: https://3v4l.org/TiGan)
2. Accessing non-static property with `::` (causes fatal error: https://3v4l.org/IdYSh)

Fixes vimeo/psalm#6117
2021-07-18 02:51:33 +03:00
Bruce Weirdan
76be96ce53
Drop FakeFileProvider from tests folder
And use Psalm\Internal\Provider\FakeFileProvider
2021-07-02 03:57:57 +03:00
Bruce Weirdan
6d4262edbd
Mark return values in as throw argument as used (#5989)
Fixes vimeo/psalm#5975
2021-06-25 09:11:27 -04:00
Matt Brown
b678461f5c Improve detection of fluent methods 2021-06-12 17:09:42 -04:00
Matt Brown
23b7ff86b7 Mark interface methods as unused even when inherited 2021-06-12 16:13:29 -04:00
Matt Brown
f2f5f1eaa2 Revert fix and tests 2021-06-10 17:44:34 -04:00
Matt Brown
e661c5fb55 Fix erroneous use when comparing methods 2021-06-10 14:39:01 -04:00
Matthew Brown
6d09418a23
Detect unused return values (#5917)
* Detect unused return values

* Allow static-returning instance methods (presumed to be fluent)

* Make $is_used the default for Codebase::methodExists
2021-06-10 14:18:15 -04:00
Matt Brown
5c1d8489da Improve test cases 2021-06-10 12:57:13 -04:00
Matt Brown
b33f87f68d Treat all assignment operations as equivalent binary ops 2021-06-04 14:39:38 -04:00
Matt Brown
6a61298074 Fix #5810 - detect properties that are never read 2021-05-21 09:25:57 -04:00
Matt Brown
517b2030c9 Fix #5545 - throwing uses method 2021-04-04 21:17:12 -04:00
Matt Brown
fe97aa0722 Fix #5542 - nullsafe method calls are assumed used 2021-03-31 10:08:52 -04:00
Matt Brown
150dd00060 Fix #5540 - function is used inside throw expression 2021-03-31 10:03:25 -04:00
Saif Eddin Gmati
9f74676524
allow dismissing return value of pure functions with by-reference arguments (#5463) 2021-03-25 09:05:59 -04:00
Saif Eddin Gmati
477ae33cd6
allow dismissing return value of no-return pure functions (#5461) 2021-03-23 19:34:12 -04:00
Matthew Brown
13497b8d2b Break out parent and implemented class checks 2021-01-05 17:49:55 -05:00
Matt Brown
ad5a8c247b Fix #4386 - fix issues with property promotion 2020-10-21 14:41:15 -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
orklah
37a2f8a33d
unused use statements (#4228) 2020-09-22 01:10:46 -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
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
5392ae0b39 Fix UnusedMethodCall examples 2020-07-16 18:14:15 -04:00
Brown
c56e29b114 Fix example 2020-07-16 16:19:29 -04:00
Brown
a2dbd31371 Fix usage of array_push results 2020-07-16 13:44:51 -04:00
Brown
d71f12d250 Fix #3802 - allow increment inside isset expression 2020-07-10 16:14:24 -04:00
Ilija Tovilo
2f646d29db
Fix #3607 - constant string class reference with leading backslash (#3612) 2020-06-19 18:02:39 -04:00
Brown
a701163f0a Add key method 2020-04-27 10:03:16 -04:00
Fabien Villepinte
a93bf28532
Fix #3045 - ignore mixed assignments to variables named $_ (#3211) 2020-04-21 20:18:38 -04:00
Matthew Brown
47c1470e3b Refactor reference checks to use more appropriate properties 2020-03-28 16:30:56 -04:00
Matthew Brown
6c7f89b0ab Fix #2920 - track unevaluated code after nested returns 2020-03-15 14:31:41 -04:00
Matthew Brown
5210f9b69b Fix #2966 - register constructor use for new $templated_class 2020-03-12 11:42:01 -04:00
Brown
2a72990d62 Add back support for unused method checks 2020-03-09 18:55:35 -04:00
Brown
59dce5d354 Skip failing test 2020-03-09 10:52:50 -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
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
25e7039f02 The current method is used
Fixes #2540
2020-01-01 18:33:12 -05:00
Matthew Brown
02fd1659ef Ignore serialize/unserialize methods
Fixes #2511
2019-12-31 07:56:35 -05:00
Brown
e551b24843 Classes that just reference themselves aren’t used 2019-12-16 11:46:10 -05:00
Brown
e476eed111 Fix issue where inside_conditional is forgotten 2019-12-11 12:06:10 -05:00
Brown
4b715cdbff Fix #2456 - ignore UnusedFunctionCall when function asserts 2019-12-11 10:13:22 -05:00
Brown
821f3528d2 Fix #701 - indicate issues fixable with Psalter 2019-12-02 15:24:01 -05:00
Matthew Brown
deb36e8b27 Allow array_map alone when it uses a closure 2019-09-09 21:28:56 -04:00
Brown
a6baa2d04c Allow callables to be understood as pure
Fixes #2112
2019-09-09 12:11:04 -04:00