ModernizeStrposFixer
extends AbstractFixer
in package
FinalYes
Tags
Table of Contents
Constants
- REPLACEMENTS = [['operator' => [T_IS_IDENTICAL, '==='], 'operand' => [T_LNUMBER, '0'], 'replacement' => [T_STRING, 'str_starts_with'], 'negate' => false], ['operator' => [T_IS_NOT_IDENTICAL, '!=='], 'operand' => [T_LNUMBER, '0'], 'replacement' => [T_STRING, 'str_starts_with'], 'negate' => true], ['operator' => [T_IS_NOT_IDENTICAL, '!=='], 'operand' => [T_STRING, 'false'], 'replacement' => [T_STRING, 'str_contains'], 'negate' => false], ['operator' => [T_IS_IDENTICAL, '==='], 'operand' => [T_STRING, 'false'], 'replacement' => [T_STRING, 'str_contains'], 'negate' => true]]
Methods
- getDefinition() : FixerDefinitionInterface
- getPriority() : int
- {@inheritdoc}
- isCandidate() : bool
- isRisky() : bool
- applyFix() : void
- fixCall() : void
- getCompareTokens() : null|array{operator_index: int, operand_index: int}
- isOfHigherPrecedence() : bool
Constants
REPLACEMENTS
private
mixed
REPLACEMENTS
= [['operator' => [T_IS_IDENTICAL, '==='], 'operand' => [T_LNUMBER, '0'], 'replacement' => [T_STRING, 'str_starts_with'], 'negate' => false], ['operator' => [T_IS_NOT_IDENTICAL, '!=='], 'operand' => [T_LNUMBER, '0'], 'replacement' => [T_STRING, 'str_starts_with'], 'negate' => true], ['operator' => [T_IS_NOT_IDENTICAL, '!=='], 'operand' => [T_STRING, 'false'], 'replacement' => [T_STRING, 'str_contains'], 'negate' => false], ['operator' => [T_IS_IDENTICAL, '==='], 'operand' => [T_STRING, 'false'], 'replacement' => [T_STRING, 'str_contains'], 'negate' => true]]
Methods
getDefinition()
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
{@inheritdoc}
public
getPriority() : int
Must run before BinaryOperatorSpacesFixer, NoExtraBlankLinesFixer, NoSpacesInsideParenthesisFixer, NoTrailingWhitespaceFixer, NotOperatorWithSpaceFixer, NotOperatorWithSuccessorSpaceFixer, PhpUnitDedicateAssertFixer, SingleSpaceAfterConstructFixer, SingleSpaceAroundConstructFixer, SpacesInsideParenthesesFixer. Must run after StrictComparisonFixer.
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
fixCall()
private
fixCall(Tokens $tokens, int $functionIndex, array{operator_index: int, operand_index: int} $operatorIndices) : void
Parameters
- $tokens : Tokens
- $functionIndex : int
- $operatorIndices : array{operator_index: int, operand_index: int}
getCompareTokens()
private
getCompareTokens(Tokens $tokens, int $offsetIndex, -1|1 $direction) : null|array{operator_index: int, operand_index: int}
Parameters
- $tokens : Tokens
- $offsetIndex : int
- $direction : -1|1
Return values
null|array{operator_index: int, operand_index: int}isOfHigherPrecedence()
private
isOfHigherPrecedence(Token $token) : bool
Parameters
- $token : Token