Description
I was playing around with property hooks and noticed the following (in my opinion) inconsistency when combining property hooks with inheritance and __get and __set:
The following code (for __get, the same applies for __set in https://3v4l.org/Q2OAj):
<?php
class ParentClass {
public function __get(string $name) {
echo "__get($name) was called\n";
}
}
class ChildClass extends ParentClass {
public $foo {
get => parent::$foo::get();
}
}
(new ParentClass)->foo;
(new ChildClass)->foo;
Resulted in this output:
__get(foo) was called
Fatal error: Uncaught Error: Undefined property ParentClass::$foo in /in/Y27mB:13
But I expected this output instead:
__get(foo) was called
__get(foo) was called
I tried searching the RFC and existing PHP issues, but I haven't found this example - apologies if I missed it. Barring something saying that this shouldn't work, I would expect it to.
PHP Version
PHP 8.4.3
Operating System
No response