[TypeDeclarationDocblocks] Handle multiple objects on AddReturnDocblockDataProviderRector#7298
[TypeDeclarationDocblocks] Handle multiple objects on AddReturnDocblockDataProviderRector#7298samsonasik merged 3 commits intomainfrom
Conversation
…ckDataProviderRector
|
It seems there is bug on rector-src/src/NodeTypeResolver/PHPStan/Type/TypeFactory.php Lines 195 to 211 in 76dc419 rector-src/src/NodeTypeResolver/PHPStan/TypeHasher.php Lines 26 to 52 in 76dc419 |
|
Fixed 🎉 |
| * @var int | ||
| */ | ||
| private const MAX_PRINTED_UNION_DOC_LENGHT = 60; | ||
| private const MAX_PRINTED_UNION_DOC_LENGHT = 77; |
There was a problem hiding this comment.
@TomasVotruba I updated to use 77 as max length union to show the fix, otherwise, it just \Iterator<mixed> for this fixture test
The fix for this case is loop when inner is ConstantArrayType too.
Proven works at
There was a problem hiding this comment.
This might be tricky to keep in readable line. The longer the docblock will be, the more mess might get int. But let's give 77 a try.
| if ($nestedFlattenItemType instanceof ConstantArrayType) { | ||
| $innerArrayTypes = $this->unwrapConstantArrayTypes($nestedFlattenItemType); | ||
| foreach ($innerArrayTypes as $innerArrayType) { | ||
| // preserve outer array -> inner array structure: array<outerKey, innerArray> | ||
| $unwrappedTypes[] = new ArrayType($nestedFlattenKeyType, $innerArrayType); | ||
| } | ||
|
|
||
| continue; | ||
| } |
There was a problem hiding this comment.
this loop again to make result of inner constant array to avoid just added the last one,
|
All checks have passed 🎉 @TomasVotruba I am merging it ;) |
|
👍 |
|
This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work. |
it currently only got last objects, which cause phpstan notice:
see https://phpstan.org/r/db520ab6-fc4f-4c45-ac1f-b91801f2e065