Constants
in package
FinalYes
Utility functions for use when examining constants declared using the "const" keyword.
Tags
Table of Contents
Methods
- getAttributeOpeners() : array<string|int, int>
- Retrieve the stack pointers to the attribute openers for any attribute block which applies to the constant declaration.
- getProperties() : array<string, string|int|bool>
- Retrieve the visibility and implementation properties of an OO constant.
Methods
getAttributeOpeners()
Retrieve the stack pointers to the attribute openers for any attribute block which applies to the constant declaration.
public
static getAttributeOpeners(File $phpcsFile, int $stackPtr) : array<string|int, int>
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position in the stack of the
T_CONSTtoken to acquire the attributes for.
Tags
Return values
array<string|int, int> —Array with the stack pointers to the applicable attribute openers or an empty array if there are no attributes attached to the constant declaration.
getProperties()
Retrieve the visibility and implementation properties of an OO constant.
public
static getProperties(File $phpcsFile, int $stackPtr) : array<string, string|int|bool>
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position in the stack of the
T_CONSTtoken to acquire the properties for.
Tags
Return values
array<string, string|int|bool> —Array with information about the constant declaration. The format of the return value is:
array(
'scope' => string, // Public, private, or protected.
'scope_token' => integer|false, // The stack pointer to the scope keyword or
// FALSE if the scope was not explicitly specified.
'is_final' => boolean, // TRUE if the final keyword was found.
'final_token' => integer|false, // The stack pointer to the final keyword
// or FALSE if the const is not declared final.
'type' => string, // The type of the const (empty if no type specified).
'type_token' => integer|false, // The stack pointer to the start of the type
// or FALSE if there is no type.
'type_end_token' => integer|false, // The stack pointer to the end of the type
// or FALSE if there is no type.
'nullable_type' => boolean, // TRUE if the type is preceded by the
// nullability operator.
'name_token' => integer, // The stack pointer to the constant name.
// Note: for group declarations this points to the
// name of the first constant.
'equal_token' => integer, // The stack pointer to the equal sign.
// Note: for group declarations this points to the
// equal sign of the first constant.
);