<?php
abstract class Entity {}
class FooEntity extends Entity {}
abstract class Repository
{
abstract public function getDetail(): Entity;
}
class FooRepository extends Repository
{
public function getDetail(): FooEntity
{
return new FooEntity;
}
}
$obj = new FooRepository();
$obj->getDetail();
Fatal error: Declaration of FooRepository::getDetail(): FooEntity must be compatible with Repository::getDetail(): Entity in /in/innXW on line 18
Process exited with code 255.