Documentation

BinaryOperatorSpacesFixer extends AbstractFixer
in package
implements ConfigurableFixerInterface uses ConfigurableFixerTrait

FinalYes
Tags
author

Dariusz Rumiński dariusz.ruminski@gmail.com

implements

ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>

phpstan-type

_AutogeneratedInputConfiguration array{ default?: 'align'|'align_by_scope'|'align_single_space'|'align_single_space_by_scope'|'align_single_space_minimal'|'align_single_space_minimal_by_scope'|'at_least_single_space'|'no_space'|'single_space'|null, operators?: array<string, ?string> }

phpstan-type

_AutogeneratedComputedConfiguration array{ default: 'align'|'align_by_scope'|'align_single_space'|'align_single_space_by_scope'|'align_single_space_minimal'|'align_single_space_minimal_by_scope'|'at_least_single_space'|'no_space'|'single_space'|null, operators: array<string, ?string> }

Table of Contents

Interfaces

ConfigurableFixerInterface

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

$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

Methods

getPriority()

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
int

isCandidate()

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
bool

fixWhiteSpaceAroundOperatorToAtLeastSingleSpace()

private fixWhiteSpaceAroundOperatorToAtLeastSingleSpace(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
string

resolveOperatorsFromConfig()

private resolveOperatorsFromConfig() : array<string, string>
Return values
array<string, string>

        
On this page

Search results