AbstractNoUselessElseFixer
extends AbstractFixer
in package
AbstractYes
Table of Contents
Methods
- getPriority() : int
- isSuperfluousElse() : bool
- getPreviousBlock() : array{: int, : int}
- Return the first and last token index of the previous block.
- isInConditional() : bool
- isInConditionWithoutBraces() : bool
- For internal use only, as it is not perfect.
Methods
getPriority()
public
getPriority() : int
Return values
intisSuperfluousElse()
protected
isSuperfluousElse(Tokens $tokens, int $index) : bool
Parameters
- $tokens : Tokens
- $index : int
Return values
boolgetPreviousBlock()
Return the first and last token index of the previous block.
private
getPreviousBlock(Tokens $tokens, int $index) : array{: int, : int}
[0] First is either T_IF, T_ELSE or T_ELSEIF [1] Last is either '}' or ';' / T_CLOSE_TAG for short notation blocks
Parameters
- $tokens : Tokens
- $index : int
-
T_IF, T_ELSE, T_ELSEIF
Return values
array{: int, : int}isInConditional()
private
isInConditional(Tokens $tokens, int $index, int $lowerLimitIndex) : bool
Parameters
- $tokens : Tokens
- $index : int
-
Index of the token to check
- $lowerLimitIndex : int
-
Lower limit index. Since the token to check will always be in a conditional we must stop checking at this index
Return values
boolisInConditionWithoutBraces()
For internal use only, as it is not perfect.
private
isInConditionWithoutBraces(Tokens $tokens, int $index, int $lowerLimitIndex) : bool
Returns if the token at given index is part of an if/elseif/else statement
without }. Assumes not passing the last ;
/close tag of the statement, not
out of range index, etc.
Parameters
- $tokens : Tokens
- $index : int
-
Index of the token to check
- $lowerLimitIndex : int