
ReflectionMethod::isAbstract 메서드는 ReflectionClass::isAbstract 메서드와 유사하게, 클래스의 메서드가 추상 메서드인지 아닌지를 확인하는 데 사용됩니다.
이 메서드는 메서드 선언부에 abstract 키워드가 포함되어 있는 경우 true를 반환하며, 그렇지 않은 경우 false를 반환합니다.
예를 들어, 다음 코드를 살펴보겠습니다.
#hostingforum.kr
php
class AbstractClass {
public abstract function abstractMethod();
public function nonAbstractMethod() {}
}
$reflectionClass = new ReflectionClass('AbstractClass');
$reflectionMethod = $reflectionClass->getMethod('abstractMethod');
echo ReflectionMethod::isAbstract($reflectionMethod) ? 'true' : 'false'; // true
$reflectionMethod = $reflectionClass->getMethod('nonAbstractMethod');
echo ReflectionMethod::isAbstract($reflectionMethod) ? 'true' : 'false'; // false
위 코드에서, `abstractMethod`은 추상 메서드이므로 `ReflectionMethod::isAbstract` 메서드는 true를 반환합니다. 반면, `nonAbstractMethod`은 일반 메서드이므로 false를 반환합니다.
이러한 메서드는 클래스의 메서드가 추상 메서드인지 아닌지를 확인하는 데 사용할 수 있습니다.
2025-06-22 14:30