From e071d037e31942292307c647b0acffe1007b0a52 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 19 Nov 2023 15:48:32 +0000 Subject: [PATCH] Updated Rector to commit 9fa5013b41ecee17113c56ad94f219bd1940e763 https://github.com/rectorphp/rector-src/commit/9fa5013b41ecee17113c56ad94f219bd1940e763 [Performance][Renaming] Remove unnecessary array_reverse() on RenameClassRector (#5266) --- .../Rector/Name/RenameClassRector.php | 24 +++++++++---------- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/rules/Renaming/Rector/Name/RenameClassRector.php b/rules/Renaming/Rector/Name/RenameClassRector.php index e8a78449be5..694004d07af 100644 --- a/rules/Renaming/Rector/Name/RenameClassRector.php +++ b/rules/Renaming/Rector/Name/RenameClassRector.php @@ -141,25 +141,23 @@ CODE_SAMPLE } private function restructureUnderNamespace(FileWithoutNamespace $fileWithoutNamespace) : void { - $stmts = \array_reverse($fileWithoutNamespace->stmts, \true); - $isBeforeNamespace = \false; $stmtsBeforeNamespace = []; - $namepace = null; - foreach ($stmts as $key => $stmt) { + foreach ($fileWithoutNamespace->stmts as $key => $stmt) { if ($stmt instanceof Namespace_) { - $isBeforeNamespace = \true; - $namepace = $stmt; + if ($stmtsBeforeNamespace !== []) { + $stmt->stmts = \array_values(\array_merge(\is_array($stmtsBeforeNamespace) ? $stmtsBeforeNamespace : \iterator_to_array($stmtsBeforeNamespace), $stmt->stmts)); + } + break; + } + if ($stmt instanceof Declare_) { continue; } - if ($isBeforeNamespace && !$stmt instanceof Declare_) { - $stmtsBeforeNamespace[] = $stmt; - unset($stmts[$key]); - } + $stmtsBeforeNamespace[] = $stmt; + unset($fileWithoutNamespace->stmts[$key]); } - if ($stmtsBeforeNamespace === [] || !$namepace instanceof Namespace_) { + if ($stmtsBeforeNamespace === []) { return; } - $namepace->stmts = \array_values(\array_merge(\is_array($stmtsBeforeNamespace) ? $stmtsBeforeNamespace : \iterator_to_array($stmtsBeforeNamespace), $namepace->stmts)); - $fileWithoutNamespace->stmts = \array_values(\array_reverse($stmts, \true)); + $fileWithoutNamespace->stmts = \array_values($fileWithoutNamespace->stmts); } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index a785868c651..97cd2bf5417 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 = '13284c60485e972ef72bf234b3c014c5f89e0d14'; + public const PACKAGE_VERSION = '9fa5013b41ecee17113c56ad94f219bd1940e763'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-11-19 10:12:03'; + public const RELEASE_DATE = '2023-11-19 22:46:19'; /** * @var int */