1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
Commit Graph

128 Commits

Author SHA1 Message Date
Evan Shaw
86173d29c9 When inside isset, array fetch can return null
This prevents false positive for various types of issues inside empty,
such as RedundantConditionGivenDocblockType and TypeDoesNotContainType.
2024-03-20 02:18:31 +01:00
kkmuffme
c5655c510d Fix param providers for native methods not working Fix array_filter params callable incorrect required params depending on the 3rd argument value (at this commit psalm doesn't report an error, due to https://github.com/vimeo/psalm/issues/8438, which gets fixed by this PR later on though) Fix https://github.com/vimeo/psalm/issues/3047 and further improve types for array_multisort and add errors for invalid params Fix SimpleTypeInferer failing on bitwise operations with constants 2023-11-18 08:55:20 +01:00
kkmuffme
ba79797627 Fix https://github.com/vimeo/psalm/issues/10371 2023-11-18 08:55:20 +01:00
kkmuffme
506fb9c773 Fix https://github.com/vimeo/psalm/issues/8919 2023-11-18 08:55:20 +01:00
kkmuffme
be85cb02b9 remove now invalid test 2023-11-18 08:55:20 +01:00
kkmuffme
f3e9263ea4 Fix array_filter callback type
Fix https://github.com/vimeo/psalm/issues/9068
2023-11-18 08:55:19 +01:00
8078b6dcbf Fixes 2023-04-21 15:58:05 +02:00
WhizSid
782735e8b2 Fixed crash issue when using multiple literals for array_splice 2023-04-19 00:38:35 +05:30
orklah
6834f5dca1
Merge pull request #9651 from tuqqu/array-flip-non-empty-fix
Fix `array_flip` to preserve non-empty array type
2023-04-13 22:54:12 +02:00
tuqqu
d3a21acc24 Fix array_flip to preserve non-empty array type 2023-04-13 22:19:44 +02:00
WhizSid
02f8f11736 Handle empty array possibilities from array_splice 2023-04-13 14:37:09 +05:30
WhizSid
9e5266d6fe Add issue snippet 2023-04-13 01:15:09 +05:30
WhizSid
b19c263fe5 Fixed non empty arg issue in array_splice function 2023-04-13 00:34:29 +05:30
Corey Taylor
730bc221e9 Re-add array_unique() stub which preserved array type 2023-03-28 04:09:50 -05:00
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