-
Couldn't load subscription status.
- Fork 8k
Closed
Description
Description
The following code:
<?php
abstract class BarAbstract
{
abstract public string $foo {
get;
set;
}
}
class Bar extends BarAbstract
{
public string $foo {
get => $this->foo.' (Bar)';
set => $value;
}
}
class BarChild extends Bar
{
public string $foo {
set {
parent::$foo::set($value);
}
}
}
$barChild = new BarChild;
try {
$barChild->foo = 'qwerty';
echo $barChild->foo;
} catch (\Throwable $e) {
echo $e->getMessage();
}Resulted in this output:
Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
But I expected this output instead:
qwerty (Bar)
The get and set hooks of the foo property of the Bar class do not work when called from the BarChild class. If the Bar class does not extend BarAbstract, no error occurs.
PHP Version
PHP 8.4.4
Operating System
No response