Given are the following classes with class A
coming from an external library so that I can not change it:
class A {
public function test () {
$this->privateMethod();
}
private function privateMethod () {
echo('A');
}
}
class B extends A {
private function privateMethod () {
echo('B');
}
}
$b = new B();
$b->test();
This results in A
being printed out by A::privateMethod
instead of B
from B::privateMethod
, because the latter is not visible to A::test
as explained here.
How else can I modify the behavior of this private library method in the cleanest possible way (e.g. without code duplication from copying the whole class and changing it)?