Documentation

AbstractNoUselessElseFixer extends AbstractFixer
in package

Tags
author

SpacePossum

Table of Contents

getPriority()  : mixed
{@inheritdoc}
isSuperfluousElse()  : bool
getPreviousBlock()  : array<string|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

getPreviousBlock()

Return the first and last token index of the previous block.

private getPreviousBlock(Tokens $tokens, int $index) : array<string|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<string|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 a 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

Search results