Repository navigation
[Php81] Skip array returned as array type in ArrayToFirstClassCallableRector - #9035
Merged
TomasVotruba merged 1 commit intoNov 23, 2026
Merged
Conversation
TomasVotruba
deleted the
array-to-first-class-callable-skip-array-return
branch
November 23, 2026 22:26
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.
ArrayToFirstClassCallableRectorconverted an array callable returned from a function declared to returnarray, which then returns aClosure- aTypeErrorat runtime:public function provideListenerPriority(): array { - return [SomeExternalObject::class, 'sleepStatic']; + return SomeExternalObject::sleepStatic(...); }The rule already skipped arrays passed to an
arrayparam, but not returns.Fix:
ContextNodeVisitornow marks an array returned from a function, method, closure or arrow function whose native return type isarray/iterable(nullable, or a union with them and nocallable/Closure/mixed/object), and the rule skips it. Untyped returns, nested closures inside such a method, andarray|callablereturns still convert.The
static_with_other_object_const_fetchfixture encoded the bug, so it is nowskip_static_with_other_object_const_fetch_returned_as_array; the static external call conversion is covered byreturn_in_untyped_method.