1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 02:27:59 +01:00
Commit Graph

137 Commits

Author SHA1 Message Date
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
Brown
a8a2a4cb66 Fix #4210 - fix __invoke declaration tracing 2020-09-19 14:18:52 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
64f08fa9dc Improve Closure::fromCallable handling 2020-08-29 22:02:58 -04:00
Saif Eddin G
5a20092fbd
add pure-callable type (#4066) 2020-08-26 16:51:22 -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
c0b0036109 Fix #3934 - prevent unsafe use of new static 2020-08-05 19:39:27 -04:00
Evgeniy
2c51f47ff6
Fix invalid UndefinedClass using array|callable (#3842)
* Do not treat string array argument as callable if it can be traeted just as string array.

* cs
2020-07-20 04:50:07 -04:00
Brown
37e238a68b Fix tests 2020-07-07 10:41:46 -04:00
Matthew Brown
081a284759 Fix #3567 - remember which variables a callable sets byref in use 2020-06-14 11:58:50 -04:00
Brown
211f014356 Fix #3571 - make callable():void valid for callable():?Foo 2020-06-12 14:26:31 -04:00
Brown
a4aa44494f Fix #3519 - prevent empty callable string 2020-06-04 15:40:53 -04:00
Brown
0cb211784d Fix #3415 - flesh out Closure return type 2020-05-22 14:26:37 -04:00
Brown
4415e0f69c Fix special case calling callable param with string non-global function
Fixes #3411
2020-05-19 15:48:31 -04:00
Brown
a3ae2a713b Fix #3182 - don’t allow unnamespaced string references to functions in same context 2020-04-19 21:21:18 -04:00
Brown
bd2104c5ba Merge with mixed in nested arrays 2020-04-09 09:27:21 -04:00
Matthew Brown
e85d22f004 Fix #3033 - allow __invoke on unions with non-objects 2020-03-28 23:41:05 -04:00
Matthew Brown
f94ab22a5f Be better about strict inference 2020-03-25 09:18:49 -04:00
Brown
ff7fbcda99 Fix #2871 - prevent keyed arrays from being interpreted as callables 2020-02-24 16:19:33 -05:00
Matthew Brown
2829530ea6 Fix #2713 - allow interface with __invoke to be called 2020-01-29 22:33:28 -05:00
Brown
34d73e7243 Fix #2685 - always evaluate $a++ in unknown call 2020-01-24 10:32:28 -05:00
Matthew Brown
2c48d42904 Allow destructuring of callable array
Fixes #2653
2020-01-17 10:02:58 -05:00
Matthew Brown
e68fd02e80 Refine class string after callable array check 2020-01-02 08:31:19 -05:00
Matthew Brown
529efaa29c Fix #2473 - allow array_map to work with callables returning static 2019-12-15 19:55:20 -05:00
Matthew Brown
1a92e98dd3 Warn about more generic callables 2019-12-14 11:55:26 -05:00
Matthew Brown
a179076de5 Break apart callabletest 2019-11-29 23:46:21 -05:00
Matthew Brown
a154191922 Fix #2380 - prevent string docblock for callable param 2019-11-27 09:18:47 -05:00
Matthew Brown
d1fbd1fa26 Add working arrow-functions implementation 2019-11-26 23:52:26 -05:00
Matthew Brown
3d9c94e29a Fix #2363 - catch possible class not found errors when getting method 2019-11-21 08:56:47 -05:00
Brown
658f86c277 Fix #2324 - avoid fatal error on self string in callable 2019-11-11 14:59:05 -05:00
Matthew Brown
9115ffd237 Fix #2215 - refine closure type if it doesn’t clash 2019-10-15 20:34:41 -04:00
Brown
6423a5e68a Fix #2145 - complain make byref params passed to closures mixed afterwards 2019-09-16 18:42:44 -04:00
Matthew Brown
da1f36b57f Fix #2089 - properly coerce arguments 2019-09-01 10:10:38 -04:00
Matthew Brown
5d94e340ee Remove unused suppressions in tests 2019-08-18 15:34:32 -04:00
Brown
236a7ffd15 Fix #2027 - fix improperly retained callable check 2019-08-16 10:32:03 -04:00
Brown
669b50e8b4 Fix erroneous callable parsing 2019-08-12 15:04:43 -04:00
Bruce Weirdan
e0a59ce117 Fixed PHP 7.4 related issues (#1957)
- s/fn/f/g (fn is a reserved keyword in 7.4)
- ReflectionType::__toString() warning (this method is deprecated in 7.4)

Note that some issues are caused by `phpspec/propecy` code and will be
fixed when phpspec/propecy#432 lands. Most were caused by
`ReflectionType::__toString()` usage in
`Psalm\Internal\Codebase\Reflection` though.
2019-07-18 23:36:39 -04:00
Matthew Brown
da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00
Brown
ac06ea659e Fix #1825 - improve behaviour of callable reconciliation 2019-06-20 19:46:42 -04:00
Matthew Brown
a553adb232 Fix test array spacing 2019-06-16 09:42:34 -04:00
Brown
f227af83c0 Allow mixed callable params to be valid 2019-04-24 12:54:35 -04:00
Matthew Brown
ea20a2bd04 Fix #1540 - use correct comparison for callable param types 2019-04-12 00:44:10 -04:00
Matthew Brown
c772914910 Add some formatting 2019-03-23 14:27:54 -04:00
Brown
85f34f2aca Add defining class and increas string length 2019-03-12 12:58:04 -04:00
Brown
e22f216a5b Allow callable|array to be coerced to an array 2019-03-11 11:39:33 -04:00
bugreportuser
57a4522ee7 Flesh out callable arg types 2019-03-07 23:24:50 -05:00
Brown
a8ea907d6c Fix #1432 - allow callable to be coerced to callable-array 2019-03-06 18:24:59 -05:00
Brown
ae69695f89 Prevent tests in PHP 7.1 2019-03-05 18:27:25 -05:00
Brown
cece1def30 Fix #1427 - allow extended methods to be used as callables 2019-03-05 18:02:42 -05:00
Bruce Weirdan
9bdc9f774f More provider typing 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
Matthew Brown
cd2eb3edb9 Fix #1361 - flesh out array map return type before using 2019-02-19 01:25:36 -05:00
Matthew Brown
40a91eab6e Fix #1339 - no crash when using self/static/parent in closure 2019-02-17 13:14:59 -05:00
Brown
d70e29508f Don’t fatal error when callable class does not exist 2019-02-15 12:02:44 -05:00
Matthew Brown
8bcb3a76e7 Add callable class 2019-02-11 01:57:28 -05:00
Matthew Brown
c58100e3af Fix #1313 - don’t allow mixed function calls 2019-02-10 16:15:52 -05:00
Matthew Brown
509709d6bc Fix #1267 - flesh out self static property types 2019-02-01 08:59:01 -05:00
Matthew Brown
79544eb289 Fix comment analysis for callable(): returntype 2019-02-01 07:50:48 -05:00
Brown
661c7ee707 Fix #1256 - detect illegal closure use 2019-01-30 11:36:21 -05:00
Brown
59baa53b3d Fix #1229 - only check for inheritance if class exists 2019-01-23 13:02:07 -05:00
Matthew Brown
1c5f6963a6 Skip callable tests for PHP 7 2019-01-21 18:01:15 -05:00
Matthew Brown
5cc3fe6b67 Fix #760 - coerce __invoke method to closure 2019-01-21 17:08:12 -05:00
Matthew Brown
590bea305d Fix #1218 - find issues with bad callables 2019-01-19 19:49:58 -05:00
Matthew Brown
bf8f76671b Don’t crash when suppressing UndefinedClass with bad params 2019-01-05 12:59:12 -05:00
Matthew Brown
e5559e3012 Allow callables to be plain objects, and vice versa
Previously Psalm required they be *known* objects
2019-01-04 08:04:26 -05:00
Matthew Brown
f0969cb3bb Fix getId calls on callable return types
Ref #1119
2018-12-08 14:10:06 -05:00
Matthew Brown
4688b25fd9 Move internal classes to own namespace 2018-11-12 11:20:59 -05:00
Brown
e6cf9e96df Add support for class concats when checking for callables 2018-10-17 13:22:57 -04:00
Matt Brown
dce8d14e1b Fix syntax errors in tests 2018-09-17 12:15:45 -04:00
Matt Brown
6542a0a784 Fix #810 - convert void array map return to null 2018-06-11 17:00:26 -04:00
Matt Brown
d35a3996fa Fix #811 - improve handling of closure vars 2018-06-11 16:54:20 -04:00
Matthew Brown
3a3c10d044 Improve handling of ? before type 2018-06-08 23:54:07 -04:00
Matthew Brown
62486c1adb Fix #772 - allow closures to be defined on a single line 2018-05-25 18:42:39 +01:00
Matthew Brown
7bc426268a Only run test in PHP 7.1 2018-05-20 13:20:15 -04:00
Matthew Brown
cdcba6152d Add ability to infer return type for method calls 2018-05-20 12:47:26 -04:00
Matthew Brown
e50ef8bf03 Support __invoke return types 2018-05-08 19:49:25 -04:00
Matt Brown
4f678f5f99 Fix bad comparisons 2018-05-08 17:42:02 -04:00
Matthew Brown
1d6e75b06e Fix #662 - allow callable void return types to be widened 2018-04-11 20:29:16 -04:00
Matt Brown
fe46e4e63d Make tests a bit more specific 2018-04-10 15:47:04 -04:00
Matt Brown
fe033f1b6c Fix #663 - infer array return types for closures 2018-04-10 13:05:31 -04:00
Matthew Brown
5915718013 Fix #660 - always refer closure types 2018-04-09 22:00:36 -04:00
Matthew Brown
7e3a1ec9c3 Add support for checking callable/closure param types
Fixes #580
2018-04-08 12:03:35 -04:00
Matthew Brown
797cab22f8 Fix support for Closure(int):int annotation 2018-04-08 10:02:41 -04:00
Matthew Brown
44cccb5b3d Fix build 2018-03-27 01:05:11 -04:00
Matthew Brown
fb802540d6 Fix variadic format cc @TysonAndre and allow callable param types
Ref #580
2018-03-27 00:12:41 -04:00
Matthew Brown
49820b06dd Prevent variadic args disrupting required closure param count 2018-03-21 09:04:07 -04:00
Matt Brown
24490aac0e Fix #609 - fix callable coercion in reconciliation step 2018-03-20 13:24:16 -04:00