From b9cbd744dca4c00f3fd51471598956e4eb8b99f3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 25 Nov 2026 18:34:48 +0700 Subject: [PATCH] Simplify shadowed function detection in FunctionFirstClassCallableRector --- .../FunctionFirstClassCallableRector.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php b/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php index c8083e3315a..2feb47cd282 100644 --- a/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php +++ b/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php @@ -138,21 +138,18 @@ public function refactor(Node $node): ?FuncCall */ private function isShadowedFunction(FuncCall $funcCall, string $functionName): bool { - $namespaceName = ScopeFetcher::fetch($funcCall)->getNamespace(); - if ($namespaceName !== null && $this->reflectionProvider->hasFunction( - new FullyQualified($namespaceName . '\\' . $functionName), - null - )) { + $functionNameNode = new Name($functionName); + $functionCallScope = ScopeFetcher::fetch($funcCall); + + $resolvedFunctionName = $this->reflectionProvider->resolveFunctionName($functionNameNode, $functionCallScope); + if ($resolvedFunctionName !== null && $resolvedFunctionName !== $functionName) { return true; } foreach ($this->useImportsResolver->resolve() as $use) { foreach ($use->uses as $useItem) { - if ($use->type !== Use_::TYPE_FUNCTION && $useItem->type !== Use_::TYPE_FUNCTION) { - continue; - } - - if ($useItem->getAlias()->toLowerString() === strtolower($functionName)) { + if (($use->type === Use_::TYPE_FUNCTION || $useItem->type === Use_::TYPE_FUNCTION) + && $this->isName($useItem->getAlias(), $functionName)) { return true; } }