Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Nov 23, 2024

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

$itemType = $type->getIterableValueType();
if ($itemType instanceof ArrayType) {
++$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