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

226 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
9be7fceb59 Fix literal string keys int not handled as int as PHP does
Fix https://github.com/vimeo/psalm/issues/8680
See also https://github.com/vimeo/psalm/issues/9295
2023-12-13 00:24:50 +01:00
kkmuffme
82ff582280 add error for invalid array key type in docblock 2023-12-13 00:23:14 +01:00
orklah
f4e9837e27
Merge pull request #10450 from nicelocal/fix_class_string_key
Fix shaped array class string key combination
2023-12-07 17:52:15 +01:00
576ecd66e6 Fix #10460 2023-12-07 17:29:22 +01:00
0d3485b588 Commit just first part of fix for now 2023-12-07 13:04:59 +01:00
76458e0b50 Add test 2023-12-06 14:52:54 +01:00
4ed0fe934f Fix shaped array class string key combination 2023-12-06 14:12:19 +01:00
ab3a17b7b0 Fix 2023-12-01 16:11:14 +01:00
2e249ab3fa Create keyed arrays when assigning literal union keys 2023-12-01 16:03:08 +01:00
kkmuffme
0252bbbd7c Fixed https://psalm.dev/r/7f112fd745 - MethodComparator only reported an error for this if the parent class was user defined (= not in stubs), which is wrong, since this will cause a fatal error when running the code 2023-11-18 08:55:20 +01:00
Maximilian Bösing
7f8ec79243
qa: modify tests since array keys are not mixed for ArrayObject
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-09-10 16:06:56 +02:00
8078b6dcbf Fixes 2023-04-21 15:58:05 +02:00
Maximilian Bösing
10e7299501
qa: add failing test for issue #8787
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-04-10 02:43:31 +02:00
Jack Worman
1c19260cdd Require trailing commas 2022-12-18 13:20:31 -06:00
Jack Worman
643542346b Add codesniffer rules and expand php-cs-fixer to bin and test 2022-12-14 13:29:09 -06: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
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
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
orklah
7c4228fb56
Merge pull request #8324 from Nicelocal/fix_union_assertions
Fix union assertions
2022-07-28 19:06:14 +02:00
09fb879428
Fix #8322, #8319 2022-07-27 17:42:48 +02:00
AndrolGenhald
ee68184527 Fix key comparison when unpacking Traversables. 2022-07-26 12:00:05 -05:00
AndrolGenhald
d54eebfe02 Fix various array spread issues.
- Correctly infer `array` and `list` instead of `non-empty-array` and `non-empty-list` (fixes #7296)
 - Add support for spreading string keys (fixes #7297).
 - Show issue when trying to unpack non-iterable
 - Show issue when trying to unpack iterable with non-array-key key
 - Re-added invalid PHP 8.0 tests removed in #6613
 - Unpacked lists with known keys will be inferred as eg `array{0: int, 1: int}<int<0, max>, int>` now but will still be treated as lists
 - Unpacked arrays with known keys will now be inferred as eg `array{a: string, b: string}<int, int>` instead of `array<int|string, int|string>`
2022-07-26 12:00:03 -05:00
AndrolGenhald
285740a753 Merge branch '4.x' 2022-07-07 15:01:38 -05:00
Bruce Weirdan
4e59398f77
Coerce null to empty string in array keys
Fixes vimeo/psalm#8063

Alters the fix for vimeo/psalm#2165 (1a48be8e9c)

/cc: @iluuu1994, @muglug
2022-06-06 17:41:42 -04:00
Matt Brown
fccc366c1e Merge pull request #7887 from ging-dev/lsp-fixes
improve LSP
2022-04-27 10:13:17 -04:00
Matt Brown
0c65a19554 Allow null to ArrayAccess::offsetSet $offset param 2022-04-27 01:34:09 -04:00
Fran Moreno
ff195e76c9
Allow null to ArrayAccess::offsetSet $offset param 2022-03-06 13:47:32 +01:00
8d0c1c62e8
Ensure all template parameters are specified in classes, interfaces, traits 2022-01-31 10:06:31 +01:00
orklah
0592c03cda fix issues resulting from previous commit 2022-01-30 16:05:38 +01:00
AndrolGenhald
558208e44e Add type checking for class const assignments, fix several other const issues. 2022-01-22 17:06:54 -06: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
ab60d311c2
Merge pull request #7188 from vimeo/muglug-use-invalidscalarargument-less 2022-01-03 06:04:42 +02:00
orklah
d912663da4
remove isEmpty 2022-01-03 04:10:41 +02:00
orklah
0747b48d06
remove TEmpty 2022-01-03 04:09:59 +02:00
Matthew Brown
b419c299e3
Use InvalidScalarArgument only when we can be sure PHP attempts coercion 2022-01-02 14:56:18 +02:00
546438bec1
Another small fix 2021-12-30 12:05:03 +01:00
ff7abec2bd
Fix tests 2021-12-30 12:01:25 +01:00
orklah
cc618bc916 allow successful destructuring to also be null if the source was nullable 2021-12-20 22:48:27 +01:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
orklah
574c8f74dd fix test 2021-12-07 19:48:37 +01:00
orklah
c17af4128e don't stop analyzing array, even if we already have a type and we can't create an object like 2021-12-07 19:38:52 +01:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
ralila
245920e53c Import instead of using fqn 2021-12-03 20:11:20 +01:00
1129ab1475
Raise RedundantCast when using array_values on a list 2021-11-26 21:47:14 +01:00
orklah
c96be1f68e fix tests 2021-10-13 11:47:57 +02:00
orklah
758acccb91 fix tests 2021-10-13 11:43:17 +02:00