Statement on glibc/iconv Vulnerability

ReflectionEnum::hasCase

(PHP 8 >= 8.1.0)

ReflectionEnum::hasCase列挙型が case を持つかを調べる

説明

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

指定された case が列挙型に定義されているかを判定します。

パラメータ

name

調べる case の名前。

戻り値

case が定義されていたら true を返します。 そうでない場合、false を返します。

例1 ReflectionEnum::hasCase() の例

<?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'));
?>

上の例の出力は以下となります。

bool(true)
bool(false)

参考

add a note

User Contributed Notes

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