PHPCSUtils 1.1.0

Constants
in package

FinalYes

Utility functions for use when examining constants declared using the "const" keyword.

Tags
since
1.1.0

Table of Contents

Methods

getProperties()  : array<string, string|int|bool>
Retrieve the visibility and implementation properties of an OO constant.

Methods

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_CONST token to acquire the properties for.

Tags
since
1.1.0
throws
TypeError

If the $stackPtr parameter is not an integer.

throws
OutOfBoundsStackPtr

If the token passed does not exist in the $phpcsFile.

throws
UnexpectedTokenType

If the token passed is not a T_CONST token.

throws
ValueError

If the specified position is not an OO constant.

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.
);

        
On this page

Search results