Bug report
Phpstan infer type as mixed, but it is wrong, because TChild is always object. Thus, the type should be object|null.
/**
* @template TChild of object
*
* @extends ArrayAccess<int, ?TChild>
*/
interface ParentNode extends ArrayAccess {
// empty
}
class HelloWorld
{
public function sayHelloBug(object $node): void
{
if ($node instanceof ParentNode) {
assertType('object|null', $node[0]);
}
}
}
Code snippet that reproduces the problem
https://phpstan.org/r/b49ce8e4-dd48-440a-9584-f22ce8a987b9
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
Yep
Bug report
Phpstan infer type as
mixed, but it is wrong, becauseTChildis alwaysobject. Thus, the type should beobject|null.Code snippet that reproduces the problem
https://phpstan.org/r/b49ce8e4-dd48-440a-9584-f22ce8a987b9
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
Yep