<?php class render { /** @var array */ private static $extensions; public static function __callStatic($function, $args) { // check if method exists if ( method_exists( __CLASS__, $function )) { self::{$function}(self::$args); } elseif (isset(self::$extensions[$function])) { (self::$extensions[$function])($args); } } public static function title($args) { echo 'Calling title()', PHP_EOL; } public static function register(string $name, callable $callback) { self::$extensions[$name] = $callback; } } render::register('custom', function(...$args) { echo 'Calling custom function', PHP_EOL; var_dump($args); }); render::title(1, 2, 3, 4); render::custom(1, 2, 3, 4);
You have javascript disabled. You will not be able to edit any code.