Since: 8.4

class ReflectionConstant implements Reflector (View source)

The ReflectionConstant class reports information about a global constant.

Properties

string $name

Methods

__construct(string $name)

Constructs a ReflectionConstant

string
getName()

Gets name

string
getNamespaceName()

Gets namespace name

string
getShortName()

Gets short name

mixed
getValue()

Gets value

bool
isDeprecated()

Checks if deprecated

string
__toString()

Returns string representation

string|false
getFileName()

Gets name of the defining file

getExtension()

Gets ReflectionExtension of the defining extension

string|false
getExtensionName()

Gets name of the defining extension

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

Gets Attributes

bool
inNamespace()

No description

Details

__construct(string $name)

Constructs a ReflectionConstant

Constructs a new ReflectionConstant object.

Parameters

string $name

The name of the constant.

Exceptions

ReflectionException

string getName()

Gets name

Gets the name of the constant.

Return Value

string

The constants name, which is composed of its namespace and name.

string getNamespaceName()

Gets namespace name

Gets the namespace name of the constant.

Return Value

string

The namespace name, or an empty string for the global namespace.

string getShortName()

Gets short name

Gets the short name of the constant, the part without the namespace.

Return Value

string

The short name of the constant.

mixed getValue()

Gets value

Gets the value of the constant.

Return Value

mixed

The value of the constant.

bool isDeprecated()

Checks if deprecated

Checks whether the constant is deprecated.

Return Value

bool

true if it's deprecated, otherwise false

string __toString()

Returns string representation

Returns the string representation of the ReflectionConstant object.

Return Value

string

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

string|false getFileName()

Since: 8.5

Gets name of the defining file

Gets the filename of the file in which the constant has been defined.

Return Value

string|false

ReflectionExtension|null getExtension()

Since: 8.5

Gets ReflectionExtension of the defining extension

Gets a ReflectionExtension object for the extension which defined the constant.

Return Value

ReflectionExtension|null

string|false getExtensionName()

Since: 8.5

Gets name of the defining extension

Gets the name of the extension which defined the constant.

Return Value

string|false

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

Since: 8.5

Gets Attributes

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

Parameters

string|null $name
int $flags

Return Value

array

bool inNamespace()

Since: 8.6

No description

Return Value

bool