PHP のリフレクション機能を使用して、メソッドからパラメーター名のリストを取得したいと考えています。私はこのようなクラスを持っています:
class TestClass {
public function method($id, $person, $someotherparam) {
return;
}
}
次のようなコードを使用してリストを取得できます。
$r = new ReflectionClass('TestClass');
$methods = $r->getMethods();
foreach($methods as $method) {
$params = $method->getParameters();
$p = $params[0]; // how can I combine this and the next line?
echo $p->name;
配列からクラスメンバーにアクセスする方法を知りたいので、割り当てを行う必要はありません。これは可能ですか?のようなものを試しましecho ($params[0])->nameたが、エラーが発生します。