Fix "Parameter X of array_values is already a list, call has no effect"-false positive#5271
Fix "Parameter X of array_values is already a list, call has no effect"-false positive#5271staabm merged 4 commits intophpstan:2.1.xfrom
Conversation
…t"-false positive
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
|
integration test failures are unrelated -> phpstan/phpstan#14334 |
|
This pull request has been marked as ready for review. |
| } | ||
|
|
||
| if ($this->isList()->yes() && $this->getIterableValueType()->isArray()->yes()) { | ||
| if ( |
There was a problem hiding this comment.
In the long term, this IF should not be here I think.
it feels like a workaround from a time in which setExistingOffsetValueType did not yet exist.
There was a problem hiding this comment.
Should we try removing this if and find the right place to fix ?
Cause setting an Int key to a List shouldnt always keep the list
There was a problem hiding this comment.
I don't want to change too many array related stuff atm - I don't want make ondrejs' work harder than necessary.
src/Type/IntersectionType.php
Outdated
| if ( | ||
| $this->isList()->yes() | ||
| && $offsetType !== null | ||
| && $offsetType->isInteger()->yes() |
There was a problem hiding this comment.
Should it be toArrayKey() ?
| } | ||
|
|
||
| if ($this->isList()->yes() && $this->getIterableValueType()->isArray()->yes()) { | ||
| if ( |
There was a problem hiding this comment.
Should we try removing this if and find the right place to fix ?
Cause setting an Int key to a List shouldnt always keep the list
closes phpstan/phpstan#13629