Skip to content

Commit 80f642c

Browse files
committed
Updated Rector to commit 31adca84ee3701bbd3e834abf30fd542ee454682
rectorphp/rector-src@31adca8 [transform] tidy up array dim fetch to method call rector (#7694)
1 parent 38b6527 commit 80f642c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

rules/Transform/Rector/ArrayDimFetch/ArrayDimFetchToMethodCallRector.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PhpParser\NodeVisitor;
1919
use PHPStan\Type\ObjectType;
2020
use Rector\Contract\Rector\ConfigurableRectorInterface;
21+
use Rector\NodeTypeResolver\Node\AttributeKey;
2122
use Rector\Rector\AbstractRector;
2223
use Rector\Transform\ValueObject\ArrayDimFetchToMethodCall;
2324
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
@@ -72,9 +73,13 @@ public function refactor(Node $node)
7273
if (!$node->var instanceof ArrayDimFetch) {
7374
return null;
7475
}
75-
return $this->getMethodCall($node->var, 'set', $node->expr) ?? NodeVisitor::DONT_TRAVERSE_CHILDREN;
76+
return $this->createExplicitMethodCall($node->var, 'set', $node->expr);
7677
}
77-
return $this->getMethodCall($node, 'get');
78+
// is part of assign, skip
79+
if ($node->getAttribute(AttributeKey::IS_BEING_ASSIGNED)) {
80+
return null;
81+
}
82+
return $this->createExplicitMethodCall($node, 'get');
7883
}
7984
public function configure(array $configuration): void
8085
{
@@ -90,7 +95,7 @@ private function handleIsset(Isset_ $isset)
9095
$exprs = [];
9196
foreach ($isset->vars as $var) {
9297
if ($var instanceof ArrayDimFetch) {
93-
$methodCall = $this->getMethodCall($var, 'exists');
98+
$methodCall = $this->createExplicitMethodCall($var, 'exists');
9499
if ($methodCall instanceof MethodCall) {
95100
$exprs[] = $methodCall;
96101
continue;
@@ -116,7 +121,7 @@ private function handleUnset(Unset_ $unset)
116121
$stmts = [];
117122
foreach ($unset->vars as $var) {
118123
if ($var instanceof ArrayDimFetch) {
119-
$methodCall = $this->getMethodCall($var, 'unset');
124+
$methodCall = $this->createExplicitMethodCall($var, 'unset');
120125
if ($methodCall instanceof MethodCall) {
121126
$stmts[] = new Expression($methodCall);
122127
continue;
@@ -136,7 +141,7 @@ private function handleUnset(Unset_ $unset)
136141
/**
137142
* @param 'get'|'set'|'exists'|'unset' $action
138143
*/
139-
private function getMethodCall(ArrayDimFetch $arrayDimFetch, string $action, ?Expr $expr = null): ?MethodCall
144+
private function createExplicitMethodCall(ArrayDimFetch $arrayDimFetch, string $action, ?Expr $expr = null): ?MethodCall
140145
{
141146
if (!$arrayDimFetch->dim instanceof Node) {
142147
return null;

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '35b9d1c092247fad0873692b34996c5087f9cc1a';
22+
public const PACKAGE_VERSION = '31adca84ee3701bbd3e834abf30fd542ee454682';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-12-01 16:32:25';
27+
public const RELEASE_DATE = '2025-12-01 20:20:58';
2828
/**
2929
* @var int
3030
*/

src/Reporting/DeprecatedRulesReporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
declare (strict_types=1);
44
namespace Rector\Reporting;
55

6-
use Rector\PhpParser\Enum\NodeGroup;
76
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
87
use Rector\Configuration\Option;
98
use Rector\Configuration\Parameter\SimpleParameterProvider;
109
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
1110
use Rector\Contract\Rector\RectorInterface;
11+
use Rector\PhpParser\Enum\NodeGroup;
1212
use RectorPrefix202512\Symfony\Component\Console\Style\SymfonyStyle;
1313
final class DeprecatedRulesReporter
1414
{

0 commit comments

Comments
 (0)