
ReflectionParameter::isCallable 메서드는 호출 가능한 객체인지 여부를 확인합니다.
이 메서드는 다음 경우에 true를 반환합니다.
- 함수
- 클래스
- 인터페이스
- Closure (익명 함수)
- 객체의 메서드
반면, 다음 경우에 false를 반환합니다.
- 기본 타입 (int, string, array 등)
- 객체의 속성 (속성이 호출 가능한 객체인 경우에도 false를 반환)
- null 또는 false
이 메서드는 호출 가능한 객체의 타입을 확인하기 때문에, 객체의 타입이 호출 가능한 객체인 경우 true를 반환합니다.
예를 들어, 다음 코드는 true를 반환합니다.
#hostingforum.kr
php
$reflection = new ReflectionParameter('function', 'test');
echo $reflection->isCallable(); // true
$reflection = new ReflectionParameter('class', 'Test');
echo $reflection->isCallable(); // true
반면, 다음 코드는 false를 반환합니다.
#hostingforum.kr
php
$reflection = new ReflectionParameter('int', 'test');
echo $reflection->isCallable(); // false
$reflection = new ReflectionParameter('Test', 'test');
echo $reflection->isCallable(); // false
2025-05-09 01:29