php8.5
Home/ Manual/ reflection / reflectionclassconstant/ ReflectionClassConstant::isDeprecated

ReflectionClassConstant::isDeprecated

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Checks if deprecated

Description

ReflectionClassConstant::isDeprecated(): bool

Checks whether the class constant is deprecated.

Parameters Parameters

Return Values

true if it's deprecated, otherwise false

Examples

ReflectionClassConstant::isDeprecated example

php
<?php
class Basket {
    #[\Deprecated(message: 'use Basket::APPLE instead')]
    public const APLE = 'apple';

    public const APPLE = 'apple';
}
$classConstant = new ReflectionClassConstant('Basket', 'APLE');
var_dump($classConstant->isDeprecated());
?>

The above example will output:

output
bool(true)

See Also

  • Deprecated
  • ReflectionClassConstant::getDocComment

Source: reference/reflection/reflectionclassconstant/isdeprecated.xml · from the official PHP manual (php/doc-en)