You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unpacked args to array_map() and immediately invoked closures are typed as one value #15620
An unpacked arg (...$x) is typed as one value. PHP expands it into one value per array item. This gives wrong closure parameter types for array_map() and for immediately invoked closures, a wrong array_map() return type, and a false argument.type.
The cause is in three places:
ContextualClosureParameterResolver::resolve() makes one parameter for each arg, also for an unpacked arg.
ArrayMapFunctionReturnTypeExtension takes an unpacked arg as one array.
In ParametersAcceptorSelector::applyIntrinsicArgOverrides(), an unpacked arg that is not a constant array adds no parameter, so the callback type becomes callable().
When the number of arrays is not known, for example with ...$lists, the types after that arg are only known as a rest type. Then the callback check should not report an error.
#10527 is related, but it was about the return type only. This came up in a review on phpstan/phpstan-src#6874. I have a fix ready and will open a PR after phpstan/phpstan-src#6874 is merged, because both change the same code.
Activity
mergeable commentedon Oct 31, 2026
This bug report is missing a link to reproduction at phpstan.org/try.
It will most likely be closed after manual review.