1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-05 13:10:49 +01:00
Commit Graph

191 Commits

Author SHA1 Message Date
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
Matthew Brown
a0e88cb16f Fix #518 - improve dead code detection to cover variable method calls 2018-02-17 17:23:57 -05:00
Matthew Brown
c87204acbf Don’t check for unused vars when checking for initialiasations
Fixes #517
2018-02-17 12:02:31 -05:00
Matthew Brown
8e0998e081 Break apart the Codebase class 2018-02-03 18:56:54 -05:00
Matt Brown
4099bf24ce Make sure new $class args are always evaluated 2018-01-29 12:22:50 -05:00
Matt Brown
66c8637b5b Fix unused code checks for possibly undefined vars 2018-01-29 12:13:44 -05:00
Matthew Brown
c4be89bf37 Validate docs by running code through them 2018-01-28 23:41:11 -05:00
Matthew Brown
ed5245bc47 Go easy on unknown invocations 2018-01-28 18:13:38 -05:00
Matthew Brown
44b8b22995 Improve checks for unused variables and params 2018-01-28 17:28:34 -05:00
Matthew Brown
ea28ee709d Improve unused variable detection slightly 2018-01-25 01:04:26 -05:00
Matthew Brown
924cf8d222 Add tests for unused params and properties 2018-01-21 23:48:58 -05:00
Matthew Brown
bc9761f6c9 Create Codebase out from ProjectChecker 2018-01-21 13:45:33 -05:00
Matthew Brown
9b6b03ff9f Create Config before ProjectChecker, and remove test-specific code from FileChecker 2018-01-21 10:22:04 -05:00
Tyson Andre
43e8703a2e Be strict about matching error messages 2018-01-11 18:04:11 -05:00
Matt Brown
2120d258a4 Fix formatting of return type adder 2018-01-11 15:50:58 -05:00
Matthew Brown
fb9f20f4b8 Find unused properties with dead code checks
Fixes #424
2018-01-10 23:29:18 -05:00
Matthew Brown
17d208bdd5 Increase test coverage 2017-12-30 10:54:01 -05:00
Matthew Brown
2d24f9e99d Don’t complain about unused variables when they’re passed by reference 2017-12-30 09:30:02 -05:00
Matthew Brown
086b314df8 Cut down on interface PossiblyUnusedMethod reports 2017-12-29 19:38:01 -05:00
Matthew Brown
0b58ee425d Fix trait method evaluation order 2017-12-29 11:26:28 -05:00
Matthew Brown
f136fc3296 Fix #305 by making test error message checks more accurate 2017-11-15 21:04:25 -05:00
Matt Brown
59265ef2bf Fix #276 - fix false positive in magic call 2017-11-10 18:08:26 -05:00
Matt Brown
e49573e7f6 Fix #279 - make sure referenced vars updated always in or 2017-11-09 16:42:39 -05:00
Matthew Brown
657d154288 CacheProvider -> ParserCacheProvider 2017-10-15 11:57:44 -04:00
Matt Brown
0e67565b2c Return null if path exists 2017-07-26 19:36:41 -04:00
Matt Brown
76ba419330 Group unused tests together 2017-07-25 17:04:58 -04:00
Matthew Brown
e29dd140e3 Refactor scanning and analysis, introducing multithreading (#191)
* Add failing test

* Add visitor to soup up classlike references

* Move a whole bunch of code into the visitor

* Move some methods back, move onto analysis stage

* Use the getAliases method everywhere

* Fix refs

* Fix more refs

* Fix some tests

* Fix more tests

* Fix include tests

* Shift config class finding to project checker and fix bugs

* Fix a few more tests

* transition test to new syntax

* Remove var_dump

* Delete a bunch of code and fix mutation test

* Remove unnecessary visitation

* Transition to better mocked out file provider, breaking some cached statement loading

* Use different scheme for naming anonymous classes

* Fix anonymous class issues

* Refactor file/statement loading

* Add specific property types

* Fix mapped property assignment

* Improve how we deal with traits

* Fix trait checking

* Pass Psalm checks

* Add multi-process support

* Delay console output until the end

* Remove PHP 7 syntax

* Update file storage with classes

* Fix scanning individual files and add reflection return types

* Always turn XDebug off

* Add quicker method of getting method mutations

* Queue return types for crawling

* Interpret all strings as possible classes once we see a `get_class` call

* Check invalid return types again

* Fix template namespacing issues

* Default to class-insensitive file names for includes

* Don’t overwrite existing issues data

* Add var docblocks for scanning

* Add null check

* Fix loading of external classes in templates

* Only try to populate class when we haven’t yet seen it’s not a class

* Fix trait property accessibility

* Only ever improve docblock param type

* Make param replacement more robust

* Fix static const missing inferred type

* Fix a few more tests

* Register constant definitions

* Fix trait aliasing

* Skip constant type tests for now

* Fix linting issues

* Make sure caching is off for tests

* Remove unnecessary return

* Use emulative parser if on PHP 5.6

* Cache parser for faster first-time parse

* Fix constant resolution when scanning classes

* Remove test that’s beyond a practical scope

* Add back --diff support

* Add --help for --threads

* Remove unused vars
2017-07-25 16:11:02 -04:00
Matthew Brown
22a716f4da Improve formatting of phpdocs 2017-05-26 20:16:18 -04:00
Matthew Brown
d6909193ea Add additional formatting changes 2017-05-26 20:05:57 -04:00
Matthew Brown
754a4d9950 Allow Psalm to be run outside of the directory it's installed in (#154)
* Add --root option when not running Psalm from root directory

* Add informative error when running Psalm outside of its project directory

* Add better message in help

* Fix autoloader precedence
2017-05-04 14:25:58 -04:00
Jon Ursenbach
11bc153deb Rewriting and streamlining every unit test with data providers. (#147)
* Rewriting and streamlining every unit test with data providers.

All unit tests have been rewritten into PHPUnit data providers
to reduce the amount of unnecessary code-reuse through out the
test suite.
2017-04-24 23:45:02 -04:00
Matthew Brown
cd5f727d2e Collect explicit references to classes/methods 2017-02-26 23:09:18 -05:00
Matt Brown
182f715b62 Add dead code detection for possibly unused public methods 2017-02-23 19:52:23 -05:00
Matthew Brown
cdcacc395d Rename DeadCode to UnusedVariable, UnusedMethod and UnusedClass 2017-02-08 00:28:26 -05:00