Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created September 24, 2012 14:46
Show Gist options
  • Save francescoagati/3776312 to your computer and use it in GitHub Desktop.
Save francescoagati/3776312 to your computer and use it in GitHub Desktop.
simple extension method with reflection and __call in php
<?php
class St {
public static function pippa($obj) {
print_r($obj);
}
}
class Wrapper {
public static $extension_class='St';
public function __call($name,$arguments) {
$reflectionMethod = new ReflectionMethod( self::$extension_class, $name);
return $reflectionMethod->invokeArgs(null, array_merge(array($this),$arguments));
}
}
$obj=(new Wrapper());
$obj->pippa();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment