From 6d4728b2a5e0ccaffe8da13da745df3ac22294bd Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 18 Jun 2026 19:38:14 +0700 Subject: [PATCH 1/2] [CodeQuality] Skip native function on MoveInnerFunctionToTopLevelRector --- .../skip_redefine_native_function.php.inc | 20 +++++++++++++++++++ .../MoveInnerFunctionToTopLevelRector.php | 17 ++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc diff --git a/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc b/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc new file mode 100644 index 00000000000..e824ba74649 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc @@ -0,0 +1,20 @@ +name->toString()); foreach ($siblingStmts as $siblingStmt) { if (! $siblingStmt instanceof Function_) { continue; @@ -134,6 +144,13 @@ private function hasSiblingFunctionOfSameName(Function_ $innerFunction, array $s if ($this->nodeNameResolver->areNamesEqual($siblingStmt, $innerFunction)) { return true; } + + if ($this->reflectionProvider->hasFunction($innerFunctionName, null)) { + $functionReflection = $this->reflectionProvider->getFunction($innerFunctionName, null); + if ($functionReflection instanceof NativeFunctionReflection) { + return true; + } + } } return false; From 2b2aa4304d875621b9cb87a0871bb7b3b9507684 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 18 Jun 2026 19:39:22 +0700 Subject: [PATCH 2/2] eol --- .../Fixture/skip_redefine_native_function.php.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc b/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc index e824ba74649..b998f9c2b88 100644 --- a/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc +++ b/rules-tests/CodeQuality/Rector/StmtsAwareInterface/MoveInnerFunctionToTopLevelRector/Fixture/skip_redefine_native_function.php.inc @@ -17,4 +17,4 @@ function bar() echo strlen('abc'); } -bar(); \ No newline at end of file +bar();