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

113 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
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
orklah
0e891f25ad refactor description of types in Atomic 2022-01-22 19:34:57 +01:00
orklah
eb53f7e99c fix tests 2022-01-20 22:18:03 +01:00
orklah
6f1a5e8a47
Merge pull request #7417 from klimick/partially-applied-closure-inference
Contextual type inference for high order function arg
2022-01-20 21:03:46 +01:00
adrew
7e623ed48e Upcast invokable to callable during hof arg analysis 2022-01-19 00:37:05 +03:00
adrew
379d0d6c49 Add tests 2022-01-18 18:54:47 +03:00
adrew
3886d5b4c6 Add test for high order function arg inference in class context 2022-01-18 13:12:13 +03:00
adrew
fac7115eae Add simple test for high order function arg inference 2022-01-18 12:48:53 +03:00
adrew
00ce1107d3 Infer partially applied closure arg by previous function arg 2022-01-18 03:02:21 +03: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
Fabien Villepinte
b9d8dd9d3f
Fix analysis when __invoke() exists 2022-01-06 21:22:18 +01:00
Matthew Brown
b419c299e3
Use InvalidScalarArgument only when we can be sure PHP attempts coercion 2022-01-02 14:56:18 +02:00
adrew
87deb19a87 Remove dead code from test 2021-12-27 19:43:06 +03:00
adrew
c0ca383020 Contextual inference for closure param types 2021-12-27 19:35:37 +03:00
adrew
3d212c642c
Add test for mismatch param type from docblock 2021-12-27 00:45:26 +02:00
adrew
d6d0fc6704
Remove undefined variables 2021-12-27 00:45:25 +02:00
adrew
2e4d75d6bd
Fix closure param type inference in generic context 2021-12-27 00:45:22 +02:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
adrew
a8d23538b7 Fix closure param type inference with named params 2021-12-12 13:17:15 +03:00
adrew
603e1c944b Fix type inference of closure params 2021-12-11 23:00:18 +03:00
adrew
989c3ada2e Fix type inference of closure params 2021-12-11 22:51:18 +03:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
orklah
7c6b86cef3 suppress error and add test 2021-11-23 20:04:52 +01: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
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