File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
rules-tests/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector/Fixture
src/NodeTypeResolver/PHPStan/Scope Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Rector \Tests \CodeQuality \Rector \ClassMethod \OptionalParametersAfterRequiredRector \Fixture ;
6
+
7
+ final class SkipCountForLoop
8
+ {
9
+ public function __invoke ($ em )
10
+ {
11
+ $ visitedProduct1 = null ;
12
+ $ visitedProduct2 = null ;
13
+ $ visitedProduct3 = null ;
14
+
15
+ $ products = $ em ->getRepository (Product::class)->findAll ();
16
+ $ visitedProducts = [];
17
+ for ($ i = 0 ; $ i < count ($ products ), count ($ visitedProducts ) <= 3 ; ++$ i ) {
18
+ $ product = $ products [$ i ];
19
+ if (!in_array ($ product , $ exclude )) {
20
+ $ varName = 'visitedProduct ' . ($ i + 1 );
21
+ $ visitedProducts [$ varName ] = $ product ;
22
+ }
23
+ }
24
+
25
+ extract ($ visitedProducts );
26
+ }
27
+ }
Original file line number Diff line number Diff line change 45
45
use PhpParser \Node \Stmt \EnumCase ;
46
46
use PhpParser \Node \Stmt \Expression ;
47
47
use PhpParser \Node \Stmt \Finally_ ;
48
+ use PhpParser \Node \Stmt \For_ ;
48
49
use PhpParser \Node \Stmt \Foreach_ ;
49
50
use PhpParser \Node \Stmt \Function_ ;
50
51
use PhpParser \Node \Stmt \Interface_ ;
@@ -222,6 +223,17 @@ public function processNodes(
222
223
return ;
223
224
}
224
225
226
+ if ($ node instanceof For_) {
227
+ foreach (array_merge ($ node ->init , $ node ->cond , $ node ->loop ) as $ expr ) {
228
+ $ expr ->setAttribute (AttributeKey::SCOPE , $ mutatingScope );
229
+ if ($ expr instanceof BinaryOp) {
230
+ $ this ->processBinaryOp ($ expr , $ mutatingScope );
231
+ }
232
+ }
233
+
234
+ return ;
235
+ }
236
+
225
237
if ($ node instanceof Array_) {
226
238
$ this ->processArray ($ node , $ mutatingScope );
227
239
return ;
You can’t perform that action at this time.
0 commit comments