File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
rules-tests/DowngradePhp80/Rector/FuncCall/DowngradeSubstrFalsyRector/Fixture
rules/DowngradePhp80/Rector/FuncCall Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp80 \Rector \FuncCall \DowngradeSubstrFalsyRector \Fixture ;
4+
5+ class SkipInBinaryOp
6+ {
7+ public function run ($ a )
8+ {
9+ return substr ("a " , 2 ) && $ a === true ;
10+ }
11+ }
Original file line number Diff line number Diff line change 1010use PhpParser \Node \Expr ;
1111use PhpParser \Node \Expr \ArrayDimFetch ;
1212use PhpParser \Node \Expr \AssignOp ;
13+ use PhpParser \Node \Expr \BinaryOp ;
1314use PhpParser \Node \Expr \BinaryOp \Concat ;
1415use PhpParser \Node \Expr \BinaryOp \Identical ;
1516use PhpParser \Node \Expr \BooleanNot ;
@@ -81,12 +82,13 @@ public function getNodeTypes(): array
8182 Do_::class,
8283 ArrayItem::class,
8384 ArrayDimFetch::class,
85+ BinaryOp::class,
8486 FuncCall::class,
8587 ];
8688 }
8789
8890 /**
89- * @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|AssignOp|If_|While_|Do_|ArrayItem|ArrayDimFetch|FuncCall $node
91+ * @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|AssignOp|If_|While_|Do_|ArrayItem|ArrayDimFetch|BinaryOp| FuncCall $node
9092 */
9193 public function refactor (Node $ node ): ?Node
9294 {
@@ -142,6 +144,12 @@ public function refactor(Node $node): ?Node
142144 return null ;
143145 }
144146
147+ if ($ node instanceof BinaryOp) {
148+ $ node ->left ->setAttribute (self ::IS_UNCASTABLE , true );
149+ $ node ->right ->setAttribute (self ::IS_UNCASTABLE , true );
150+ return null ;
151+ }
152+
145153 if ($ node instanceof CallLike) {
146154 if ($ node ->isFirstClassCallable ()) {
147155 return null ;
You can’t perform that action at this time.
0 commit comments