<?php
abstract class A
{
public function renderSomethingRecursive()
{
static $inside = 0;
echo "CALL: ", __CLASS__, '::', __FUNCTION__, "($inside) \n";
$inside++;
if ($inside > 10) return;
// this function can call itself
self::renderSomethingRecursive(); // ERROR!!!!
}
abstract public function addSomething($value);
}
class B extends A
{
public function renderSomethingRecursive()
{
static $inside = 0;
echo "CALL: ", __CLASS__, '::', __FUNCTION__, "($inside) \n";
$inside++;
throw new Exception ('This time this method must not be called!');
}
public function addSomething ($value)
{
static $inside = 0;
echo "CALL: ", __CLASS__, '::', __FUNCTION__, "($inside) \n";
if ($inside > 10) return;
$inside++;
parent::renderSomethingRecursive();
}
}
$obj = new B();
$obj->addSomething('value');