Skip to content

Instantly share code, notes, and snippets.

@DNA
Created December 11, 2013 19:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DNA/7917360 to your computer and use it in GitHub Desktop.
Save DNA/7917360 to your computer and use it in GitHub Desktop.
<?php
class myStdClass {
public function __call($method, $args) {
if (isset($this->$method)) {
return call_user_func_array($this->$method, $args);
}
}
}
$x = new myStdClass;
$x->a = function () {
$D = new myStdClass;
$D->c = 5;
$D->b = function () use ($D) {
return $D->c;
};
return $D;
};
echo $x->a()->b();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment