1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 18:17:55 +01:00
Commit Graph

114 Commits

Author SHA1 Message Date
orklah
0747b48d06
remove TEmpty 2022-01-03 04:09:59 +02:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
orklah
4755131585 more consistency 2021-10-20 07:32:04 +02:00
Aleksandr Zhuravlev
978d9ec774 Improve handling of positive ints by array_filter() 2021-10-16 20:47:22 +13:00
ElisDN
7b47063585 Add array typed tests 2021-10-15 14:30:20 +03:00
ElisDN
f26e9ae3b1 Add array replace tests 2021-10-15 14:30:20 +03:00
orklah
22fb4b5d19 add test 2021-10-07 11:04:51 +02:00
orklah
b9f14f8687 improve min/max inference, add a return type provider for rand, mt_rand and random_int 2021-10-02 09:53:58 +02:00
Bruce Weirdan
103b2b7244
Warn about array_walk_recursive over objects 2021-08-31 23:18:20 +03:00
Bruce Weirdan
b370ce92aa
Report RawObjectIteration when array_walk is used on objects 2021-08-20 01:43:49 +03:00
Justin
f7a2aaef6e
Update DateTime and DateTimeImmutable signatures
`DateTime::format` and `DateTimeImmutable::format` will always
return a string starting in PHP 8.0.
2021-07-03 04:29:54 -04:00
Bruce Weirdan
6db79be207
Keep generic part of shape on array_map return type
Fixes vimeo/psalm#6038
2021-07-03 06:33:37 +03:00
Ruslan Karimov
79b61c3b61 Added support for self & static keywords in array_reduce callables 2021-06-29 22:27:50 +05:00
Matt Brown
9dde8eed9d Add support for literal-int annotations as well 2021-06-14 23:24:09 -04:00
Matt Brown
3140654a44 Experiment with implode literal tracking 2021-06-14 16:03:37 -04:00
olsavmic
4fb2b65164
Fix ArrayFillReturnTypeProvider - consider second param (#5770)
Add test

Fix
2021-05-14 20:12:39 -04:00
orklah
72022139fa
improve array_splice inference (#5738) 2021-05-10 11:45:52 -04:00
AndrolGenhald
b859fba52d
Fix array spread false negative that crashes (fixes #5431, reverts #2852) (#5432) 2021-03-19 21:51:36 -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
1a3ff5676a
fix stub for array_combine + remove false in PHP8 + improve tests (#5395) 2021-03-16 13:43:49 -04:00
orklah
dd4d970a37
makes array_combine return non-empty-array for most cases (#5393)
* makes array_combine return non-empty-array for most cases

* Add back newline

Co-authored-by: Matthew Brown <github@muglug.com>
2021-03-14 21:18:19 -04:00
Matt Brown
876a772edc Fix #5176 - substitute in actual argument when instance type found 2021-02-08 09:29:41 -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
7ffea7c425 Fix #4917 - allow array_reduce to be called with a single arg 2021-01-06 12:59:51 -05:00
Matt Brown
b64eb6d716 Break out array_key_exists tests 2020-12-02 14:42:16 -05:00
orklah
32bf18dff0
fix array_column with possibly_undefined keys (#4719) 2020-11-27 17:05:54 -05:00
Matt Brown
f43dba8c4c Use more accurate comparison for non-empty-lists 2020-10-28 13:32:55 -04:00
Matt Brown
fee3b63122 Fix #4274 - don’t ignore mixed union in array_shift operation 2020-10-12 15:17:22 -04:00
orklah
7093253eea
fix test on windows (#4225) 2020-09-20 13:00:30 -04:00
Brown
72d1d799b1 Fix #4208 - array with possibly-undefined keys isn‘t really sealed 2020-09-19 15:46:54 -04:00
Brown
0b209864fe Improve accuracy of array_filter 2020-09-14 13:31:53 -04:00
Brown
8d7fe83e2a Improve array_merge return type 2020-09-14 13:06:15 -04:00
ygottschalk
5b0c9b1a28
added array-size max constraint to greater check (#4175)
added a few unit tests
2020-09-12 16:13:13 -04:00
Brown
09d22cb05c Fix #4169 - add appropriate bounds check 2020-09-12 11:33:26 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
92239add4d Add some backwards-incompatible changes for 4.x 2020-08-30 11:44:14 -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
Matthew Brown
5c20a5295e Improve solution to #3964 2020-08-16 13:03:30 -04:00
ygottschalk
f831ebdbcf
narrowed reset and end return type (#3950)
* narrowed `reset` return type
BUT psalm seems to ignore the stub

* narrowed `reset` and `end` return type, this time for real

* fixed UnusedVariable Issue

* fixed RedundantCondition Issue
caused by `end`s return type being more precise

* Improve solution slightly

Co-authored-by: Matthew Brown <github@muglug.com>
2020-08-07 12:23:20 -04:00
Brown
38bfc12b98 Fix array_shift behaviour to be more accurate with lists
Fixes #3941
2020-08-05 12:43:37 -04:00
Matthew Brown
ab64ccab88 Fix #3913 properly 2020-07-31 14:56:29 -04:00
Brown
962265e98e Hopefully final fixes 2020-07-21 23:59:11 -04:00
ygottschalk
de2109234d
fixes wrong return type of key() #3838 (#3839)
* fixes wrong return type of key() #3838
fixed/added tests for key

* fixed test again
2020-07-20 04:49:36 -04:00
Brown
06ee1b71c7 Improve check for empty array 2020-07-15 09:49:30 -04:00
Brown
0ab163fd78 Skip dodgy tests 2020-07-15 01:53:31 -04:00
ygottschalk
94e2552d1c
Fix #3810 removing ignore-nullable-return (#3817)
* Fix #3810 removing ignore-nullable-return form stubs of key, array_key_first, array_key_last

* fixed test failing due to changes to key()

* Improve key return type

* Remove unnecessary check

Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-14 17:43:26 -04:00
Evgeniy
fcd2ac3078
array_column check result non-emptyness (#3813)
* Update

* Update test

* Fix test

* Fix test

* inline function res in test

* cs
2020-07-14 17:13:45 -04:00
Brown
27cb660377 Respect possibly-undefined array keys while merging
Fixes #3393
2020-05-19 20:10:01 -04:00
orklah
478bb267d8
stubs for array_sum (#3395) 2020-05-18 17:23:21 -04:00
Brown
111303d913 Add non-empty-lowercase-string type 2020-05-15 10:18:05 -04:00
Brown
813302206a Improve rendering of tuples 2020-05-11 09:08:53 -04:00
Brown
75761647c2 Fix #3321 - allow interface methods to be mapped 2020-05-08 14:52:53 -04:00
Brown
891c66650b Prevent unintersectable template lower bounds
Ref #3264
2020-04-29 14:57:57 -04:00
Grégoire Paris
1fb1c2195d
Allow non-string keys (#3221)
Although it would be stupid to provide an array with exclusively
non-string keys, it's possible to have an array with a bit of both.

See for instance
155d028be0/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php (L263-L276)
2020-04-27 22:49:07 -04:00
Brown
ddbc1d2763 Yet again fix handling of nested template resolution and comparison 2020-04-18 13:02:55 -04:00
Matthew Brown
ecac9d56c0 Fix #3061 - prevent array_key_exists from completely changing type 2020-04-03 08:05:21 -04:00
Matthew Brown
5b4ed6b516 Fix #2942 - support array_splice properly for numeric-keyed arrays 2020-03-09 01:15:52 -04:00
Matthew Brown
d8b6467b1a Fix #2852 - no duplicatearraykey warning for non string-keyed arrays 2020-02-21 01:27:42 -05:00
Matthew Brown
5f4d797fe1 Fix #2772 - add support for multiple array_map function param inference 2020-02-08 12:17:57 -05:00
Brown
66227f9b7f Fix #2727 - callable arg checks should obey ignore_falsable_return 2020-01-31 13:58:56 -05:00
Brown
3d6c63bc08 Break apart FunctionCallTest 2020-01-31 13:58:02 -05:00