Created
September 24, 2012 14:46
-
-
Save francescoagati/3776312 to your computer and use it in GitHub Desktop.
simple extension method with reflection and __call in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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