I have a abstract class User:
abstract class User
and a child of User, "Administrator":
class Administrator extends User
When i create a new Administrator and want to persist with this signature:
public function persist(Administrator $object): void
$this->repo->persist(new Administrator())
PHPSTAN is complaining:
Parameter #1 $object of method AdministratorRepository::persist() expects Administrator, User given
Why it thinks it's User where i am instantiating an new Administrator directly? I think its about Covariance and Contravariance but cant figure out how to tell PHPSTAN correctly?
I checked the https://phpstan.org/blog/whats-up-with-template-covariant but did not get a solution to work properly.