CakeFest 2024: The Official CakePHP Conference

ReflectionClassConstant クラス

(PHP 7 >= 7.1.0, PHP 8)

はじめに

ReflectionClassConstant クラスは、クラス定数に関する情報を報告します。

クラス概要

class ReflectionClassConstant implements Reflector {
/* 定数 */
public const int IS_PUBLIC;
public const int IS_PROTECTED;
public const int IS_PRIVATE;
public const int IS_FINAL;
/* プロパティ */
public string $name;
public string $class;
/* メソッド */
public __construct(object|string $class, string $constant)
public static export(mixed $class, string $name, bool $return = ?): string
public getAttributes(?string $name = null, int $flags = 0): array
public getModifiers(): int
public getName(): string
public getValue(): mixed
public isEnumCase(): bool
public isFinal(): bool
public isPrivate(): bool
public isProtected(): bool
public isPublic(): bool
public __toString(): string
}

プロパティ

name

クラス定数の名前。読み取り専用です。 書き込もうとすると ReflectionException がスローされます。

class

クラス定数が定義されたクラス名。読み取り専用です。 書き込もうとすると ReflectionException がスローされます。

定義済み定数

ReflectionClassConstant の修飾子

ReflectionClassConstant::IS_PUBLIC

アクセス権が public であることを示します。 PHP 7.4.0 より前のバージョンでは、この値は 256 でした。

ReflectionClassConstant::IS_PROTECTED

アクセス権が protected であることを示します。 PHP 7.4.0 より前のバージョンでは、この値は 512 でした。

ReflectionClassConstant::IS_PRIVATE

アクセス権が private であることを示します。 PHP 7.4.0 より前のバージョンでは、この値は 1024 でした。

ReflectionClassConstant::IS_FINAL

定数が final であることを示します。 PHP 8.1.0 以降で利用可能です。

注意:

これらの定数の値は、PHP のバージョンが異なると変更される可能性があります。 これらの値を直接用いず、常に定数を使うことを推奨します。

変更履歴

バージョン 説明
8.0.0 ReflectionClassConstant::export() は、削除されました。

目次

add a note

User Contributed Notes

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