Consider the code:
class A {
function x(): string { return 'X'; }
function dump(): void {
error_log('In A: ' . $this->x());
}
}
class B extends A {
function x(): string { return 'XXX'; }
function dump(): void {
error_log('In B: ' . $this->x());
parent::dump();
}
}
$a = new A();
$b = new B();
$a->dump();
$b->dump();
This results in:
In A: X
In B: XXX
In A: XXX
, where I would expect the result to be:
In A: X
In B: XXX
In A: X
What is it that I do not understand?