orklah
5a99c9be94
offset the starting position of the function in case of attributes
2021-09-29 21:19:04 +02:00
Bruce Weirdan
b39e765475
Prevent failures with dev PHP versions
...
It was failing with dev versions, e.g. `8.2.0-dev`
2021-09-07 01:43:03 +03:00
Bruce Weirdan
76be96ce53
Drop FakeFileProvider from tests folder
...
And use Psalm\Internal\Provider\FakeFileProvider
2021-07-02 03:57:57 +03:00
orklah
872f1c232c
allow Psalter to fix RedundantCast ( #5948 )
...
* allow Psalter to fix RedundantCast
* fix test
2021-06-17 18:15:45 -04:00
orklah
cfa5492286
Remove redundant namespaced phpdoc ( #5936 )
...
* remove array-key from generated phpdoc
* remove mixed value too
* fix tests
* fix mixed suppression
* revert back to array to prevent breaking refactoring
2021-06-16 11:16:20 -04:00
Bruce Weirdan
6abce3525a
Enforce use
sort ( #5900 )
2021-06-07 22:55:21 -04:00
orklah
3bcfd2e726
allow psalter to add literal string/int in psalm phpdoc ( #5844 )
...
* allow psalter to add literal string/int in psalm phpdoc
* fix CS
2021-05-28 09:46:11 -04:00
orklah
de1bb954cf
Handle the case where a switch return on each case ( #5819 )
...
* Handle the case where a switch return on each case
* introduce a "hybrid" case exit type for cases where there's both "none" and something else
2021-05-23 16:24:29 -04:00
pawel-slowik
d82f02879c
Don't migrate virtual nodes ( #5780 )
...
* Add a failing test for issue #5002
* Don't try to migrate virtual nodes
Fixes #5002
2021-05-17 22:21:32 -04:00
Bruce Weirdan
9e19653a72
Infer never
return type ( #5710 )
...
* Allow __toString to return never
Fixes vimeo/psalm#5653
* Push $return_is_exit down
* Produce unique control actions
* Test suggesting `@return never`
2021-05-05 01:22:29 -04:00
orklah
343d020408
improve psalter capacities for anonymous class extending real classes ( #5146 )
2021-02-04 09:59:38 -05:00
Ben Davies
53afd2857d
Split unit test over multiple jobs in GitHub Actions, lowering the total run time ( #4985 )
...
* Split unit test over multiple jobs in GitHub Actions, lowering the total run time
* rename FileManipulationTest to FileManipulationTestCase so it does not run as a standalone Test
2021-01-11 17:30:33 -05:00
orklah
1d9987e0ed
fix phpdoc ( #4905 )
2020-12-29 11:42:41 +00:00
orklah
f0c0ac0616
handle return flag for a try/catch/finally ( #4746 )
...
* handle return flag for a try/catch/finally
* add tests for psalter
2020-12-01 12:55:27 -05:00
Matt Brown
b14a62338e
Fix test
2020-11-23 13:14:40 -05:00
Matt Brown
baca927aab
Fix #4643 - use PHP8 union types when possible
2020-11-21 22:50:56 -05:00
Matt Brown
3728837ef9
Only run unused code analysis where necessary
2020-11-21 18:25:18 -05:00
orklah
509a937d1b
use int|string in phpdoc format for array-key ( #4645 )
2020-11-21 17:38:40 -05:00
orklah
6b72599ec5
allow static return type in PHP8 ( #4641 )
2020-11-20 18:46:35 -05:00
orklah
e04f219948
return static instead of self when static context detected ( #4632 )
...
* return this instead of self when static context detected
* replace $this by static
2020-11-19 19:02:25 -05:00
Matt Brown
ab3961d9b3
Sanity check to ensure closure uses aren’t removed
2020-11-18 00:38:28 -05:00
Matt Brown
c9e47450a7
Fix #4266 - prevent OOM when analysing closure unioned with invokable class
2020-10-02 00:47:42 -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
Brown
68ebef2a2e
Clean up immutable fix
2020-09-03 15:32:14 -04:00
Brown
28a107e620
Fix #4112 - allow slashes in docblock tag names
2020-09-02 19:39:59 -04:00
Brown
92239add4d
Add some backwards-incompatible changes for 4.x
2020-08-30 11:44:14 -04:00
Brown
4e10a0ed6f
Fix #4036 - add immutable annotations automatically too
2020-08-24 19:29:00 -04:00
Brown
94cec15598
Only add pure when not overriding upstream
2020-08-23 22:16:03 -04:00
Brown
6103cf0f51
Fix ImpureVariable test
2020-08-23 22:07:02 -04:00
Brown
02a2e99d42
Only add pure to functions with params
2020-08-23 18:41:31 -04:00
Matthew Brown
8a975d7c20
Don’t add pure annotation when closure is impure
2020-08-23 14:07:19 -04:00
Matthew Brown
9418be79cc
Restrict pure annotation addition a little more
2020-08-23 13:34:32 -04:00
Brown
c8ea4b4e8b
Prohibit property fetches from pure contexts except when they’re on immutable objects
2020-08-23 10:57:24 -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
67f9adb33c
Allow adding pure annotations to functions
...
Ref #4036
2020-08-23 10:28:26 -04:00
Brown
cdef4ec351
Alter docblock params too
2020-08-14 16:26:55 -04:00
Brown
dbcf154036
Add fixer for mismatching param names
2020-08-14 15:25:21 -04:00
Brown
2afbf58324
Prevent adding trait property types
2020-07-10 19:11:06 -04:00
Brown
33a834bb0b
Fix some property inference bugs
2020-07-08 14:43:36 -04:00
Brown
619c384509
Add indentation as necessary between property docblocks
2020-07-08 14:32:16 -04:00
Brown
cf67b9eef1
Fix #435 - add psalter fix for MissingPropertyType
2020-07-08 12:03:12 -04:00
Matthew Brown
5395183837
Use more accurate means of determining whether function did return
2020-03-28 23:37:42 -04:00
Matthew Brown
7195ea6842
Fix #3030 - don’t suggest return types can do more
2020-03-28 23:15:54 -04:00
Matthew Brown
fc651c489e
Break out MissingReturnType manipulation tests
2020-03-28 22:49:38 -04:00
Matthew Brown
f94ab22a5f
Be better about strict inference
2020-03-25 09:18:49 -04:00
Matthew Brown
af2ea1732b
Fix #2857 - use correct location for byref vars
2020-02-21 00:42:52 -05:00
Brown
e567f8c728
Fix #2752 - string casts can be implicit method calls, don’t remove automatically
2020-02-06 21:05:16 -05:00
Matthew Brown
5bd9b988fb
Fix #2494 - don’t use extended name for anonymous classes
2019-12-31 08:46:52 -05:00
Bruce Weirdan
4110ec351b
Make travis green again ( #2518 )
...
* Bumped phpspec/prophecy version to prevent 7.4 deprecations
* Fix DOMDocument::$config type
This property was documented as containing DOMConfiguration object, but
in fact always returned `null` (see [php source](ee80567a83/ext/dom/document.c (L542)
)).
DOMConfiguration class is removed in PHP 8.
* Dropped unused use
* Allow to set PHP 8.0 as current version
* Fix CallMap issues for PHP 8.0
- Use both major and minor version to load deltas
- Don't load non-existent deltas
- Stop at lowest possible delta
2019-12-27 19:06:09 -05:00
Brown
9d22f56560
Fix #2443 - templates are not valid PHPDoc
2019-12-10 14:03:51 -05:00
Matthew Brown
aa4daea182
Add extra safety feature
2019-12-03 01:59:36 -05:00
Matthew Brown
585ef0644d
Add test for docblock-defined param types
2019-12-03 01:52:18 -05:00
Matthew Brown
97de060df9
Fix #2279 - add parameter typehint by default
2019-12-03 01:49:43 -05:00
Brown
821f3528d2
Fix #701 - indicate issues fixable with Psalter
2019-12-02 15:24:01 -05:00
Matthew Brown
2369bac943
Preserve self refs where possible
2019-11-16 19:59:08 -05:00
Brown
55bf6a2db3
Migrate static return types
2019-11-15 16:50:43 -05:00
Brown
4747ba709a
Migrate more things
2019-11-15 15:34:25 -05:00
Brown
fe5e675881
Improve unvariable removal
2019-11-13 15:05:21 -05:00
lhchavez
216f991b0c
Normalize stringified type names ( #2239 )
...
This change makes stringified types more normalized. Concretely it sorts
all union types, reconciled types, and sorts the keys within object-like
types.
2019-10-17 01:14:33 -04:00
Brown
73eb71bada
I think I understand strpos/strrpos a little better now
2019-09-26 15:31:56 -04:00
Brown
4832aa6075
Fix incorrect location for substitution
2019-09-26 15:22:33 -04:00
Brown
cf799d0926
Fix #2173 - remove @var annotations automatically
2019-09-26 15:08:05 -04:00
Matthew Brown
b4178c7ee1
Fix #2013 - don’t add more specific return type when @inheritdoc present
2019-09-01 16:00:52 -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
9c616aa5c6
Remove pure function calls when removing unused variables
2019-08-16 23:19:52 -04:00
Matthew Brown
53817ed40b
Fix #1991 - allow overlapping code to subsume manipulations inside
2019-08-08 22:58:54 -04:00
Brown
ea2074b19b
Allow suppression of unused variable issues
2019-07-24 17:01:41 -04:00
Brown
862f48503f
Fix tests
2019-07-24 17:00:27 -04:00
Jeffrey Yoo
ed61bcafda
Issue 1926 unused variable ( #1967 )
...
* add support for Psalter to remove UnusedVariable
* fix issues found by Psalm
* fix stylistic issues found by phpcs
* added more stylistic changes and suppressed UndefinedClass error for Psalm
* suppress TypeDoesNotContainType error for CheckTrivialExprVisitor
* fix whitespace issue raised by phpcs
* fix bug where partial removal of assignment by ref does not process '&' symbol
* Remove workspace files
* remove 'Array_' and 'ArrayItem' classes from blacklist and add 'New_' class to the blacklist
2019-07-24 16:48:54 -04:00
Matthew Brown
da42be175f
Apply PHPCS fixes
...
Fixes #1880
2019-07-05 16:27:53 -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
Hugo Alliaume
37d719ed67
Fix readability for object-like types when running psalter
( #1708 )
...
* chore: update tests
* fix: better readability for object-like types
* test: add tests for nested array return type
* Improve spacing
2019-06-16 09:20:49 -04:00
Brown
1bc1af140f
Move method calls outside classes and __CLASS__ constants
2019-06-14 15:54:15 -04:00
Brown
58b6ce3483
Fix bugs when moving methods that reference each other
2019-06-14 14:41:44 -04:00
Brown
2fba2e42a9
Fix #1771 - allow psalm-refactor to manipulate namespaces
2019-06-13 18:28:46 -04:00
Brown
010f911d22
Fix replacement of local types
2019-06-11 10:33:52 -04:00
Brown
45f2d986e6
Allow multiple class renames at once
2019-06-10 17:09:34 -04:00
Matthew Brown
537fbf059a
Allow moving instance method into subclass
2019-06-08 16:59:19 -04:00
Matthew Brown
20c66f693e
Fix handling of class const types
2019-06-06 18:46:40 -04:00
Matthew Brown
36ac342496
Fix handling of property type with default
2019-06-06 17:42:23 -04:00
Matthew Brown
b091ceaa9a
Fix union of literal class string
2019-06-06 17:18:24 -04:00
Brown
b1d1ab974c
Preserve formatting of callable type
2019-06-06 14:27:49 -04:00
Brown
0221282074
Be resilient to docblock spaces
2019-06-06 13:57:00 -04:00
Matthew Brown
0287adfd44
Fix const replacements when moving classes
2019-06-06 07:05:30 -04:00
Matthew Brown
4fc5d1d5c8
Rewrite use statements
2019-06-05 22:13:33 -04:00
Brown
ddd287fb3d
Move exception classes
2019-06-05 11:33:04 -04:00
Brown
6f0a6201de
Fix static calls after moving
2019-06-05 11:22:09 -04:00
Brown
3e15fa8bfe
Fix bad namespacing
2019-06-05 11:15:52 -04:00
Brown
f309c755f8
Add ability to move classes
2019-06-05 08:50:24 -04:00
Brown
778b95d335
Add support for moving class constants
2019-06-04 11:14:49 -04:00
Matthew Brown
a9809ab28a
Add property moving & renaming
2019-06-04 00:32:19 -04:00
Matthew Brown
fc0f625f62
Add safeguards to prevent bad refactor input
2019-06-02 23:33:57 -04:00
Matthew Brown
2439a9f6a0
Allow instance method renaming, too
2019-06-02 12:02:39 -04:00
Matthew Brown
2b0a17c1c8
Add simple tool to move static methods
2019-06-02 01:10:50 -04:00
Matthew Brown
c569f3932c
Use separate method for parsing docblocks
2019-06-01 18:44:59 -04:00
Matthew Brown
22b6c8120a
Fix spacing issue
2019-06-01 17:22:33 -04:00
Matthew Brown
e7d2a2e0b4
Rewrite docblock param types
2019-06-01 16:46:10 -04:00