[TypeDeclaration] Handle Union with array type on ReturnUnionTypeRector#5144
Merged
samsonasik merged 2 commits intomainfrom Oct 8, 2023
Merged
[TypeDeclaration] Handle Union with array type on ReturnUnionTypeRector#5144samsonasik merged 2 commits intomainfrom
samsonasik merged 2 commits intomainfrom
Conversation
Member
Author
|
The bug seems on rector-src/rules/TypeDeclaration/TypeNormalizer.php Lines 97 to 100 in 49fda93 |
Member
Author
|
Fixed 🎉 |
samsonasik
commented
Oct 8, 2023
Comment on lines
-90
to
-101
| if ($traversedType instanceof UnionType) { | ||
| $traversedTypeTypes = $traversedType->getTypes(); | ||
| $countTraversedTypes = count($traversedTypeTypes); | ||
|
|
||
| $collectedTypes = $this->getCollectedTypes($traversedTypeTypes); | ||
| $countCollectedTypes = count($collectedTypes); | ||
|
|
||
| // re-create new union types | ||
| if ($countTraversedTypes !== $countCollectedTypes && $countTraversedTypes > 2) { | ||
| return $this->typeFactory->createMixedPassedOrUnionType($collectedTypes); | ||
| } | ||
| } |
Member
Author
There was a problem hiding this comment.
this was used by ReturnTypeDeclarationRector which read docblock 20153a9
which now we use native type for return type inferer so it should safe to remove
Member
Author
|
All checks have passed 🎉 @TomasVotruba I am merging it ;) |
samsonasik
added a commit
that referenced
this pull request
Oct 10, 2023
…or (#5144) * [TypeDeclaration] Handle Union with array type on ReturnUnionTypeRector * Fixed 🎉
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Given the following code:
It currently produce:
which
arrayshould be included.