Operators in package
Utility functions for use when working with operators.
Tags
Table of Contents
Methods
- isReference() : bool
- Determine if the passed token is a reference operator.
- isShortTernary() : bool
- Determine whether a ternary is a short ternary/elvis operator, i.e. without "middle".
- isUnaryPlusMinus() : bool
- Determine whether a T_MINUS/T_PLUS token is a unary operator.
Methods
isReference()
Determine if the passed token is a reference operator.
public static isReference(File $phpcsFile, int $stackPtr) : bool Main differences with the PHPCS version:
- Defensive coding against incorrect calls to this method.
Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the
T_BITWISE_ANDtoken.
Tags
Return values
bool —TRUE if the specified token position represents a reference. FALSE if the token represents a bitwise operator.
isShortTernary()
Determine whether a ternary is a short ternary/elvis operator, i.e. without "middle".
public static isShortTernary(File $phpcsFile, int $stackPtr) : bool Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the ternary then/else operator in the stack.
Tags
Return values
bool —TRUE if short ternary; or FALSE otherwise.
isUnaryPlusMinus()
Determine whether a T_MINUS/T_PLUS token is a unary operator.
public static isUnaryPlusMinus(File $phpcsFile, int $stackPtr) : bool Parameters
- $phpcsFile : File
-
The file being scanned.
- $stackPtr : int
-
The position of the plus/minus token.
Tags
Return values
bool —TRUE if the token passed is a unary operator. FALSE otherwise, i.e. if the token is an arithmetic operator, or if the token is not a T_PLUS/T_MINUS token.