Created
December 4, 2012 08:37
-
-
Save assertchris/4201869 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function create($name, $parameters = []) | |
| { | |
| $name = str_replace(".", "\\", $name); | |
| $reflection = new ReflectionClass($name); | |
| return $reflection->newInstanceArgs($parameters); | |
| } | |
| create("Some.Namespaced.Class", [$arg1, $arg2]); # -> new Some\Namespaced\Class($arg1, $arg2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment