Open
Description
I noticed an interesting behavior in this extension.
With the following code:
class AssertReturn {
/**
* @template TClass of object
* @param class-string<TClass> $class
*
* @throws InvalidArgumentException
* @return list<TClass>
*/
public static function allInstancesOf(mixed $list, string $class) : array
{
Assert::isList($list);
dumpType($list); // Dumped type: list<mixed>
Assert::allIsInstanceOf($list, $class);
dumpType($list); // Dumped type: list<object>
return $list;
}
}
This is not what I was expecting or hoping for.
When using the Debugger I notice this:
So it's related to the fact that I use generics to pass the TClass
.
What's the best way to deal to mitigate this problem, if it's possible.
Metadata
Metadata
Assignees
Labels
No labels