Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array unpacking support for string-keyed arrays #803

Merged
merged 1 commit into from
Dec 28, 2021

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
@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
2 participants