php / 8.1.5 / reflectionenumunitcase.getvalue.html /

ReflectionEnumUnitCase::getValue

(PHP 8 >= 8.1.0)

ReflectionEnumUnitCase::getValueGets the enum case object described by this reflection object

Description

public ReflectionEnumUnitCase::getValue(): UnitEnum

Returns the enum case object described by this reflection object.

Parameters

This function has no parameters.

Return Values

The enum case object described by this reflection object.

Examples

Example #1 ReflectionEnum::getValue() example

<?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:

enum(Suit::Diamonds)

See Also

© 1997–2021 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/reflectionenumunitcase.getvalue.php