
ReflectionClassConstant::isDeprecated 메소드는 deprecated 상수만 체크합니다.
이 메소드는 PHPDoc에서 deprecated로 지정된 상수만 체크합니다.
예를 들어, 아래 코드에서 'deprecated' 상수가 체크되지만, 'nonDeprecated' 상수는 체크되지 않습니다.
#hostingforum.kr
php
/**
* @deprecated
*/
class MyClass {
const deprecated = 'deprecated';
const nonDeprecated = 'nonDeprecated';
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionConstant = $reflectionClass->getConstant('deprecated');
echo ReflectionClassConstant::isDeprecated($reflectionConstant) ? 'deprecated' : 'nonDeprecated'; // deprecated
$reflectionConstant = $reflectionClass->getConstant('nonDeprecated');
echo ReflectionClassConstant::isDeprecated($reflectionConstant) ? 'deprecated' : 'nonDeprecated'; // nonDeprecated
위의 코드에서 'deprecated' 상수는 PHPDoc에서 deprecated로 지정되어 있기 때문에 ReflectionClassConstant::isDeprecated 메소드는 true를 반환합니다. 반면 'nonDeprecated' 상수는 deprecated로 지정되어 있지 않기 때문에 false를 반환합니다.
2025-06-25 16:16