
이러한 인터페이스 목록에서 인터페이스 자체를 제외하고, implements된 클래스의 인터페이스만 얻으려면 다음과 같이 처리할 수 있습니다.
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('implementsClass');
$interfaces = $reflectionClass->getInterfaces();
$implementsInterfaces = array();
foreach ($interfaces as $interface) {
if ($interface->getName() !== $reflectionClass->getName()) {
$implementsInterfaces[] = $interface;
}
}
위 코드에서, implements된 클래스의 인터페이스만을 `$implementsInterfaces` 변수에 저장합니다.
또는, PHP 8.0 이상부터는 `ReflectionClass::getImplementedInterfaces()` 메서드를 사용할 수 있습니다.
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('implementsClass');
$implementsInterfaces = $reflectionClass->getImplementedInterfaces();
2025-06-04 05:02