File tree Expand file tree Collapse file tree
rules-tests/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector/Fixture/Nesting
rules/Privatization/TypeManipulator Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \ClassMethod \DocblockReturnArrayFromDirectArrayInstanceRector \Fixture \Nesting ;
4+
5+ final class AvoidExtremeNesting
6+ {
7+ public function run (): array
8+ {
9+ return [
10+ 'key1 ' => 123 ,
11+ 'key2 ' => '456.7 ' ,
12+ 'key3 ' => 89.0 ,
13+ 'key4 ' => -42 ,
14+ 'key5 ' => '12% ' ,
15+ 'key6 ' => -9999 ,
16+ ];
17+ }
18+ }
19+
20+ ?>
21+ -----
22+ <?php
23+
24+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \ClassMethod \DocblockReturnArrayFromDirectArrayInstanceRector \Fixture \Nesting ;
25+
26+ final class AvoidExtremeNesting
27+ {
28+ /**
29+ * @return array<string, int|string|float>
30+ */
31+ public function run (): array
32+ {
33+ return [
34+ 'key1 ' => 123 ,
35+ 'key2 ' => '456.7 ' ,
36+ 'key3 ' => 89.0 ,
37+ 'key4 ' => -42 ,
38+ 'key5 ' => '12% ' ,
39+ 'key6 ' => -9999 ,
40+ ];
41+ }
42+ }
43+
44+ ?>
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public function generalizeConstantTypes(Type $type): Type
9898 $ uniqueGeneralizedUnionTypes = $ this ->typeFactory ->uniquateTypes ($ generalizedUnionedTypes );
9999
100100 if (count ($ uniqueGeneralizedUnionTypes ) > 1 ) {
101- $ generalizedUnionType = new UnionType ($ generalizedUnionedTypes );
101+ $ generalizedUnionType = new UnionType ($ uniqueGeneralizedUnionTypes );
102102 // avoid too huge print in docblock
103103 $ unionedDocType = $ this ->staticTypeMapper ->mapPHPStanTypeToPHPStanPhpDocTypeNode (
104104 $ generalizedUnionType
You can’t perform that action at this time.
0 commit comments