Token
    
            
            in package
            
        
    
    
    
Representation of single token.
As a token prototype you should understand a single element generated by token_get_all.
Tags
Table of Contents
Methods
- __construct() : mixed
 - equals() : bool
 - Check if token is equals to given one.
 - equalsAny() : bool
 - Check if token is equals to one of given.
 - getCastTokenKinds() : array<int, int>
 - getClassyTokenKinds() : array<int, int>
 - Get classy tokens kinds: T_CLASS, T_INTERFACE and T_TRAIT.
 - getContent() : string
 - Get token's content.
 - getId() : int|null
 - Get token's id.
 - getKeywords() : array<int, int>
 - Generate array containing all keywords that exists in PHP version in use.
 - getMagicConstants() : array<int, int>
 - Generate array containing all predefined constants that exists in PHP version in use.
 - getName() : null|string
 - Get token's name.
 - getNameForId() : null|string
 - Get token's name.
 - getObjectOperatorKinds() : array<int, int>
 - Get object operator tokens kinds: T_OBJECT_OPERATOR and (if available) T_NULLSAFE_OBJECT_OPERATOR.
 - getPrototype() : array{: int, : string}|string
 - isArray() : bool
 - Check if token prototype is an array.
 - isCast() : bool
 - Check if token is one of type cast tokens.
 - isClassy() : bool
 - Check if token is one of classy tokens: T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM.
 - isComment() : bool
 - Check if token is one of comment tokens: T_COMMENT or T_DOC_COMMENT.
 - isGivenKind() : bool
 - Check if token is one of given kind.
 - isKeyCaseSensitive() : bool
 - A helper method used to find out whether a certain input token has to be case-sensitively matched.
 - isKeyword() : bool
 - Check if token is a keyword.
 - isMagicConstant() : bool
 - Returns if the token is of a Magic constants type.
 - isNativeConstant() : bool
 - Check if token is a native PHP constant: true, false or null.
 - isObjectOperator() : bool
 - Check if token is one of object operator tokens: T_OBJECT_OPERATOR or T_NULLSAFE_OBJECT_OPERATOR.
 - isWhitespace() : bool
 - Check if token is whitespace.
 - toArray() : array{id: int|null, name: string|null, content: string, isArray: bool, changed: bool}
 - toJson() : string
 
Methods
__construct()
    public
                    __construct(array{: int, : string}|string $token) : mixed
    Parameters
- $token : array{: int, : string}|string
 - 
                    
token prototype
 
equals()
Check if token is equals to given one.
    public
                    equals(array{0: int, 1?: string}|string|Token $other[, bool $caseSensitive = true ]) : bool
    If tokens are arrays, then only keys defined in parameter token are checked.
Parameters
- $other : array{0: int, 1?: string}|string|Token
 - 
                    
token or it's prototype
 - $caseSensitive : bool = true
 - 
                    
perform a case sensitive comparison
 
Return values
boolequalsAny()
Check if token is equals to one of given.
    public
                    equalsAny(array<int, array{0: int, 1?: string}|string|Token> $others[, bool $caseSensitive = true ]) : bool
    Parameters
- $others : array<int, array{0: int, 1?: string}|string|Token>
 - 
                    
array of tokens or token prototypes
 - $caseSensitive : bool = true
 - 
                    
perform a case sensitive comparison
 
Return values
boolgetCastTokenKinds()
    public
            static        getCastTokenKinds() : array<int, int>
    Return values
array<int, int>getClassyTokenKinds()
Get classy tokens kinds: T_CLASS, T_INTERFACE and T_TRAIT.
    public
            static        getClassyTokenKinds() : array<int, int>
    Return values
array<int, int>getContent()
Get token's content.
    public
                    getContent() : string
    It shall be used only for getting the content of token, not for checking it against excepted value.
Return values
stringgetId()
Get token's id.
    public
                    getId() : int|null
    It shall be used only for getting the internal id of token, not for checking it against excepted value.
Return values
int|nullgetKeywords()
Generate array containing all keywords that exists in PHP version in use.
    public
            static        getKeywords() : array<int, int>
    Return values
array<int, int>getMagicConstants()
Generate array containing all predefined constants that exists in PHP version in use.
    public
            static        getMagicConstants() : array<int, int>
    Tags
Return values
array<int, int>getName()
Get token's name.
    public
                    getName() : null|string
    It shall be used only for getting the name of token, not for checking it against excepted value.
Return values
null|string —token name
getNameForId()
Get token's name.
    public
            static        getNameForId(int $id) : null|string
    It shall be used only for getting the name of token, not for checking it against excepted value.
Parameters
- $id : int
 
Return values
null|string —token name
getObjectOperatorKinds()
Get object operator tokens kinds: T_OBJECT_OPERATOR and (if available) T_NULLSAFE_OBJECT_OPERATOR.
    public
            static        getObjectOperatorKinds() : array<int, int>
    Return values
array<int, int>getPrototype()
    public
                    getPrototype() : array{: int, : string}|string
    Return values
array{: int, : string}|stringisArray()
Check if token prototype is an array.
    public
                    isArray() : bool
    Return values
bool —is array
isCast()
Check if token is one of type cast tokens.
    public
                    isCast() : bool
    Return values
boolisClassy()
Check if token is one of classy tokens: T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM.
    public
                    isClassy() : bool
    Return values
boolisComment()
Check if token is one of comment tokens: T_COMMENT or T_DOC_COMMENT.
    public
                    isComment() : bool
    Return values
boolisGivenKind()
Check if token is one of given kind.
    public
                    isGivenKind(int|array<int, int> $possibleKind) : bool
    Parameters
- $possibleKind : int|array<int, int>
 - 
                    
kind or array of kinds
 
Return values
boolisKeyCaseSensitive()
A helper method used to find out whether a certain input token has to be case-sensitively matched.
    public
            static        isKeyCaseSensitive(bool|array<int, bool> $caseSensitive, int $key) : bool
    Parameters
- $caseSensitive : bool|array<int, bool>
 - 
                    
global case sensitiveness or an array of booleans, whose keys should match the ones used in $sequence. If any is missing, the default case-sensitive comparison is used
 - $key : int
 - 
                    
the key of the token that has to be looked up
 
Return values
boolisKeyword()
Check if token is a keyword.
    public
                    isKeyword() : bool
    Return values
boolisMagicConstant()
Returns if the token is of a Magic constants type.
    public
                    isMagicConstant() : bool
    Tags
Return values
boolisNativeConstant()
Check if token is a native PHP constant: true, false or null.
    public
                    isNativeConstant() : bool
    Return values
boolisObjectOperator()
Check if token is one of object operator tokens: T_OBJECT_OPERATOR or T_NULLSAFE_OBJECT_OPERATOR.
    public
                    isObjectOperator() : bool
    Return values
boolisWhitespace()
Check if token is whitespace.
    public
                    isWhitespace([null|string $whitespaces = " 	
 " ]) : bool
    Parameters
- $whitespaces : null|string = " "
 - 
                    
whitespace characters, default is " \t\n\r\0\x0B"
 
Return values
booltoArray()
    public
                    toArray() : array{id: int|null, name: string|null, content: string, isArray: bool, changed: bool}
    Return values
array{id: int|null, name: string|null, content: string, isArray: bool, changed: bool}toJson()
    public
                    toJson() : string