1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00
Commit Graph

117 Commits

Author SHA1 Message Date
Matt Brown
3731255f6f
Fix #4386 - fix issues with property promotion 2021-01-29 11:41:13 +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
orklah
e3e5a55907
unused use statements (#4228) 2021-01-29 11:39:42 +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
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
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
Brown
de5df1e36a Warn about unnecessary use of DateTimeImmutable 2019-09-03 13:49:15 -04:00
Matthew Brown
4a38ab165f Fix erroneous marking of external-mutation-free method as unused 2019-08-31 10:02:11 -04:00
Matthew Brown
7886d5a408 Add support for @psalm-mutation-free annotation on methods 2019-08-31 00:47:12 -04:00
Matthew Brown
504ccdab8c $a++, $a-- etc should be treated as assignments 2019-08-30 18:06:45 -04:00
Matthew Brown
d891217a48 Don’t complain about initialisation of external-mutation-free classes from pure context 2019-08-30 17:34:58 -04:00
Matthew Brown
bbde2d6239 Add support for @psalm-external-mutation-free 2019-08-30 17:26:55 -04:00
Matthew Brown
6d07663d70 Annotate method getters more accurately 2019-08-30 16:40:32 -04:00
Matthew Brown
f4f4a32f08 Fix #2062 - treat function inside variable method call name as used 2019-08-26 00:47:46 -04:00
Brown
f00ee740c0 Analyse encapsulated string when method not known
Ref #2052
2019-08-23 10:59:59 -04:00
Matthew Brown
5a1604d088 Fix #2047 - left side of callable is a thing that is also kinda called 2019-08-22 22:06:22 -04:00
Thomas Bley
149402abda Extend impure functions (#2042)
* extended impure functions, fixes #2038

* extended UnusedCodeTest #2038
2019-08-21 13:12:13 -04:00
Matthew Brown
6ea68e9f7f Clean up more unused @psalm-suppress annotations 2019-08-18 16:59:56 -04:00
Matthew Brown
5d94e340ee Remove unused suppressions in tests 2019-08-18 15:34:32 -04:00
Brown
6a213a60aa Make test name align with tested thing 2019-07-31 17:42:01 -04:00
Brown
3a1a3ebc47 Fix #1980 - don’t complain about UnusedVariable after continue 2019-07-31 17:35:56 -04:00
Matthew Brown
c887d907e3
Add missing return type 2019-07-28 20:42:35 -04:00
2e3s
f15cc7dd5b Mark private properties unused when referenced only in constructor (#1962)
* Mark private properties unused when referenced only in constructor

If a private property is used only in constructor then most likely
it's a dead code since there is no need to have the class property.
But such static properties can be accessed between the calls.

* Ignore the private property issue on alter

* Fix the related dead code psalm

* Add a missing condition into the test
2019-07-21 23:29:16 -04:00
Matthew Brown
da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00
Brown
c4eb127f11 Fix treatment of class_exists 2019-06-27 10:17:11 -04:00