Scopes
in package
Utility functions for use when examining token scopes.
Tags
Table of Contents
Methods
- isOOConstant() : bool
- Check whether a T_CONST token is a class/interface/trait/enum constant declaration.
- isOOMethod() : bool
- Check whether a T_FUNCTION token is a class/interface/trait/enum method declaration.
- isOOProperty() : bool
- Check whether a T_VARIABLE token is a class/trait property declaration.
- validDirectScope() : int|false
- Check whether the direct wrapping scope of a token is within a limited set of acceptable tokens.
Methods
isOOConstant()
Check whether a T_CONST token is a class/interface/trait/enum constant declaration.
public
static isOOConstant(File $phpcsFile, int $stackPtr) : bool
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack of the
T_CONST
token to verify.
Tags
Return values
boolisOOMethod()
Check whether a T_FUNCTION token is a class/interface/trait/enum method declaration.
public
static isOOMethod(File $phpcsFile, int $stackPtr) : bool
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack of the
T_FUNCTION
token to verify.
Tags
Return values
boolisOOProperty()
Check whether a T_VARIABLE token is a class/trait property declaration.
public
static isOOProperty(File $phpcsFile, int $stackPtr) : bool
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack of the
T_VARIABLE
token to verify.
Tags
Return values
boolvalidDirectScope()
Check whether the direct wrapping scope of a token is within a limited set of acceptable tokens.
public
static validDirectScope(File $phpcsFile, int $stackPtr, int|string|array<string|int, int|string> $validScopes) : int|false
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack of the token to verify.
- $validScopes : int|string|array<string|int, int|string>
-
Array of token constants representing the scopes considered valid.
Tags
Return values
int|false —Integer stack pointer to the valid direct scope; or FALSE
if
no valid direct scope was found.