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
Template variables are not being correctly inferred when passing an Iterator<T> or IteratorAggregate<T> into an iterable<T> parameter.
To Reproduce
Create the following function:
/** * @template T * * @param iterable<T> $testInput * * @return T */functiontemplateTest(iterable$testInput): mixed
{
return'some value (pretend this is the correct type)';
}
And call this function with a variable of type Iterator or IteratorAggregate (ignore the actual value of the variable, it doesn't matter):
Describe the bug
Template variables are not being correctly inferred when passing an
Iterator<T>
orIteratorAggregate<T>
into aniterable<T>
parameter.To Reproduce
Create the following function:
And call this function with a variable of type
Iterator
orIteratorAggregate
(ignore the actual value of the variable, it doesn't matter):When you inspect the type of
$testOutput
it will bemixed
.Expected behavior
I expect the type of
$testOutput
to be correctly inferred from the input type (in the above examples it should bestring
).This already works when passing an input value of type
iterable
orarray
:In the above cases, the type of
$testOutput
is correctly inferred asstring
.Screenshots
Platform and version
M2 Pro - macOS Sonoma 14.6
PHP Intelephense v1.12.6
The text was updated successfully, but these errors were encountered: