Parentheses
Utility functions for use when examining parenthesis tokens and arbitrary tokens wrapped in parentheses.
Tags
Table of Contents
- firstOwnerIn() : int|false
- Check whether the owner of a outermost wrapping set of parentheses of an arbitrary token is within a limited set of acceptable token types.
- getFirstCloser() : int|false
- Retrieve the position of the closer to the first (outer) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
- getFirstOpener() : int|false
- Retrieve the position of the opener to the first (outer) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
- getFirstOwner() : int|false
- Retrieve the position of the parentheses owner to the first (outer) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
- getLastCloser() : int|false
- Retrieve the position of the closer to the last (inner) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
- getLastOpener() : int|false
- Retrieve the position of the opener to the last (inner) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
- getLastOwner() : int|false
- Retrieve the position of the parentheses owner to the last (inner) set of parentheses an arbitrary token is wrapped in where the parentheses owner is within the set of valid owners.
- getOwner() : int|false
- Get the pointer to the parentheses owner of an open/close parenthesis.
- hasOwner() : bool
- Check whether the passed token is nested within parentheses owned by one of the valid owners.
- isOwnerIn() : bool
- Check whether the parenthesis owner of an open/close parenthesis is within a limited set of valid owners.
- lastOwnerIn() : int|false
- Check whether the owner of a innermost wrapping set of parentheses of an arbitrary token is within a limited set of acceptable token types.
Methods
firstOwnerIn()
Check whether the owner of a outermost wrapping set of parentheses of an arbitrary token is within a limited set of acceptable token types.
public
static firstOwnerIn(File $phpcsFile, int $stackPtr, int|string|array $validOwners) : int|false
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack of the token to verify.
- $validOwners : int|string|array
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the valid parentheses owner; or FALSE
if
the token was not wrapped in parentheses or if the outermost set
of parentheses in which the token is wrapped does not have an owner
within the set of owners considered valid.
getFirstCloser()
Retrieve the position of the closer to the first (outer) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
public
static getFirstCloser(File $phpcsFile, int $stackPtr[, int|string|array $validOwners = [] ]) : int|false
If no $validOwners
are specified, the closer to the first set of parentheses surrounding
the token will be returned.
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array = []
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the parentheses closer; or FALSE
if the token
does not have parentheses owned by any of the valid owners or if
the token is not nested in parentheses at all.
getFirstOpener()
Retrieve the position of the opener to the first (outer) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
public
static getFirstOpener(File $phpcsFile, int $stackPtr[, int|string|array $validOwners = [] ]) : int|false
If no $validOwners
are specified, the opener to the first set of parentheses surrounding
the token will be returned.
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array = []
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the parentheses opener; or FALSE
if the token
does not have parentheses owned by any of the valid owners or if
the token is not nested in parentheses at all.
getFirstOwner()
Retrieve the position of the parentheses owner to the first (outer) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
public
static getFirstOwner(File $phpcsFile, int $stackPtr[, int|string|array $validOwners = [] ]) : int|false
If no $validOwners
are specified, the owner to the first set of parentheses surrounding
the token will be returned or false
if the first set of parentheses does not have an owner.
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array = []
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the parentheses owner; or FALSE
if the token
does not have parentheses owned by any of the valid owners or if
the token is not nested in parentheses at all.
getLastCloser()
Retrieve the position of the closer to the last (inner) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
public
static getLastCloser(File $phpcsFile, int $stackPtr[, int|string|array $validOwners = [] ]) : int|false
If no $validOwners
are specified, the closer to the last set of parentheses surrounding
the token will be returned.
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array = []
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the parentheses closer; or FALSE
if the token
does not have parentheses owned by any of the valid owners or if
the token is not nested in parentheses at all.
getLastOpener()
Retrieve the position of the opener to the last (inner) set of parentheses an arbitrary token is wrapped in, where the parentheses owner is within the set of valid owners.
public
static getLastOpener(File $phpcsFile, int $stackPtr[, int|string|array $validOwners = [] ]) : int|false
If no $validOwners
are specified, the opener to the last set of parentheses surrounding
the token will be returned.
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array = []
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the parentheses opener; or FALSE
if the token
does not have parentheses owned by any of the valid owners or if
the token is not nested in parentheses at all.
getLastOwner()
Retrieve the position of the parentheses owner to the last (inner) set of parentheses an arbitrary token is wrapped in where the parentheses owner is within the set of valid owners.
public
static getLastOwner(File $phpcsFile, int $stackPtr[, int|string|array $validOwners = [] ]) : int|false
If no $validOwners
are specified, the owner to the last set of parentheses surrounding
the token will be returned or false
if the last set of parentheses does not have an owner.
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array = []
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the parentheses owner; or FALSE
if the token
does not have parentheses owned by any of the valid owners or if
the token is not nested in parentheses at all.
getOwner()
Get the pointer to the parentheses owner of an open/close parenthesis.
public
static getOwner(File $phpcsFile, int $stackPtr) : int|false
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of
T_OPEN/CLOSE_PARENTHESIS
token.
Tags
Return values
int|false —Integer stack pointer to the parentheses owner; or FALSE
if the
parenthesis does not have a (direct) owner or if the token passed
was not a parenthesis.
hasOwner()
Check whether the passed token is nested within parentheses owned by one of the valid owners.
public
static hasOwner(File $phpcsFile, int $stackPtr, int|string|array $validOwners) : bool
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of the token we are checking.
- $validOwners : int|string|array
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
bool —isOwnerIn()
Check whether the parenthesis owner of an open/close parenthesis is within a limited set of valid owners.
public
static isOwnerIn(File $phpcsFile, int $stackPtr, int|string|array $validOwners) : bool
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position of
T_OPEN/CLOSE_PARENTHESIS
token. - $validOwners : int|string|array
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
bool —TRUE
if the owner is within the list of $validOwners
; FALSE
if not and
if the parenthesis does not have a (direct) owner.
lastOwnerIn()
Check whether the owner of a innermost wrapping set of parentheses of an arbitrary token is within a limited set of acceptable token types.
public
static lastOwnerIn(File $phpcsFile, int $stackPtr, int|string|array $validOwners) : int|false
Parameters
- $phpcsFile : File
-
The file where this token was found.
- $stackPtr : int
-
The position in the stack of the token to verify.
- $validOwners : int|string|array
-
Array of token constants for the owners which should be considered valid.
Tags
Return values
int|false —Integer stack pointer to the valid parentheses owner; or FALSE
if
the token was not wrapped in parentheses or if the innermost set
of parentheses in which the token is wrapped does not have an owner
within the set of owners considered valid.