Marco Pivetta
e6600fea21
Better type inference and type checking for large union types used in array keys/values
...
Fixes #8983
This patch adds a basic test showing that, when reaching a union type with 30 elements
or more, Psalm used to fail with an error, because the large union type got simplified
into a more general type as part of performance optimizations done in `TypeCombiner::combine()`.
This means that a type like `array<1|2|3|(etcetera...)|100, mixed>` was internally
simplified to `array<int, mixed>`, after reaching 30 elements or more, which in turn
led to problems and confusing errors when large union types are in play.
Such union types are relatively common in lookup-table-alike value objects.
By removing the hardcoded call-time limit of `30` types to be combined, we hereby
rely on the default `TypeCombiner::combine()` limit of `500` items, which is more
healthy.
This may come with some performance implications, but it is worth trying out, for
now.
Further parameters passed to `TypeCombiner::combine()` that were already matching
parameter default values were also omitted from the call-sites.
2022-12-29 10:05:23 +01:00
825f46f9dc
Fix test
2022-12-19 22:23:31 +01:00
ab2692fdd3
Update
2022-12-19 18:31:43 +01:00
ec11254316
Update
2022-12-19 14:27:41 +01:00
e923229204
Fix array_merge
2022-12-19 14:01:00 +01:00
326ba91812
Update
2022-12-19 13:49:42 +01:00
Jack Worman
1c19260cdd
Require trailing commas
2022-12-18 13:20:31 -06:00
c454a181cc
Fixes
2022-12-18 15:00:15 +01:00
098d5020d0
array_merge_recursive
2022-12-18 14:52:44 +01:00
1dd062a810
Fix #2481
2022-12-18 14:50:51 +01:00
b83226a0db
More array_merge improvements
2022-12-18 14:37:19 +01:00
992f26a8e7
Fix array_merge edge case
2022-12-16 18:10:46 +01:00
Jack Worman
643542346b
Add codesniffer rules and expand php-cs-fixer to bin and test
2022-12-14 13:29:09 -06:00
6347a21546
Literal inferring for array_column, array_combine, array_fill_keys, array_fill ( #8850 )
...
* Squash
* Remove BC break
* Suppress
* Possibly fix
* Fixes
* Fix test
* Implement literal array_column
* Improve array_column inference
* Improve logic
* Add array_combine return type provider
* Cleanup
* Fix #8868 (add array_fill_keys/array_fill return type)
* cs-fix
* Fix
2022-12-13 22:29:35 +01:00
cca276768e
List refactoring v5 ( #8820 )
...
* Squash
* Remove BC break
* Suppress
* Possibly fix
* Fixes
* Fix test
* Trigger build
* Update psl
* Update psl
* Fixes
* Fixes
* Cleanup
* fix
* Fix build
* Do not consider never when getting the max count
* Add assertion
* Cleanup
* Fix
* Cleanup
2022-12-13 21:40:19 +01:00
orklah
433e272149
Merge pull request #8809 from danog/fix_8806
...
Fix #8806
2022-12-01 21:00:40 +01:00
7f15d47c19
Add tests
2022-12-01 20:14:37 +01:00
orklah
2da4bf98d6
add test
2022-11-30 23:45:55 +01:00
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
Bruce Weirdan
80750fd579
Implement subtype checks for stringable-object
2022-11-10 19:55:36 -04: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
Maximilian Bösing
7f35bff0d9
feature: enhance type detection for internal php functions key
, current
, end
and reset
...
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-10-17 20:24:40 +02:00
748a74bb2c
Merge remote-tracking branch 'origin/4.x' into HEAD
2022-10-16 13:41:27 +02:00
kkmuffme
5c39e66b15
fix tests
2022-09-15 19:38:51 +02:00
Bruce Weirdan
de49946e4d
Update empty list/array notation
2022-05-28 16:19:49 -04:00
Bruce Weirdan
e0acf22e40
Merge branch '4.x' into update-master
2022-05-28 14:49:12 -04:00
hirokinoue
e7005245b8
add test case for implode()
2022-05-14 23:36:51 +09:00
hirokinoue
4bb5c38eb6
add test case for usort()
2022-04-29 00:52:37 +09:00
hirokinoue
139948e774
add test case for uksort()
2022-04-29 00:33:08 +09:00
hirokinoue
d4470cc99e
add test case for uasort()
2022-04-29 00:18:27 +09:00
hirokinoue
c7b9e1eebb
add test case for shuffle()
2022-04-28 23:18:39 +09:00
hirokinoue
db565f1d32
add test case for rsort()
2022-04-28 23:05:33 +09:00
Matt Brown
9cc2af56b4
Support Stringable before PhpToken autoloading
2022-04-27 01:36:17 -04:00
hirokinoue
3a6ebbb8ff
add test case for sort()
2022-04-24 01:00:38 +09:00
hirokinoue
63faa0c919
test the correct function
2022-04-24 00:54:58 +09:00
Mateusz Cholewka
cd1b155f53
test if the type of second argument is not uncertain
2022-03-07 14:10:03 +01:00
Mateusz Cholewka
70abbbee01
refactor array column test
...
add one more test when index key not exist in array
reorganise samples to keep all similar together
2022-03-06 15:45:22 +01:00
Mateusz Cholewka
d48965d929
add failing test
2022-03-06 14:09:07 +01:00
orklah
9168cef2d4
Merge remote-tracking branch 'upstream/4.x' into upstream-master6
2022-01-26 21:06:25 +01:00
ElisDN
9f01c16ae9
Fix array_replace type
2022-01-25 15:22:50 +03:00
orklah
0e891f25ad
refactor description of types in Atomic
2022-01-22 19:34:57 +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
orklah
52ae26f143
fix test
2022-01-09 15:53:43 +01:00
orklah
65efab3a8d
keep class-strings through array_merge
2022-01-09 15:48:58 +01:00
Matthew Brown
83911c7408
Remove unnecessary references to empty in TypeCombiner
2022-01-03 04:10:41 +02:00