Skip to content

Fix "Parameter X of array_values is already a list, call has no effect"-false positive#5271

Merged
staabm merged 4 commits intophpstan:2.1.xfrom
staabm:fix13629
Mar 22, 2026
Merged

Fix "Parameter X of array_values is already a list, call has no effect"-false positive#5271
staabm merged 4 commits intophpstan:2.1.xfrom
staabm:fix13629

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Mar 21, 2026

@staabm staabm changed the base branch from 2.2.x to 2.1.x March 21, 2026 13:43
@phpstan-bot
Copy link
Collaborator

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.

@staabm
Copy link
Contributor Author

staabm commented Mar 21, 2026

integration test failures are unrelated -> phpstan/phpstan#14334

@staabm staabm marked this pull request as ready for review March 21, 2026 13:57
@staabm staabm requested a review from VincentLanglet March 21, 2026 13:57
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

}

if ($this->isList()->yes() && $this->getIterableValueType()->isArray()->yes()) {
if (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to change too many array related stuff atm - I don't want make ondrejs' work harder than necessary.

if (
$this->isList()->yes()
&& $offsetType !== null
&& $offsetType->isInteger()->yes()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be toArrayKey() ?

}

if ($this->isList()->yes() && $this->getIterableValueType()->isArray()->yes()) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

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

@staabm staabm merged commit b7eca59 into phpstan:2.1.x Mar 22, 2026
650 of 652 checks passed
@staabm staabm deleted the fix13629 branch March 22, 2026 21:25
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.

False report for 2.1.30 release "arrayValues.list" ("Parameter X of array_values is already a list, call has no effect")

3 participants