Consider class A and B as follows:
Class A {
public function A1 (){
$this->A2();
}
public function A2 (){}
}
Class B extends A {
public function A2 () {} // overriding A2
}
$instance= new B ();
$instance -> A1(); // Calling A1 of class B which calls the parent class A1 actually
As you can see Class B overrides function A2. A2 is called from class A method A1
The problem is that it calls the A2 in class A and not the overriding A2 in class B.
How can I make sure that if I override a method, the overriding method will be invoked even if it is called from a parent class (A) method (when the actual object is an instance of the overriding (B) class.