-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Code snippet that reproduces the problem
/**
* @template TReturn
* @param callable():(\Generator<mixed, mixed, mixed, TReturn>|TReturn) $gen
* @return array<int, TReturn>
*/
function call(callable $gen) : array {
$return = $gen();
if ($return instanceof Generator) {
return [$return->getReturn()];
}
/** @var array<int, TReturn> */
$wrapped_gen = [$gen];
return $wrapped_gen;
}
$arr = call(
/**
* @return Generator<mixed, mixed, mixed, string>
*/
function() {
yield 1;
return "hello";
}
);
foreach ($arr as $a) {
$a->foo();
}https://phpstan.org/r/4fe92bd5-514f-42ba-ade6-8cf392b61ad1
Expected output
Cannot call method on string variable $a
Actual output
No issues
Reactions are currently unavailable