File tree Expand file tree Collapse file tree 2 files changed +42
-8
lines changed
rules-tests/TypeDeclarationDocblocks/Rector/Class_/ClassMethodArrayDocblockParamFromLocalCallsRector/Fixture
rules/TypeDeclaration/NodeAnalyzer Expand file tree Collapse file tree 2 files changed +42
-8
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \ClassMethodArrayDocblockParamFromLocalCallsRector \Fixture ;
4+
5+ class NotZeroPosition
6+ {
7+ public function go ()
8+ {
9+ $ this ->run ([], ['item1 ' , 'item2 ' ]);
10+ }
11+
12+ private function run (array $ data , array $ items )
13+ {
14+ }
15+ }
16+
17+ ?>
18+ -----
19+ <?php
20+
21+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \ClassMethodArrayDocblockParamFromLocalCallsRector \Fixture ;
22+
23+ class NotZeroPosition
24+ {
25+ public function go ()
26+ {
27+ $ this ->run ([], ['item1 ' , 'item2 ' ]);
28+ }
29+
30+ /**
31+ * @param string[] $items
32+ */
33+ private function run (array $ data , array $ items )
34+ {
35+ }
36+ }
37+
38+ ?>
Original file line number Diff line number Diff line change @@ -124,17 +124,13 @@ private function unionToSingleType(array $staticTypesByArgumentPosition): array
124124 $ staticTypeByArgumentPosition [$ position ] = $ this ->narrowParentObjectTreeToSingleObjectChildType (
125125 $ unionedType
126126 );
127- }
128-
129- if (count ($ staticTypeByArgumentPosition ) !== 1 ) {
130- return $ staticTypeByArgumentPosition ;
131- }
132127
133- if (! $ staticTypeByArgumentPosition [0 ]->isNull ()->yes ()) {
134- return $ staticTypeByArgumentPosition ;
128+ if ($ staticTypeByArgumentPosition [$ position ]->isNull ()->yes ()) {
129+ $ staticTypeByArgumentPosition [$ position ] = new MixedType ();
130+ }
135131 }
136132
137- return [ new MixedType ()] ;
133+ return $ staticTypeByArgumentPosition ;
138134 }
139135
140136 private function narrowParentObjectTreeToSingleObjectChildType (Type $ type ): Type
You can’t perform that action at this time.
0 commit comments