@ 2013-02-12T01:33:26Z <?php
class Intercept {
protected $class = null;
protected $callback = null;
public function __construct($class, $callback = null) {
$this->class = new $class();
$this->callback = $callback;
}
protected function run_callback() {
$this->($this->callback)();
}
public function __get($name) {
$this->run_callback();
return $this->class->$name;
}
public function __set($name, $value) {
$this->run_callback();
return $this->class->$name = $value;
}
public function __isset($name) {
$this->run_callback();
return isset($this->class->$name);
}
public function __unset($name) {
$this->run_callback();
unset($this->class->$name);
}
public function __call($method, $args) {
$this->run_callback();
return call_user_func_array(array($this->class, $method), $args);
}
public function __toString() {
$this->run_callback();
return $this->class;
}
public function __invoke() {
$this->run_callback();
return $this->class();
}
}
class test {
public function hello() {
return 'world';
}
}
$closure = function() {
echo 123;
};
$test=new Intercept('test', $closure);
echo $test->hello();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.4.0 - 5.4.11 Parse error: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/A1vDY on line 15
Process exited with code 255 . Output for 5.3.0 - 5.3.21 Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in /in/A1vDY on line 15
Process exited with code 255 . preferences:dark mode live preview
169.76 ms | 1399 KiB | 41 Q