-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Hello 👋🏽
I have the following snippet:
<?php declare(strict_types = 1);
class Model {}
/**
* @template TKey of array-key
* @template TModel
*
*/
class SupportCollection {}
/**
* @template TKey of array-key
* @template TModel of Model
*
*/
class Collection
{
/**
* Run a map over each of the items.
*
* @template TMapValue
*
* @param callable(TModel, TKey): TMapValue $callback
* @return (TMapValue is Model ? static<TKey, TMapValue> : SupportCollection<TKey, TMapValue>)
*/
public function map(callable $callback) {} // @phpstan-ignore return.missing
}I was expecting the TMapValue to be narrowed down to Model in static<TKey, TMapValue> because we are in the truthy branch of the if condition. But as it can be seen in the playground, it doesn't work like that.
Am I wrong to expect that, or is it a bug?
Code snippet that reproduces the problem
https://phpstan.org/r/92226828-0e09-4210-9906-6b1df14395c0
Expected output
No errors.
Did PHPStan help you today? Did it make you happy in any way?
It helps me every day!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels