1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
Commit Graph

157 Commits

Author SHA1 Message Date
Matthew Brown
b558748db2 Detect unused properties that are written to inside arrays 2021-12-11 11:42:05 -05:00
rarila
39402c233d
Return type hints (#7065)
Co-authored-by: ralila <>
2021-12-05 19:51:26 +02:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
ralila
f833085a15 Fix fqn usage in php-doc 2021-12-04 03:37:19 +01:00
ralila
7c32325e03 Import instead of using fqn constants 2021-12-03 21:25:22 +01:00
ralila
2a956498bf Import instead of using fqn functions 2021-12-03 21:07:25 +01:00
ralila
711be643c6 Import instead of using fqn exceptions 2021-12-03 20:29:06 +01:00
ralila
245920e53c Import instead of using fqn 2021-12-03 20:11:20 +01:00
Bruce Weirdan
d19aad7db1
Display target PHP version
Historically it was often not quite clear to users what PHP version
Psalm assumes, and why. This PR addresses this issue by printing the
version and where we got it from right before scanning the files.
2021-11-27 02:18:09 +02:00
orklah
d8fcd783c8 fix parse 2021-11-22 21:38:25 +01:00
orklah
1c1e352e5f prevent Psalm from considering throwing methods as unused just because they're immutable 2021-11-22 21:29:57 +01:00
Philip Hofstetter
ece2bccf76
don't stop processing for class usage after raising an issue
this fixes #6887
2021-11-12 09:24:39 +01:00
Philip Hofstetter
038df9cebe
detect unevaluated inline-html code after an rearly return
this is a followup after #6876

this fixes #6877
2021-11-10 13:11:50 +01:00
Philip Hofstetter
f407ac846a
do not treat __halt_compiler() as an expression being executed
this fixes #6875
2021-11-10 12:45:12 +01:00
orklah
65c41e7543 don't consider calls to methods with assertions as Unused 2021-11-06 20:00:31 +01:00
orklah
9c9669ea44 don't consider calls to methods with assertions as Unused 2021-11-06 19:54:17 +01:00
orklah
f4f9bd6711 allow declaring functions and classLikes after a never-returning call 2021-11-05 18:34:59 +01:00
orklah
6e8bd2b207 allow declaring functions and classLikes after a never-returning call 2021-11-05 18:18:34 +01:00
orklah
33aab6cc40 allow declaring functions and classLikes after a never-returning call 2021-11-05 18:09:40 +01:00
orklah
500571b9da move tests to enable config 2021-11-01 22:45:17 +01:00
orklah
88dd4eace3 add test 2021-10-11 17:33:02 +02:00
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