Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/acceptance/Collections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,28 @@ Feature: Collections

@Collections::ArrayAccess
Scenario: Adding an item using wrong key type with array offset access [Psalm 5]
Given I have the following code
"""
/** @var Collection<int,string> */
$c = new ArrayCollection(["a", "b", "c"]);
$c["10"] = "aaa";
"""
And I have Psalm newer than "7.12.99" (because of "an assignment no longer reads the offset")
When I run Psalm
Then I see these errors
| Type | Message |
| InvalidArgument | Argument 1 of Doctrine\Common\Collections\Collection::offsetSet expects int\|null, but '10' provided |
And I see no other errors

Scenario: Adding an item using wrong key type with array offset access, also read before Psalm 7.13 [Psalm 5]
Given I have the following code
"""
/** @var Collection<int,string> */
$c = new ArrayCollection(["a", "b", "c"]);
$c["10"] = "aaa";
"""
And I have Psalm newer than "4.99" (because of "changed issue type")
And I have Psalm older than "7.13" (because of "an assignment no longer reads the offset")
When I run Psalm
Then I see these errors
| Type | Message |
Expand Down