Documentation

NoSuperfluousElseifFixer extends AbstractNoUselessElseFixer
in package

FinalYes

Table of Contents

Methods

getDefinition()  : FixerDefinitionInterface
getPriority()  : int
isCandidate()  : bool
applyFix()  : void
isSuperfluousElse()  : bool
convertElseifToIf()  : void
getPreviousBlock()  : array{: int, : int}
Return the first and last token index of the previous block.
isElseif()  : bool
isInConditional()  : bool
isInConditionWithoutBraces()  : bool
For internal use only, as it is not perfect.

Methods

getPriority()

public getPriority() : int

Must run before SimplifiedIfReturnFixer. Must run after NoAlternativeSyntaxFixer.

Return values
int

getPreviousBlock()

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
bool

isInConditionWithoutBraces()

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
Return values
bool

        
On this page

Search results