diff --git a/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php b/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php index 7f0bbf99890..2502cb38bfe 100644 --- a/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php +++ b/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php @@ -13,13 +13,14 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\For_; -use Rector\Rector\AbstractRector; +use PHPStan\Analyser\Scope; +use Rector\Rector\AbstractScopeAwareRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector\ForRepeatedCountToOwnVariableRectorTest */ -final class ForRepeatedCountToOwnVariableRector extends AbstractRector +final class ForRepeatedCountToOwnVariableRector extends AbstractScopeAwareRector { /** * @var string @@ -63,8 +64,11 @@ CODE_SAMPLE * @param For_ $node * @return Stmt[]|null */ - public function refactor(Node $node) : ?array + public function refactorWithScope(Node $node, Scope $scope) : ?array { + if ($scope->hasVariableType(self::COUNTER_NAME)->yes()) { + return null; + } $countInCond = null; $counterVariable = new Variable(self::COUNTER_NAME); foreach ($node->cond as $condExpr) { diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index a6f73b4339d..8fb5a1c6e6c 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'd67342e4e23b577a259e2d2af0ed64461db9968b'; + public const PACKAGE_VERSION = '56e2031ba3eb1886f534e87d6fb533f8b24f6889'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-04-17 10:01:56'; + public const RELEASE_DATE = '2024-04-18 04:00:25'; /** * @var int */ diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 18fc9990667..c0ea5d90505 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -14,7 +14,7 @@ $loader = (static function () { // Restore the backup and ensure the excluded files are properly marked as loaded $GLOBALS['__composer_autoload_files'] = \array_merge( $existingComposerAutoloadFiles, - \array_fill_keys(['5928a00fa978807cf85d90ec3f4b0147', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a'], true) + \array_fill_keys(['0e6d7bf4a5811bfa5cf40c5ccd6fae6a', '5928a00fa978807cf85d90ec3f4b0147'], true) ); return $loader;