Since: 7.1

class ReflectionClassConstant implements Reflector (View source)

The ReflectionClassConstant class reports information about a class constant.

Constants

IS_PUBLIC Since: 8.0

Indicates that the constant is public.

IS_PROTECTED Since: 8.0

Indicates that the constant is protected.

IS_PRIVATE Since: 8.0

Indicates that the constant is private.

IS_FINAL Since: 8.1

Properties

string $name
class-string $class
bool Since: 8.1
$isFinal

Methods

__construct(class-string|object $class, string $constant)

ReflectionClassConstant constructor.

static string|null
export(string|object $class, string $name, bool $return = false)

Export

getDeclaringClass()

Gets declaring class

string|false
getDocComment()

Gets doc comments

int
getModifiers()

Gets the class constant modifiers

string
getName()

Get name of the constant

mixed
getValue()

Gets value

bool
isPrivate()

Checks if class constant is private

bool
isProtected()

Checks if class constant is protected

bool
isPublic()

Checks if class constant is public

string
__toString()

Returns the string representation of the ReflectionClassConstant object.

array
getAttributes(string|null $name = null, int $flags = 0)

Gets Attributes

bool
isEnumCase()

Checks if class constant is an Enum case

bool
isFinal()

Checks if class constant is final

bool
hasType()

Checks if class constant has a type

getType()

Gets a class constant's type

bool
isDeprecated()

Checks if deprecated

Details

__construct(class-string|object $class, string $constant)

Since: 7.1

ReflectionClassConstant constructor.

Parameters

class-string|object $class

Either a string containing the name of the class to reflect, or an object.

string $constant

The name of the class constant.

Exceptions

Exception

static string|null export(string|object $class, string $name, bool $return = false)

Since: 7.1

Export

Exports a reflection.

Parameters

string|object $class

The reflection to export.

string $name

The class constant name.

bool $return

Setting to {\true} will return the export, as opposed to emitting it. Setting to {\false} (the default) will do the opposite.

Return Value

string|null

ReflectionClass getDeclaringClass()

Since: 7.1

Gets declaring class

Return Value

ReflectionClass

A ReflectionClass object.

string|false getDocComment()

Since: 7.1

Gets doc comments

Return Value

string|false

The doc comment if it exists, otherwise {\false}

int getModifiers()

Since: 7.1

Gets the class constant modifiers

Return Value

int

A numeric representation of the modifiers. The actual meanings of these modifiers are described in the predefined constants.

string getName()

Since: 7.1

Get name of the constant

Return Value

string

Returns the constant's name.

mixed getValue()

Since: 7.1

Gets value

Return Value

mixed

The value of the class constant.

bool isPrivate()

Since: 7.1

Checks if class constant is private

Return Value

bool

true if the class constant is private, otherwise false

bool isProtected()

Since: 7.1

Checks if class constant is protected

Return Value

bool

true if the class constant is protected, otherwise false

bool isPublic()

Since: 7.1

Checks if class constant is public

Return Value

bool

true if the class constant is public, otherwise false

string __toString()

Since: 7.1

Returns the string representation of the ReflectionClassConstant object.

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

array getAttributes(string|null $name = null, int $flags = 0)

Since: 8.0

Gets Attributes

Returns all attributes declared on this class constant as an array of ReflectionAttribute.

Parameters

string|null $name

Name of an attribute class

int $flags

Сriteria by which the attribute is searched.

Return Value

array

Array of attributes, as a ReflectionAttribute object.

bool isEnumCase()

Checks if class constant is an Enum case

Checks if the class constant is an Enum case.

Return Value

bool

true if the class constant is an Enum case; false otherwise.

bool isFinal()

Since: 8.1

Checks if class constant is final

Checks if the class constant is final.

Return Value

bool

true if the class constant is final, otherwise false

bool hasType()

Since: 8.3

Checks if class constant has a type

Checks if the class constant has a type associated with it.

Return Value

bool

ReflectionType|null getType()

Since: 8.3

Gets a class constant's type

Gets the associated type of a class constant.

Return Value

ReflectionType|null

bool isDeprecated()

Since: 8.4

Checks if deprecated

Checks whether the class constant is deprecated.

Return Value

bool