Repository navigation
[CodingStyle] Keep string callable global when shadowed in FunctionFirstClassCallableRector - #9057
Merged
Merged
Conversation
…rstClassCallableRector
TomasVotruba
force-pushed
the
fix-first-class-callable-global-function
branch
from
November 24, 2026 17:00
832bec2 to
6c0ae79
Compare
TomasVotruba
enabled auto-merge (squash)
November 24, 2026 17:01
samsonasik
reviewed
Nov 25, 2026
| { | ||
| $namespaceName = ScopeFetcher::fetch($funcCall)->getNamespace(); | ||
| if ($namespaceName !== null && $this->reflectionProvider->hasFunction( | ||
| new FullyQualified($namespaceName . '\\' . $functionName), |
Member
There was a problem hiding this comment.
nodeNameResolver->getName() should already resolve the correct name
Member
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A string callable like
'trim'always resolves to the global function. A baretrim(...)resolves against the current namespace anduse functionimports first, so when a namespacedtrim()exists or ause function Foo\trim;import is in the file, the rule switched the call to a different function.Before:
array_map(trim(...), $data)- callsApp\trim().After:
array_map(\trim(...), $data)- still calls the globaltrim().The fix emits the fully qualified name only when the bare name would resolve elsewhere - a
<Namespace>\<name>function exists, or the file has ause functionimport (or alias) to that name. Otherwise the output stays bare as before. Addednamespaced_function_shadowanduse_function_importfixtures.