-
-
Save aligoren/750b52b83db375662efa8b5b9c34ea98 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