Skip to content

Add regression test for #11507 - #6747

Open
HawkForge wants to merge 1 commit into
phpstan:2.3.xfrom
HawkForge:test/bug-11507
Open

HawkForge wants to merge 1 commit into
phpstan:2.3.xfrom
HawkForge:test/bug-11507

Conversation

@HawkForge

Copy link
Copy Markdown
Contributor

Adds a regression test for #11507, reported by @liamduckett. The reproducer from the issue (a Collection::map() callback that sets $item['foo'] on a non-empty-array<string, string>) no longer reports "Function foo() should return Collection<int, non-empty-array<string, string>> but returns Collection<int, non-empty-array<string, string>>" since the bidirectional type narrowing work landed in 2.3.x. The test fails on 2.2.17 with exactly that error and passes on 2.3.x.

Closes phpstan/phpstan#11507

@staabm staabm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one of the reproducers of the referenced issue is fixed. therefore this PR does not close the issue.


declare(strict_types = 1);

namespace Bug11507;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems this snippet was adopted and does not reflect 1:1 the reported reproducer of phpstan/phpstan#11507 (comment) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type mismatch when explicitly setting an array key

2 participants