File tree Expand file tree Collapse file tree 3 files changed +25
-21
lines changed
rules-tests/Php70/Rector/FuncCall/MultiDirnameRector/Fixture
rules/Php70/Rector/FuncCall Expand file tree Collapse file tree 3 files changed +25
-21
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,6 @@ function multiDirname()
77 dirname (dirname ($ path ));
88
99 new dirname (dirname (dirname ($ path )));
10-
11-
12- // untouched
13- dirname (dirname ($ path , $ level ));
14-
15- dirname ("foo/ " . dirname ($ path ));
16-
17- dirname (dirname ($ path ) . $ foo );
18-
19- foo \dirname (dirname ($ path ));
2010}
2111
2212?>
@@ -30,16 +20,6 @@ function multiDirname()
3020 dirname ($ path , 2 );
3121
3222 new dirname (dirname ($ path , 2 ));
33-
34-
35- // untouched
36- dirname (dirname ($ path , $ level ));
37-
38- dirname ("foo/ " . dirname ($ path ));
39-
40- dirname (dirname ($ path ) . $ foo );
41-
42- foo \dirname (dirname ($ path ));
4323}
4424
4525?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \Php70 \Rector \FuncCall \MultiDirnameRector \Fixture ;
4+
5+ function multiDirname ()
6+ {
7+ dirname (dirname ($ path , $ level ));
8+
9+ dirname ("foo/ " . dirname ($ path ));
10+
11+ dirname (dirname ($ path ) . $ foo );
12+
13+ foo \dirname (dirname ($ path ));
14+
15+ dirname ($ path , 1 );
16+
17+ dirname ($ path , 2 );
18+
19+ dirname (getcwd (), 2 );
20+ }
21+
22+ ?>
Original file line number Diff line number Diff line change @@ -56,12 +56,14 @@ public function refactor(Node $node): ?Node
5656 $ activeFuncCallNode = $ node ;
5757 $ lastFuncCallNode = $ node ;
5858
59+ $ shouldUpdate = false ;
5960 while (($ activeFuncCallNode = $ this ->matchNestedDirnameFuncCall ($ activeFuncCallNode )) instanceof FuncCall) {
6061 $ lastFuncCallNode = $ activeFuncCallNode ;
62+ $ shouldUpdate = true ;
6163 }
6264
6365 // nothing to improve
64- if ($ this ->shouldSkip ()) {
66+ if (! $ shouldUpdate || $ this ->shouldSkip ()) {
6567 return null ;
6668 }
6769
You can’t perform that action at this time.
0 commit comments