- print_r: documentation ( source)
- preg_replace: documentation ( source)
<?php
namespace Wl\A;
class B {
public function get() {
return "BBBBB";
}
}
$b = new B();
$funct = function (B $b) { print_r($b::get()); };
$refParam = new \ReflectionParameter($funct, 0);
$export = \ReflectionParameter::export(
array(
$refParam->getDeclaringClass()->name,
$refParam->getDeclaringFunction()->name
),
$refParam->name,
true
);
$type = preg_replace('/.*?(\w+)\s+\$'.$refParam->name.'.*/', '\\1', $export);
echo "ARGS:\n";
echo $type;
exit;
try {
$a->b("");
} catch (\Exception $e) {
echo "catched";
} catch (\TypeError $e) {
echo "subidubi";
}