File tree Expand file tree Collapse file tree
rules/Transform/Rector/ArrayDimFetch Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818use PhpParser \NodeVisitor ;
1919use PHPStan \Type \ObjectType ;
2020use Rector \Contract \Rector \ConfigurableRectorInterface ;
21- use Rector \NodeTypeResolver \ Node \ AttributeKey ;
21+ use Rector \NodeNestingScope \ ContextAnalyzer ;
2222use Rector \Rector \AbstractRector ;
2323use Rector \Transform \ValueObject \ArrayDimFetchToMethodCall ;
2424use Symplify \RuleDocGenerator \ValueObject \CodeSample \ConfiguredCodeSample ;
@@ -35,6 +35,11 @@ final class ArrayDimFetchToMethodCallRector extends AbstractRector implements Co
3535 */
3636 private array $ arrayDimFetchToMethodCalls ;
3737
38+ public function __construct (
39+ private readonly ContextAnalyzer $ contextAnalyzer
40+ ) {
41+ }
42+
3843 public function getRuleDefinition (): RuleDefinition
3944 {
4045 return new RuleDefinition ('Change array dim fetch to method call ' , [
@@ -86,11 +91,7 @@ public function refactor(Node $node): array|Expr|null|int
8691 }
8792
8893 // is part of assign, skip
89- if ($ node ->getAttribute (AttributeKey::IS_BEING_ASSIGNED )) {
90- return null ;
91- }
92-
93- if ($ node ->getAttribute (AttributeKey::IS_ASSIGN_OP_VAR )) {
94+ if ($ this ->contextAnalyzer ->isLeftPartOfAssign ($ node )) {
9495 return null ;
9596 }
9697
You can’t perform that action at this time.
0 commit comments