Statement on glibc/iconv Vulnerability

ReflectionEnum::hasCase

(PHP 8 >= 8.1.0)

ReflectionEnum::hasCaseChecks for a case on an Enum

Descrição

public ReflectionEnum::hasCase(string $name): bool

Determines if a given case is defined on an Enum.

Parâmetros

name

The case to check for.

Valor Retornado

true if the case is defined, false if not.

Exemplos

Exemplo #1 ReflectionEnum::hasCase() example

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

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

var_dump($rEnum->hasCase('Hearts'));
var_dump($rEnum->hasCase('Horseshoes'));
?>

O exemplo acima produzirá:

bool(true)
bool(false)

Veja Também

add a note

User Contributed Notes

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