File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture
rules/Php85/Rector/ArrayDimFetch Expand file tree Collapse file tree 2 files changed +19
-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 \Php85 \Rector \ArrayDimFetch \ArrayFirstLastRector \Fixture ;
6+
7+ final class SkipUnderUnset
8+ {
9+ public function run ()
10+ {
11+ $ a = [1 ,2 ,3 ];
12+ unset($ a [array_key_last ($ a )]);
13+ }
14+ }
Original file line number Diff line number Diff line change 77use PhpParser \Node ;
88use PhpParser \Node \Expr \ArrayDimFetch ;
99use PhpParser \Node \Expr \FuncCall ;
10+ use Rector \NodeTypeResolver \Node \AttributeKey ;
1011use Rector \PHPStan \ScopeFetcher ;
1112use Rector \Rector \AbstractRector ;
1213use Rector \ValueObject \PhpVersionFeature ;
@@ -88,6 +89,10 @@ public function refactor(Node $node): ?FuncCall
8889 return null ;
8990 }
9091
92+ if ($ node ->getAttribute (AttributeKey::IS_UNSET_VAR )) {
93+ return null ;
94+ }
95+
9196 $ functionName = $ this ->isName ($ node ->dim , self ::ARRAY_KEY_FIRST )
9297 ? 'array_first '
9398 : 'array_last ' ;
You can’t perform that action at this time.
0 commit comments