-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/f7496069-aa93-438b-80b1-b7e957c72d5f
<?php declare(strict_types = 1);
/**
* @template TParent of ParentNodeInterface
*/
interface ChildNodeInterface
{
/** @return TParent */
public function getParent(): ParentNodeInterface;
}
interface ParentNodeInterface
{
/** @return list<ChildNodeInterface<static>> */
public function getChildren(): array;
}
final class Block implements ParentNodeInterface
{
/** @var list<Row> */
private $rows = [];
/** @return list<Row> */
public function getChildren(): array
{
return $this->rows;
}
}
/** @implements ChildNodeInterface<Block> */
final class Row implements ChildNodeInterface
{
/** @var Block $parent */
private $parent;
public function getParent(): Block {
return $this->parent;
}
}Expected output
No errors
Actual output
Return type (array<int, Row>) of method Block::getChildren() should be compatible with return type (array<int, ChildNodeInterface<static(ParentNodeInterface)>>) of method ParentNodeInterface::getChildren()
I could somewhat understand the error if Block wasn't final, but in this case I can't see any problems with the types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels