On 14/03/2021 19:40, Matthew Brown wrote:
It's maybe possible in the special case of implementing interfaces, but
it's unsound for general inheritance:
<?php
class A {
public int $someInt = 0;
public function getSomeInt() : int {
return $this->someInt;
}
}
class B extends A {
public static function getSomeInt() : int {
return parent::getSomeInt();
}
}
Can you explain what this is illustrating? Right now, it doesn't
compile, but that's what Gert was suggesting be changed, so the 3v4l
link isn't very enlightening.
From the point of view of the contract of the class, it's fine:
$foo->getSomeInt() is still a legal call if $foo is actually an instance
of B.
Are you saying that having the parent::getSomeInt() call fail would be
problematic?
Regards,
--
Rowan Tommins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php