This method can be used to call a overwritten public method of a parent class on an child instance
The following code will output "A":
<?php
class A
{
public function foo()
{
return __CLASS__;
}
}
class B extends A
{
public function foo()
{
return __CLASS__;
}
}
$b = new B();
$reflection = new ReflectionObject($b);
$parentReflection = $reflection->getParentClass();
$parentFooReflection = $parentReflection->getMethod('foo');
$data = $parentFooReflection->invoke($b);
echo $data;
?>