File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
rules-tests/CodingStyle/Rector/ClassMethod/BinaryOpStandaloneAssignsToDirectRector
rules/CodingStyle/Rector/ClassMethod Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \CodingStyle \Rector \ClassMethod \BinaryOpStandaloneAssignsToDirectRector \Fixture ;
4+
5+ use CodingStyle \Rector \ClassMethod \BinaryOpStandaloneAssignsToDirectRector \Source \SomeGetter ;
6+
7+ final class TwoBareGetters
8+ {
9+ public function run (SomeGetter $ firstSomeGetter , SomeGetter $ secondSomeGetter )
10+ {
11+ $ first = $ firstSomeGetter ->getSome ();
12+ $ second = $ secondSomeGetter ->getSome ();
13+
14+ return $ first <=> $ second ;
15+ }
16+ }
17+
18+ ?>
19+ -----
20+ <?php
21+
22+ namespace Rector \Tests \CodingStyle \Rector \ClassMethod \BinaryOpStandaloneAssignsToDirectRector \Fixture ;
23+
24+ use CodingStyle \Rector \ClassMethod \BinaryOpStandaloneAssignsToDirectRector \Source \SomeGetter ;
25+
26+ final class TwoBareGetters
27+ {
28+ public function run (SomeGetter $ firstSomeGetter , SomeGetter $ secondSomeGetter )
29+ {
30+ return $ firstSomeGetter ->getSome () <=> $ secondSomeGetter ->getSome ();
31+ }
32+ }
33+
34+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CodingStyle \Rector \ClassMethod \BinaryOpStandaloneAssignsToDirectRector \Source ;
4+
5+ class SomeGetter
6+ {
7+ public function getSome ()
8+ {
9+ return 100 ;
10+ }
11+ }
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ private function matchToVariableAssignExpr(Stmt $stmt): ?VariableAndExprAssign
133133 }
134134
135135 // skip complex cases
136- if ($ assign ->expr instanceof MethodCall) {
136+ if ($ assign ->expr instanceof MethodCall && $ assign -> expr -> args !== [] ) {
137137 return null ;
138138 }
139139
You can’t perform that action at this time.
0 commit comments