Skip to content

Conversation

@canvural
Copy link
Contributor

PHPStan didn't seem to have support for unpacking string keyed arrays: https://phpstan.org/r/e187af75-320b-4fa6-ba5a-54ceec396f42

This PR adds it only for PHP 8.1 and above.

I think my implementation may not be the best (especially the $hasStringKey hackery), feel free to override it or I'd be happy to change it according to suggestions 👍🏽

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Hi, I think the else branch is still wrong, right?

} else {
	$arrayBuilder->degradeToGeneralArray();
	$arrayBuilder->setOffsetValueType(new IntegerType(), $valueType->getIterableValueType());
}

@canvural
Copy link
Contributor Author

Hi, I think the else branch is still wrong, right?

} else {
	$arrayBuilder->degradeToGeneralArray();
	$arrayBuilder->setOffsetValueType(new IntegerType(), $valueType->getIterableValueType());
}

Are you saying this should also apply to the else branch for not ConstantArrayType?

@canvural canvural force-pushed the array-unpack-string-keys branch 2 times, most recently from 5d23a2e to ed7ad43 Compare November 29, 2021 22:16
@canvural canvural force-pushed the array-unpack-string-keys branch from ed7ad43 to 2f01813 Compare December 13, 2021 18:25
@ondrejmirtes
Copy link
Member

Thank you!

@canvural canvural deleted the array-unpack-string-keys branch March 28, 2022 12:50
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.

2 participants