Description
The following code (https://3v4l.org/7Xf05#v8.4.10):
<?phpabstractclass P {
abstractprotected$foo { get; }
}
classC1extends P {
protected$foo = 1;
}
classC2extends P {
protected$foo = 2;
staticfunctionfoo($c) { return$c->foo; }
}
var_dump(C2::foo(newC2));
var_dump(C2::foo(newC1));Resulted in this output:
int(2)
Fatal error: Uncaught Error: Cannot access protected property C1::$foo in /in/7Xf05:14
Stack trace:
#0 /in/7Xf05(18): C2::foo(Object(C1))
#1 {main}
thrown in /in/7Xf05 on line 14
But I expected this output instead:
Doing the same with methods works flawlessly (https://3v4l.org/iQo81#v8.4.10):
<?phpabstractclass P {
abstractprotectedfunctionfoo();
}
classC1extends P {
protectedfunctionfoo() { return1; }
}
classC2extends P {
protectedfunctionfoo() { return2; }
staticfunctiondoFoo($c) { return$c->foo(); }
}
var_dump(C2::doFoo(newC2));
var_dump(C2::doFoo(newC1));results in the expected
PHP Version
Operating System
No response
Description
The following code (https://3v4l.org/7Xf05#v8.4.10):
Resulted in this output:
But I expected this output instead:
Doing the same with methods works flawlessly (https://3v4l.org/iQo81#v8.4.10):
results in the expected
PHP Version
Operating System
No response