<?php
class Caller
{
public function overwritten()
{
echo 'Overwriting from ' . __CLASS__ . PHP_EOL;
}
public static function call()
{
echo 'Calling from ' . __CLASS__ . PHP_EOL;
}
}
class StaticCaller extends Caller
{
public function overwritten()
{
echo 'Overwriting from ' . __CLASS__ . PHP_EOL;
}
public function staticCall()
{
static::call();
static::overwritten();
}
}
class SelfCaller extends Caller
{
public function overwritten()
{
echo 'Overwriting from ' . __CLASS__ . PHP_EOL;
}
public function selfCall()
{
self::call();
self::overwritten();
}
}
class ThisCaller extends Caller
{
public function overwritten()
{
echo 'Overwriting from ' . __CLASS__ . PHP_EOL;
}
public function thisCall()
{
$this->call();
$this->overwritten();
}
}
$staticCaller = new StaticCaller();
$selfCaller = new SelfCaller();
$thisCaller = new ThisCaller();
$staticCaller->staticCall();
$selfCaller->selfCall();
$thisCaller->thisCall();