3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Container{ private $callables = []; public function __set(string $name,$value){ if($value instanceof Closure){ $this->callables[$name] = $value; } } public function __call(string $method, array $args){ if(isset($this->callables[$method])){ $callable = $this->callables[$method]; $callable($args); } } } $container = new Container(); $container->demo = function(){ return new Container(); }; var_dump($container->demo());

preferences:
62.66 ms | 402 KiB | 5 Q