3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Super { private $aliases; protected function __construct(array $aliases) { $this->aliases = $aliases; } public function __call($name, $arguments) { /* if $name is an alias, replace it */ if (isset($this->aliases[$name])) { $name = $this->aliases[$name]; } /* throw an exception if the method is undefined */ if (!method_exists($this, $name)) { throw new Exception("The specified method or method alias is undefined in the current context"); } /* finally, call the method by its actual name */ return $this->$name($arguments); } } class Sub extends Super { public function __construct() { parent::__construct(array( "alias" => "actualMethod" )); } public function actualMethod() { echo "Inside the actual method"; } } $sub = new Sub; $sub->actualMethod(); $sub->alias();

preferences:
41.4 ms | 402 KiB | 5 Q