所以,基本上,有没有办法在不使用慢速回溯的情况下以漂亮的方式做到这一点?现在我这样做:
class BaseTest {
public function magic() {
$args = func_get_args();
$class = new ReflectionClass(get_called_class());
$method = $class->getMethod($args[0]);
$magic = array();
foreach($method->getParameters() as $k => $parameter) {
$magic[$parameter->getName()] = $args[$k];
}
return $magic;
}
}
class Test extends BaseTest {
public function testWithParams($param1, $param2) {
return $this->magic(__FUNCTION__, $param1, $param2);
}
}
$q = new Test();
var_dump($q->testWithParams(1,2));