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
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
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
3a52ccd5a6
Add tests for things that should work
2019-06-25 21:46:18 -04:00
Matthew Brown
c4551bd0df
Fix issue where extension_loaded stopped constructor being recognised
2019-06-15 18:49:58 -04:00
Brown
0bd4dbcbc4
Bump to PHP 7.1
...
Fixes #1650
2019-05-16 18:36:36 -04:00
Matthew Brown
f33745ad25
Fix parameter offset for error
2019-05-13 16:01:41 -04:00
Brown
08bf101f48
Fix #1598 , catching unused variables followed by try inside loop
2019-05-02 17:21:02 -04:00
Brown
1eabe6ed55
Ignore protected properties redefined downstream
2019-04-17 16:55:15 -04:00
Brown
86c6b6fa36
Don’t warn about unused properties that override a used one
2019-04-17 16:41:35 -04:00
Brown
a529f74473
Add support for tracking callables
2019-04-17 15:45:40 -04:00
Matthew Brown
c772914910
Add some formatting
2019-03-23 14:27:54 -04:00
Bruce Weirdan
ec85096c96
Fixed identified issues
2019-03-02 08:43:19 -05:00
Matthew Brown
3d4710c9d3
Add better checks for invalid array_map/array_filter args
2019-02-22 00:50:41 -05:00
Brown
3deea3980d
Add checks for unitialized properties
...
Fixes #1328
2019-02-13 13:32:19 -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
Brown
341cb0c82c
Fix #1125 - check protected method overridden ids for use
2018-12-13 17:20:29 -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
Brown
d0bd10d143
Improve provider architecture, upping test coverage
2018-09-30 11:34:51 -04:00
Matt Brown
0304201d91
Fix #932 - allow obvious string vars to be used for includes
2018-08-07 13:17:23 -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
Matt Brown
4f9d4b7094
Fix #885 - allow suppression of UndefinedMethod at method level
2018-07-12 12:12:28 -04:00
Matt Brown
e10b2c0fd4
Fix #805 - allow dead code detection from methods just called internally
2018-06-19 16:14:51 -04:00
Matthew Brown
3670f066bb
Improve dead code detection
2018-06-16 20:01:41 -04:00
Matthew Brown
d47980df13
Fix #416 - make sure trait methods are treated better by dead code detection
2018-06-09 23:10:42 -04:00
Matt Brown
4bf652863b
Also check for non-false returns on LessSpecificReturnType
2018-03-07 11:16:56 -05:00
Matt Brown
80864b1ce8
Don’t be concerned about unused params named $_
...
Fixes #540
2018-02-27 11:39:26 -05:00
Matt Brown
1f358e36ef
Fix #544 - remove possibly assigned try vars from catch initialisations
2018-02-27 11:25:27 -05:00
Matthew Brown
115e647c3c
Fix #543 - register static vars properly so their references can be caught
2018-02-26 19:32:26 -05:00
Matthew Brown
956972b4a4
Fix #539 - evaluate global variable usage
2018-02-25 10:43:54 -05:00
Matthew Brown
81fd016120
Fix #193 - allow caching of storages
2018-02-19 00:27:39 -05:00
Matthew Brown
108ca54867
Fix #516 - make sure --find-references-to doesn’t output missing references
2018-02-17 17:45:30 -05:00