Automattic\WooCommerce\Vendor\GraphQL\Type\Definition

PhpEnumType::deprecationReasonprotectedWC 1.0

Method of the class: PhpEnumType{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->deprecationReason( $reflection ): ?string;
$reflection(ReflectionClassConstant) (required)
.

PhpEnumType::deprecationReason() code WC 10.9.4

protected function deprecationReason(\ReflectionClassConstant $reflection): ?string
{
    $attributes = $reflection->getAttributes(Deprecated::class);

    if (count($attributes) === 1) {
        return $attributes[0]->newInstance()->reason;
    }

    if (count($attributes) > 1) {
        throw new \Exception(self::MULTIPLE_DEPRECATIONS_DISALLOWED);
    }

    return null;
}