From efbd3fef527fe6de6b43b295b282b7dc24cf6a42 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 19 Oct 2026 11:06:16 +0200 Subject: [PATCH] [perf] Hoist cheap limit-arg guard before scope fetch in preg_split rule --- .../NullToStrictIntPregSlitFuncCallLimitArgRector.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rules/Php81/Rector/FuncCall/NullToStrictIntPregSlitFuncCallLimitArgRector.php b/rules/Php81/Rector/FuncCall/NullToStrictIntPregSlitFuncCallLimitArgRector.php index 62a7279c887..5a7acb3f72e 100644 --- a/rules/Php81/Rector/FuncCall/NullToStrictIntPregSlitFuncCallLimitArgRector.php +++ b/rules/Php81/Rector/FuncCall/NullToStrictIntPregSlitFuncCallLimitArgRector.php @@ -80,11 +80,6 @@ public function refactor(Node $node): ?Node return null; } - $scope = $node->getAttribute(AttributeKey::SCOPE); - if (! $scope instanceof Scope) { - return null; - } - $args = $node->getArgs(); $position = $this->argsAnalyzer->resolveArgPosition($args, 'limit', 2); @@ -92,6 +87,11 @@ public function refactor(Node $node): ?Node return null; } + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (! $scope instanceof Scope) { + return null; + } + $classReflection = $scope->getClassReflection(); $isTrait = $classReflection instanceof ClassReflection && $classReflection->isTrait();