Skip to content

Commit

Permalink
[BUGFIX] Fix missing Scope in UseExtensionConfigurationApiRector (#4052)
Browse files Browse the repository at this point in the history
* [BUGFIX] Fix missing Scope in UseExtensionConfigurationApiRector

Resolves: #4049
  • Loading branch information
sabbelasichon authored Feb 1, 2024
1 parent 735e8d7 commit ea6323b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Rector/v9/v0/UseExtensionConfigurationApiRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\Coalesce;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Isset_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use PHPStan\Analyser\Scope;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Ssch\TYPO3Rector\Helper\Typo3NodeResolver;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -24,7 +25,7 @@
* @changelog https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.0/Deprecation-82254-DeprecateGLOBALSTYPO3_CONF_VARSEXTextConf.html
* @see \Ssch\TYPO3Rector\Tests\Rector\v9\v0\UseExtensionConfigurationApiRector\UseExtensionConfigurationApiRectorTest
*/
final class UseExtensionConfigurationApiRector extends AbstractScopeAwareRector
final class UseExtensionConfigurationApiRector extends AbstractRector
{
/**
* @return array<class-string<Node>>
Expand All @@ -37,7 +38,7 @@ public function getNodeTypes(): array
/**
* @param FuncCall|Isset_|ArrayDimFetch $node
*/
public function refactorWithScope(Node $node, Scope $scope): ?Node
public function refactor(Node $node): ?Node
{
if ($node instanceof FuncCall) {
return $this->refactorUnserialize($node);
Expand All @@ -51,7 +52,8 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
return null;
}

if ($scope->isInFirstLevelStatement()) {
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof Assign && $parentNode->var === $node) {
return null;
}

Expand Down

0 comments on commit ea6323b

Please sign in to comment.