File tree Expand file tree Collapse file tree 2 files changed +57
-2
lines changed
rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeBasedOnPHPUnitDataProviderRector/Fixture
rules/TypeDeclaration/Rector/ClassMethod Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddParamTypeBasedOnPHPUnitDataProviderRector \Fixture ;
4+
5+ use Iterator ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ final class WithInnerFunction extends TestCase
9+ {
10+ /**
11+ * @dataProvider provideData()
12+ */
13+ public function test ($ name )
14+ {
15+ }
16+
17+ public function provideData ()
18+ {
19+ function () {
20+ return [['some ' ]];
21+ };
22+
23+ yield [1 ];
24+ }
25+ }
26+
27+ ?>
28+ -----
29+ <?php
30+
31+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddParamTypeBasedOnPHPUnitDataProviderRector \Fixture ;
32+
33+ use Iterator ;
34+ use PHPUnit \Framework \TestCase ;
35+
36+ final class WithInnerFunction extends TestCase
37+ {
38+ /**
39+ * @dataProvider provideData()
40+ */
41+ public function test (int $ name )
42+ {
43+ }
44+
45+ public function provideData ()
46+ {
47+ function () {
48+ return [['some ' ]];
49+ };
50+
51+ yield [1 ];
52+ }
53+ }
54+
55+ ?>
Original file line number Diff line number Diff line change @@ -161,13 +161,13 @@ private function inferParam(
161161 }
162162
163163 /** @var Return_[] $returns */
164- $ returns = $ this ->betterNodeFinder ->findInstanceOf (( array ) $ dataProviderClassMethod-> stmts , Return_::class);
164+ $ returns = $ this ->betterNodeFinder ->findInstancesOfInFunctionLikeScoped ( $ dataProviderClassMethod , Return_::class);
165165 if ($ returns !== []) {
166166 return $ this ->resolveReturnStaticArrayTypeByParameterPosition ($ returns , $ parameterPosition );
167167 }
168168
169169 /** @var Yield_[] $yields */
170- $ yields = $ this ->betterNodeFinder ->findInstanceOf (( array ) $ dataProviderClassMethod-> stmts , Yield_::class);
170+ $ yields = $ this ->betterNodeFinder ->findInstancesOfInFunctionLikeScoped ( $ dataProviderClassMethod , Yield_::class);
171171 return $ this ->resolveYieldStaticArrayTypeByParameterPosition ($ yields , $ parameterPosition );
172172 }
173173
You can’t perform that action at this time.
0 commit comments