php8.5
Home/ Manual/ reflection / reflectionenumunitcase/ ReflectionEnumUnitCase::getValue

ReflectionEnumUnitCase::getValue

PHP function Edit on GitHub ✎

(PHP 8 >= 8.1.0)

Gets the enum case object described by this reflection object

Description

ReflectionEnumUnitCase::getValue(): UnitEnum

Returns the enum case object described by this reflection object.

Parameters Parameters

Return Values

The enum case object described by this reflection object.

Examples

ReflectionEnum::getValue example

php
<?php
enum Suit
{
    case Hearts;
    case Diamonds;
    case Clubs;
    case Spades;
}

$rEnum = new ReflectionEnum(Suit::class);

$rCase = $rEnum->getCase('Diamonds');

var_dump($rCase->getValue());
?>

The above example will output:

output
enum(Suit::Diamonds)

See Also

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