"php reflection - get method parameter type as string" Code Answer

3

I think the only way is to export and manipulate the result string:

$refParam = new ReflectionParameter(array('Foo', 'Bar'), 0);

$export = ReflectionParameter::export(
   array(
      $refParam->getDeclaringClass()->name, 
      $refParam->getDeclaringFunction()->name
   ), 
   $refParam->name, 
   true
);

$type = preg_replace('/.*?(w+)s+$'.$refParam->name.'.*/', '\1', $export);
echo $type;
By dinesh2kkids-961553589e7d on August 28 2022

Answers related to “php reflection - get method parameter type as string”

Only authorized users can answer the search term. Please sign in first, or register a free account.