
ReflectionMethod::getPrototype 메서드는 클래스의 메서드에 대한 정보를 반환하는 데 사용됩니다.
이 메서드는 클래스의 메서드에 대한 프로토타입 정보를 반환하므로, 클래스의 메서드가 어떤 타입의 인자를 받고, 어떤 타입의 값을 반환하는지 알 수 있습니다.
사용 예시:
#hostingforum.kr
php
class Test {
public function test($a, $b) {
return $a + $b;
}
}
$reflectionMethod = new ReflectionMethod('Test', 'test');
$prototype = $reflectionMethod->getPrototype();
echo $prototype->getName(); // Test::test
echo $prototype->getNumberOfParameters(); // 2
echo $prototype->getParameter(0)->getName(); // $a
echo $prototype->getParameter(1)->getName(); // $b
echo $prototype->getReturnType()->getName(); // int
이 예시에서는 `ReflectionMethod::getPrototype` 메서드를 사용하여 `Test` 클래스의 `test` 메서드에 대한 프로토타입 정보를 가져옵니다.
2025-06-25 21:45