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

171 Commits

Author SHA1 Message Date
Matthew Brown
8d36bdc3ed
Make array shapes strict by default (#8701)
* Make array shapes strict by default

* Fix PSL tests
2022-11-11 20:14:21 -05:00
65d6a469b6 Fix tests 2022-11-08 10:45:21 +01:00
68a5511057 Merge remote-tracking branch 'origin/4.x' into HEAD 2022-11-08 10:25:04 +01:00
1986c8b4a8
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists (#8395)
* Immutable CodeLocation

* Remove excess clones

* Remove external clones

* Remove leftover clones

* Fix final clone issue

* Immutable storages

* Refactoring

* Fixes

* Fixes

* Fix

* Fix

* Fixes

* Simplify

* Fixes

* Fix

* Fixes

* Update

* Fix

* Cache global types

* Fix

* Update

* Update

* Fixes

* Fixes

* Refactor

* Fixes

* Fix

* Fix

* More caching

* Fix

* Fix

* Update

* Update

* Fix

* Fixes

* Update

* Refactor

* Update

* Fixes

* Break one more test

* Fix

* FIx

* Fix

* Fix

* Fix

* Fix

* Improve performance and readability

* Equivalent logic

* Fixes

* Revert

* Revert "Revert"

This reverts commit f9175100c8452c80559234200663fd4c4f4dd889.

* Fix

* Fix reference bug

* Make default TypeVisitor immutable

* Bugfix

* Remove clones

* Partial refactoring

* Refactoring

* Fixes

* Fix

* Fixes

* Fixes

* cs-fix

* Fix final bugs

* Add test

* Misc fixes

* Update

* Fixes

* Experiment with removing different property

* revert "Experiment with removing different property"

This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9.

* Uniform naming

* Uniform naming

* Hack hotfix

* Clean up $_FILES ref #8621

* Undo hack, try fixing properly

* Helper method

* Remove redundant call

* Partially fix bugs

* Cleanup

* Change defaults

* Fix bug

* Fix (?, hope this doesn't break anything else)

* cs-fix

* Review fixes

* Bugfix

* Bugfix

* Improve logic

* Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389)

* Default to sealed arrays

* Fix array_merge bug

* Fixes

* Fix

* Sealed type checks

* Properly infer properties-of and get_object_vars on final classes

* Fix array_map zipping

* Fix tests

* Fixes

* Fixes

* Fix more stuff

* Recursively resolve type aliases

* Fix typo

* Fixes

* Fix array_is_list assertion on keyed array

* Add BC docs

* Fixes

* fix

* Update

* Update

* Update

* Update

* Seal arrays with count assertions

* Fix #8528

* Fix

* Update

* Improve sealed array foreach logic

* get_object_vars on template properties

* Fix sealed array assertion reconciler logic

* Improved reconciler

* Add tests

* Single source of truth for test types

* Fix tests

* Fixup tests

* Fixup tests

* Fixup tests

* Update

* Fix tests

* Fix tests

* Final fixes

* Fixes

* Use list syntax only when needed

* Fix tests

* Cs-fix

* Update docs

* Update docs

* Update docs

* Update docs

* Update docs

* Document missing types

* Update docs

* Improve class-string-map docs

* Update

* Update

* I love working on psalm :)

* Keep arrays unsealed by default

* Fixup tests

* Fix syntax mistake

* cs-fix

* Fix typo

* Re-import missing types

* Keep strict types only in return types

* argc/argv fixes

* argc/argv fixes

* Fix test

* Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
Vincent Langlet
fbaf6afb30 Try 2022-11-03 18:11:01 +01:00
Vincent Langlet
b2f095f1b8 Add tests 2022-11-03 14:39:48 +01:00
Vincent Langlet
4a27322144 serialize is not pure for array of object 2022-11-03 11:48:33 +01:00
Vincent Langlet
ef0a17ee11 Do not report serialize as unused 2022-11-02 22:52:42 +01:00
8d0c1c62e8
Ensure all template parameters are specified in classes, interfaces, traits 2022-01-31 10:06:31 +01:00
orklah
af1888b631 Merge remote-tracking branch 'upstream/4.x' into upstream-master4 2022-01-22 17:48:42 +01:00
orklah
52a7f0694e drop compatibility aliases 2022-01-19 19:29:16 +01:00
Matthew Brown
b49682a485 Simplify issue suppression in tests 2022-01-13 14:38:17 -05:00
Matthew Brown
f439d6550b
Ensure that all entries in test arrays have explicit keys (#7386)
* Transformation that updates assertions

* Simplify transformation

* Ensure that all tests have keys

* Fix a few remaining keys
2022-01-13 13:49:37 -05:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
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