BinaryOperatorSpacesFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface
uses
ConfigurableFixerTrait
Tags
Table of Contents
Interfaces
Constants
- SUPPORTED_OPERATORS = ['=', '*', '/', '%', '<', '>', '|', '^', '+', '-', '&', '&=', '&&', '||', '.=', '/=', '=>', '==', '>=', '===', '!=', '<>', '!==', '<=', 'and', 'or', 'xor', '-=', '%=', '*=', '|=', '+=', '<<', '<<=', '>>', '>>=', '^=', '**', '**=', '<=>', '??', '??=']
Properties
- $alignOperatorTokens : array<string, string>
- $allowedValues : array<int, null|string>
- $currentLevel : int
- Level counter of the current nest level.
- $deepestLevel : int
- Keep track of the deepest level ever achieved while parsing the code. Used later to replace alignment placeholders with spaces.
- $operators : array<string, string>
- $tokensAnalyzer : TokensAnalyzer
Methods
- getDefinition() : FixerDefinitionInterface
- Returns the definition of the fixer.
- getPriority() : int
- Returns the priority of the fixer.
- isCandidate() : bool
- Check if the fixer is a candidate for given Tokens collection.
- applyFix() : void
- configurePostNormalisation() : void
- createConfigurationDefinition() : FixerConfigurationResolverInterface
- fixAlignment() : void
- fixWhiteSpaceAroundOperator() : void
- fixWhiteSpaceAroundOperatorToAtLeastSingleSpace() : void
- fixWhiteSpaceAroundOperatorToNoSpace() : void
- fixWhiteSpaceAroundOperatorToSingleSpace() : void
- fixWhiteSpaceBeforeOperator() : void
- injectAlignmentPlaceholders() : void
- injectAlignmentPlaceholdersDefault() : void
- injectAlignmentPlaceholdersForArrow() : void
- injectArrayAlignmentPlaceholders() : void
- isEqualPartOfDeclareStatement() : false|int
- replacePlaceholders() : string
- Look for group of placeholders and provide vertical alignment.
- resolveOperatorsFromConfig() : array<string, string>
Constants
SUPPORTED_OPERATORS
private
array<int, string>
SUPPORTED_OPERATORS
= ['=', '*', '/', '%', '<', '>', '|', '^', '+', '-', '&', '&=', '&&', '||', '.=', '/=', '=>', '==', '>=', '===', '!=', '<>', '!==', '<=', 'and', 'or', 'xor', '-=', '%=', '*=', '|=', '+=', '<<', '<<=', '>>', '>>=', '^=', '**', '**=', '<=>', '??', '??=']
Properties
$alignOperatorTokens
private
array<string, string>
$alignOperatorTokens
= []
$allowedValues
private
static array<int, null|string>
$allowedValues
= [self::ALIGN, self::ALIGN_BY_SCOPE, self::ALIGN_SINGLE_SPACE, self::ALIGN_SINGLE_SPACE_MINIMAL, self::ALIGN_SINGLE_SPACE_BY_SCOPE, self::ALIGN_SINGLE_SPACE_MINIMAL_BY_SCOPE, self::SINGLE_SPACE, self::NO_SPACE, self::AT_LEAST_SINGLE_SPACE, null]
$currentLevel
Level counter of the current nest level.
private
int
$currentLevel
So one level alignments are not mixed with other level ones.
$deepestLevel
Keep track of the deepest level ever achieved while parsing the code. Used later to replace alignment placeholders with spaces.
private
int
$deepestLevel
$operators
private
array<string, string>
$operators
= []
$tokensAnalyzer
private
TokensAnalyzer
$tokensAnalyzer
Methods
getDefinition()
Returns the definition of the fixer.
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
Returns the priority of the fixer.
public
getPriority() : int
Must run after ArrayIndentationFixer, ArraySyntaxFixer, AssignNullCoalescingToCoalesceEqualFixer, ListSyntaxFixer, LongToShorthandOperatorFixer, ModernizeStrposFixer, NoMultilineWhitespaceAroundDoubleArrowFixer, NoUnsetCastFixer, PowToExponentiationFixer, StandardizeNotEqualsFixer, StrictComparisonFixer.
Return values
intisCandidate()
Check if the fixer is a candidate for given Tokens collection.
public
isCandidate(Tokens $tokens) : bool
Fixer is a candidate when the collection contains tokens that may be fixed during fixer work. This could be considered as some kind of bloom filter. When this method returns true then to the Tokens collection may or may not need a fixing, but when this method returns false then the Tokens collection need no fixing for sure.
Parameters
- $tokens : Tokens
Return values
boolapplyFix()
protected
applyFix(SplFileInfo $file, Tokens $tokens) : void
Parameters
- $file : SplFileInfo
- $tokens : Tokens
configurePostNormalisation()
protected
configurePostNormalisation() : void
createConfigurationDefinition()
protected
createConfigurationDefinition() : FixerConfigurationResolverInterface
Return values
FixerConfigurationResolverInterfacefixAlignment()
private
fixAlignment(Tokens $tokens, array<string, string> $toAlign) : void
Parameters
- $tokens : Tokens
- $toAlign : array<string, string>
fixWhiteSpaceAroundOperator()
private
fixWhiteSpaceAroundOperator(Tokens $tokens, int $index) : void
Parameters
- $tokens : Tokens
- $index : int
fixWhiteSpaceAroundOperatorToAtLeastSingleSpace()
private
fixWhiteSpaceAroundOperatorToAtLeastSingleSpace(Tokens $tokens, int $index) : void
Parameters
- $tokens : Tokens
- $index : int
fixWhiteSpaceAroundOperatorToNoSpace()
private
fixWhiteSpaceAroundOperatorToNoSpace(Tokens $tokens, int $index) : void
Parameters
- $tokens : Tokens
- $index : int
fixWhiteSpaceAroundOperatorToSingleSpace()
private
fixWhiteSpaceAroundOperatorToSingleSpace(Tokens $tokens, int $index) : void
Parameters
- $tokens : Tokens
- $index : int
fixWhiteSpaceBeforeOperator()
private
fixWhiteSpaceBeforeOperator(Tokens $tokens, int $index, string $alignStrategy) : void
Parameters
- $tokens : Tokens
- $index : int
- $alignStrategy : string
injectAlignmentPlaceholders()
private
injectAlignmentPlaceholders(Tokens $tokens, int $from, int $until, string $tokenContent) : void
Parameters
- $tokens : Tokens
- $from : int
- $until : int
- $tokenContent : string
injectAlignmentPlaceholdersDefault()
private
injectAlignmentPlaceholdersDefault(Tokens $tokens, int $startAt, int $endAt, string $tokenContent) : void
Parameters
- $tokens : Tokens
- $startAt : int
- $endAt : int
- $tokenContent : string
injectAlignmentPlaceholdersForArrow()
private
injectAlignmentPlaceholdersForArrow(Tokens $tokens, int $startAt, int $endAt) : void
Parameters
- $tokens : Tokens
- $startAt : int
- $endAt : int
injectArrayAlignmentPlaceholders()
private
injectArrayAlignmentPlaceholders(Tokens $tokens, int $from, int $until) : void
Parameters
- $tokens : Tokens
- $from : int
- $until : int
isEqualPartOfDeclareStatement()
private
isEqualPartOfDeclareStatement(Tokens $tokens, int $index) : false|int
Parameters
- $tokens : Tokens
- $index : int
Return values
false|int —index of T_DECLARE where the =
belongs to or false
replacePlaceholders()
Look for group of placeholders and provide vertical alignment.
private
replacePlaceholders(Tokens $tokens, string $alignStrategy, string $tokenContent) : string
Parameters
- $tokens : Tokens
- $alignStrategy : string
- $tokenContent : string
Return values
stringresolveOperatorsFromConfig()
private
resolveOperatorsFromConfig() : array<string, string>