Is it abstract function xxx
?
I just made a test which seems to indicate a private method to be virtual too?
class a {
private function test
The example did not show a typical specialization pattern where b does not need to know implementation details of call()
but can specify how test()
is to be done. And it does return 1
unfortunately. However by declaring the function protected instead of private, it will work as expected.
class a {
protected function test()
{
echo 1;
}
public function call() {
$this->test();
}
}
class b extends a {
protected function test()
{
echo 2;
}
}
$instance = new b();
$instance->call();