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

89 Commits

Author SHA1 Message Date
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
34000ca90d Fixes 2022-10-16 13:59:15 +02:00
748a74bb2c Merge remote-tracking branch 'origin/4.x' into HEAD 2022-10-16 13:41:27 +02:00
Vincent Langlet
6bc714c867 Add support for callable in array_reduce 2022-08-24 16:04:22 +02:00
someniatko
be02e7e5c7 #8363 - support static as a type parameter in return types of the first-class callables 2022-08-04 17:16:06 +03:00
someniatko
f3d67845c5 #8363 - ensure we recognize inherited static methods for the first-class callables 2022-08-04 17:01:42 +03:00
kkmuffme
d2be169ce5 update tests 2022-08-03 20:12:18 +02:00
orklah
2f3c150690 merge fixes 2022-02-26 21:28:15 +01:00
orklah
0fe6eaf5d9 Merge remote-tracking branch 'upstream/4.x' into upstream-master13 2022-02-26 21:26:59 +01:00
Aaron Piotrowski
97b5685f55
Fix first-class callable in loop 2022-02-21 18:37:20 -06:00
Bruce Weirdan
11e60fa261
Merge branch '4.x' into upstream-master 2022-02-11 03:51:48 +02:00
orklah
5a19d42dab fix test 2022-01-31 21:51:31 +01:00
orklah
a598efb4ab Handle first class callable on unknown functions 2022-01-31 21:36:01 +01:00
orklah
7c4f08067b Merge remote-tracking branch 'upstream/4.x' into upstream-master5 2022-01-23 23:44:04 +01:00
orklah
a7b72b865f remove TPositiveInt usage for TIntRange 2022-01-23 22:04:18 +01:00
orklah
0e891f25ad refactor description of types in Atomic 2022-01-22 19:34:57 +01:00
orklah
997d5d5f5f handle two more cases of firstClassCallable 2022-01-22 17:37:35 +01:00
orklah
d2faa5b94f fix errors after merge 2022-01-14 21:13:34 +01:00
orklah
b633619a2c Merge remote-tracking branch 'upstream/4.x' into upstream-master 2022-01-14 21:01:25 +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
Bruce Weirdan
762ef8dab4
Merge branch '4.x' into upstream-master 2022-01-07 08:44:32 +02:00
orklah
cbb0c6398f allow short closure with never 2022-01-06 21:36:34 +01:00
Bruce Weirdan
fe036d4db0
Prevent crashes on array_map(...)
Fixes vimeo/psalm#7305
2022-01-06 10:38:58 +02:00
Bruce Weirdan
cf962eebc2
Promote conditional tests to always-running 2022-01-04 11:40:55 +02:00
Aaron Piotrowski
e23a915bb1
Fix first-class callables when used with magic method, built-in, or undefined methods
Closes #7196.
2021-12-27 14:29:33 -06:00
Matthew Brown
89a1c5acbc Fix faulty comparison with typed closure 2021-12-16 16:39:08 +00:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
Aaron Piotrowski
1f3a37ff02
Add support for first-class callables 2021-12-09 10:54:49 -06:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
Bruce Weirdan
6bd7f5b867
Forbid template annotation on closures (#5499)
They don't work properly anyway.

Fixes vimeo/psalm#5472
2021-03-29 15:10:04 -04:00
AndrolGenhald
d4590711d6
Fix object-like array keys when combining string and automatic keys (fixes #5427). (#5428)
* Fix object-like array keys (fixes #5427).

* Fix incorrect return types for tests.

* Fix false positive list with literal int key.
2021-03-19 21:44:44 -04:00
orklah
90fd1c5d1f
fix usage of callable with array_map (#5373) 2021-03-12 14:05:22 -05:00
Bruce Weirdan
7138678c63
Allow undefined variable detection in arrow functions (#5343)
Previously Psalm would assume that any variable it sees in the arrow
function body is defined (and mixed, if it's not available in the outer
scope). This prevented undefined variable detection. Dropping that
assumption allows it to work.

Fixes vimeo/psalm#5331
2021-03-11 00:06:23 -05:00
Matt Brown
0624098865 Ensure getId() output can always be parsed as a type
Ref #5105
2021-01-25 23:41:51 -05:00
Matt Brown
4a0e2f543e Fix implicit void closure not getting recognised 2020-12-04 13:16:05 -05:00
Matt Brown
32d526bde9 Add descendant variables for closure uses
Fixes #4522
2020-11-09 15:20:28 -05:00
Brown
f973937aec Fix #4209 - allow hinting arrow function return type 2020-09-19 14:59:19 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
f78fbbe4c9 Fix #4146 - allow null checks on Iterator::current output 2020-09-07 11:40:36 -04:00
Brown
02a58f787b Fix #4148 - add Closure to scanned classes when arrow function is seen 2020-09-07 11:11:01 -04:00
Brown
b5279cd7d4 Fix erroneous Closure::__invoke return type 2020-09-01 12:33:25 -04:00
Brown
efe143a396 Fix #4077 - always track closure purity 2020-08-28 12:42:55 -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
Bruce Weirdan
4dcb7183f5
Fix windows tests (#4040)
* Fix windows tests by not mangling the expectations

* Use platform-dependent directory separator in expected messages

* fix CS
2020-08-22 10:00:36 -04:00
Brown
37e238a68b Fix tests 2020-07-07 10:41:46 -04:00
Brown
21f4deed3b Fix #3268 - infer generator return for closure 2020-04-29 16:52:37 -04:00
Matthew Brown
a179076de5 Break apart callabletest 2019-11-29 23:46:21 -05:00
Matt Brown
24490aac0e Fix #609 - fix callable coercion in reconciliation step 2018-03-20 13:24:16 -04:00
Matthew Brown
b8a8e9bc5b Add two skipped (bug-identifying) tests 2018-03-20 09:30:37 -04:00