Answer by powtac for PHP Reflection - Get Method Parameter Type As String
This is a better regular expression than the one from that answer. It will work even when the parameter is optional. preg_match('~>\s+([a-z]+)\s+~', (string)$ReflectionParameter, $result); $type =...
View ArticleAnswer by masakielastic for PHP Reflection - Get Method Parameter Type As String
getType method can be used since PHP 7.0. class Foo {} class Bar {} class MyClass { public function baz(Foo $foo, Bar $bar) {} } $class = new ReflectionClass('MyClass'); $method =...
View ArticleAnswer by Matúš Duchoň for PHP Reflection - Get Method Parameter Type As String
I supposed this is what you are looking for: class MyClass { function __construct(AnotherClass $requiredParameter, YetAnotherClass $optionalParameter = null) { } } $reflector = new...
View ArticleAnswer by neofraktal for PHP Reflection - Get Method Parameter Type As String
You could use Zend Framework 2. $method_reflection = new \Zend\Code\Reflection\MethodReflection( 'class', 'method' ); foreach( $method_reflection->getParameters() as $reflection_parameter ) { $type...
View ArticleAnswer by daanl for PHP Reflection - Get Method Parameter Type As String
I had similar problem, when checking getClass on reflection parameter when a class was not loaded. I made a wrapper function to get the class name from example netcoder made. Problem was that netcoder...
View ArticleAnswer by netcoder for PHP Reflection - Get Method Parameter Type As String
I think the only way is to export and manipulate the result string: $refParam = new ReflectionParameter(array('Foo', 'Bar'), 0); $export = ReflectionParameter::export( array(...
View ArticlePHP Reflection - Get Method Parameter Type As String
I'm trying to use PHP reflection to dynamically load the class files of models automatically based upon the type of parameter that is in the controller method. Here's an example controller method....
View Article