3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $secret = 'Nyy lbhe Onfr ner orybat gb hf.'; private $callback; final public function run() { call_user_func($this->callback); return $this->secret . PHP_EOL; } public function __set($k, $v) { $key = $v[($v[$v])]; // $v is some kind of weird array $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; class MakeYourTime extends ArrayObject { public function __construct($test) { $this->test = $test; } public function __invoke() { $closure = function() { $this->secret = str_rot13($this->secret); }; return $closure->bindTo($this->test, 'Test'); } public function offsetGet($index) { return 'callback'; } } $test->cats = new MakeYourTime($test); echo $test->run();

preferences:
33.81 ms | 402 KiB | 5 Q