diff --git a/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/not_too_complex.php.inc b/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/not_too_complex.php.inc new file mode 100644 index 00000000000..20f86cb5131 --- /dev/null +++ b/rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting/not_too_complex.php.inc @@ -0,0 +1,44 @@ + 123, + 'key2' => '456.7', + 'key3' => 89.0, + 'key4' => -42, + 'key5' => '12%', + 'key6' => -9999, + ]; + } +} + +?> +----- + + */ + public function run(): array + { + return [ + 'key1' => 123, + 'key2' => '456.7', + 'key3' => 89.0, + 'key4' => -42, + 'key5' => '12%', + 'key6' => -9999, + ]; + } +} + +?> diff --git a/rules/Privatization/TypeManipulator/TypeNormalizer.php b/rules/Privatization/TypeManipulator/TypeNormalizer.php index cf395806d90..90664309bdd 100644 --- a/rules/Privatization/TypeManipulator/TypeNormalizer.php +++ b/rules/Privatization/TypeManipulator/TypeNormalizer.php @@ -98,7 +98,7 @@ public function generalizeConstantTypes(Type $type): Type $uniqueGeneralizedUnionTypes = $this->typeFactory->uniquateTypes($generalizedUnionedTypes); if (count($uniqueGeneralizedUnionTypes) > 1) { - $generalizedUnionType = new UnionType($generalizedUnionedTypes); + $generalizedUnionType = new UnionType($uniqueGeneralizedUnionTypes); // avoid too huge print in docblock $unionedDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode( $generalizedUnionType