TernaryToElvisOperatorFixer
extends AbstractFixer
in package
FinalYes
Table of Contents
Constants
- VALID_BEFORE_ENDTYPES = [ '=', [T_OPEN_TAG], [T_OPEN_TAG_WITH_ECHO], '(', ',', ';', '[', '{', '}', [\PhpCsFixer\Tokenizer\CT::T_ARRAY_INDEX_CURLY_BRACE_OPEN], [T_AND_EQUAL], // &= [T_CONCAT_EQUAL], // .= [T_DIV_EQUAL], // /= [T_MINUS_EQUAL], // -= [T_MOD_EQUAL], // %= [T_MUL_EQUAL], // *= [T_OR_EQUAL], // |= [T_PLUS_EQUAL], // += [T_POW_EQUAL], // **= [T_SL_EQUAL], // <<= [T_SR_EQUAL], // >>= [T_XOR_EQUAL], ]
- Lower precedence and other valid preceding tokens.
Methods
- getDefinition() : FixerDefinitionInterface
- getPriority() : int
- {@inheritdoc}
- isCandidate() : bool
- isRisky() : bool
- applyFix() : void
- clearMeaningfulFromRange() : void
- getAfterOperator() : array{start: int, end: int}
- getBeforeOperator() : array{start: int, end: int}|null
Constants
VALID_BEFORE_ENDTYPES
Lower precedence and other valid preceding tokens.
private
array<int, array{: int}|string>
VALID_BEFORE_ENDTYPES
= [
'=',
[T_OPEN_TAG],
[T_OPEN_TAG_WITH_ECHO],
'(',
',',
';',
'[',
'{',
'}',
[\PhpCsFixer\Tokenizer\CT::T_ARRAY_INDEX_CURLY_BRACE_OPEN],
[T_AND_EQUAL],
// &=
[T_CONCAT_EQUAL],
// .=
[T_DIV_EQUAL],
// /=
[T_MINUS_EQUAL],
// -=
[T_MOD_EQUAL],
// %=
[T_MUL_EQUAL],
// *=
[T_OR_EQUAL],
// |=
[T_PLUS_EQUAL],
// +=
[T_POW_EQUAL],
// **=
[T_SL_EQUAL],
// <<=
[T_SR_EQUAL],
// >>=
[T_XOR_EQUAL],
]
Ordered by most common types first.
Methods
getDefinition()
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
{@inheritdoc}
public
getPriority() : int
Must run before NoTrailingWhitespaceFixer, TernaryOperatorSpacesFixer.
Return values
intisCandidate()
public
isCandidate(Tokens $tokens) : bool
Parameters
- $tokens : Tokens
Return values
boolisRisky()
public
isRisky() : bool
Return values
boolapplyFix()
protected
applyFix(SplFileInfo $file, Tokens $tokens) : void
Parameters
- $file : SplFileInfo
- $tokens : Tokens
clearMeaningfulFromRange()
private
clearMeaningfulFromRange(Tokens $tokens, array{start: int, end: int} $range) : void
Parameters
- $tokens : Tokens
- $range : array{start: int, end: int}
getAfterOperator()
private
getAfterOperator(Tokens $tokens, int $index) : array{start: int, end: int}
Parameters
- $tokens : Tokens
- $index : int
Return values
array{start: int, end: int}getBeforeOperator()
private
getBeforeOperator(Tokens $tokens, int $index) : array{start: int, end: int}|null
Parameters
- $tokens : Tokens
- $index : int
Return values
array{start: int, end: int}|null —null if contains ++/-- operator