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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize PHPStan Type interface in TypeNormalizer #6478

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Nov 23, 2024

I think this fixes the root cause of rectorphp/rector#8907

++$arrayNesting;
$this->normalizeArrayOfUnionToUnionArray($type->getItemType(), $arrayNesting);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the root cause is that we call getItemType which is not defined in Type, therefore will crash depending on the used type

} elseif ($type->getItemType() instanceof UnionType) {
$this->collectNestedArrayTypeFromUnionType($type->getItemType(), $arrayNesting);
$this->normalizeArrayOfUnionToUnionArray($itemType, $arrayNesting);
} elseif ($itemType instanceof UnionType) {
Copy link
Member

Choose a reason for hiding this comment

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

this can be IntersectionType, see PR patch that happen on downgrade:

due to downgrade error:

until we have more fixture tests, I think we can keep using strict ArrayType and ConstantArrayType to avoid regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, lets do it less aggressive: #6479

@samsonasik
Copy link
Member

let's close in favor of #6479

@samsonasik samsonasik closed this Nov 23, 2024
@staabm staabm deleted the fix branch November 23, 2024 09:23
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