Documentation

ReflectionClassConstant
in package
implements Reflector

Somehow the standard reflection library didn't include class constants until 7.1.

ReflectionClassConstant corrects that omission.

Interfaces, Classes and Traits

Reflector

Table of Contents

$class  : mixed
$name  : mixed
$value  : mixed
__construct()  : mixed
Construct a ReflectionClassConstant object.
__toString()  : string
To string.
create()  : ReflectionClassConstant|ReflectionClassConstant
Get a ReflectionClassConstant instance.
export()  : null|string
Exports a reflection.
getDeclaringClass()  : ReflectionClass
Gets the declaring class.
getDocComment()  : false
Get the constant's docblock.
getEndLine()  : mixed
Get the code end line.
getFileName()  : mixed
Gets the constant's file name.
getModifiers()  : int
Gets the class constant modifiers.
getName()  : string
Gets the constant name.
getStartLine()  : mixed
Get the code start line.
getValue()  : mixed
Gets the value of the constant.
isPrivate()  : bool
Checks if class constant is private.
isProtected()  : bool
Checks if class constant is protected.
isPublic()  : bool
Checks if class constant is public.

Properties

Methods

__construct()

Construct a ReflectionClassConstant object.

public __construct(string|object $class, string $name) : mixed
Parameters
$class : string|object
$name : string
Return values
mixed

create()

Get a ReflectionClassConstant instance.

public static create(string|object $class, string $name) : ReflectionClassConstant|ReflectionClassConstant

In PHP >= 7.1, this will return a \ReflectionClassConstant from the standard reflection library. For older PHP, it will return this polyfill.

Parameters
$class : string|object
$name : string
Return values
ReflectionClassConstant|ReflectionClassConstant

export()

Exports a reflection.

public static export(string|object $class, string $name[, bool $return = false ]) : null|string
Parameters
$class : string|object
$name : string
$return : bool = false

pass true to return the export, as opposed to emitting it

Return values
null|string

getDeclaringClass()

Gets the declaring class.

public getDeclaringClass() : ReflectionClass
Return values
ReflectionClass

getEndLine()

Get the code end line.

public getEndLine() : mixed
Tags
throws
RuntimeException
Return values
mixed

getFileName()

Gets the constant's file name.

public getFileName() : mixed

Currently returns null, because if it returns a file name the signature formatter will barf.

Return values
mixed

getModifiers()

Gets the class constant modifiers.

public getModifiers() : int

Since this is only used for PHP < 7.1, we can just return "public". All the fancier modifiers are only available on PHP versions which have their own ReflectionClassConstant class :)

Return values
int

getStartLine()

Get the code start line.

public getStartLine() : mixed
Tags
throws
RuntimeException
Return values
mixed

isPrivate()

Checks if class constant is private.

public isPrivate() : bool
Return values
bool

false

isProtected()

Checks if class constant is protected.

public isProtected() : bool
Return values
bool

false

isPublic()

Checks if class constant is public.

public isPublic() : bool
Return values
bool

true

Search results