Dutch PHP Conference 2025 - Call For Papers

ReflectionEnumUnitCase::getValue

(PHP 8 >= 8.1.0)

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

Опис

public ReflectionEnumUnitCase::getValue(): UnitEnum

Returns the enum case object described by this reflection object.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

The enum case object described by this reflection object.

Приклади

Приклад #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());
?>

Поданий вище приклад виведе:

enum(Suit::Diamonds)

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top