Documentation

GroupImportFixer extends AbstractFixer
in package
implements ConfigurableFixerInterface uses ConfigurableFixerTrait

FinalYes
Tags
author

Volodymyr Kupriienko vldmr.kuprienko@gmail.com

author

Greg Korba greg@codito.dev

phpstan-type

_AutogeneratedInputConfiguration array{ group_types?: list }

phpstan-type

_AutogeneratedComputedConfiguration array{ group_types: list }

implements

ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>

Table of Contents

Interfaces

ConfigurableFixerInterface

Methods

getDefinition()  : FixerDefinitionInterface
Returns the definition of the fixer.
isCandidate()  : bool
Check if the fixer is a candidate for given Tokens collection.
applyFix()  : void
createConfigurationDefinition()  : FixerConfigurationResolverInterface
addGroupUseStatements()  : void
areDeclarationsDifferent()  : bool
Check if namespace use analyses are different.
createNewGroup()  : int
Creates new use statement group.
getNamespaceNameWithSlash()  : string
getSameNamespacesByType()  : array<string|int, mixed>
Gets namespace use analyzers with same namespaces.
insertToGroupUseWithAlias()  : int
Insert use with alias to the group.
removeSingleUseStatements()  : void

Methods

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

addGroupUseStatements()

private addGroupUseStatements(array<int, NamespaceUseAnalysis$statements, Tokens $tokens) : void
Parameters
$statements : array<int, NamespaceUseAnalysis>
$tokens : Tokens

areDeclarationsDifferent()

Check if namespace use analyses are different.

private areDeclarationsDifferent(NamespaceUseAnalysis|null $analysis1, NamespaceUseAnalysis|null $analysis2) : bool
Parameters
$analysis1 : NamespaceUseAnalysis|null
$analysis2 : NamespaceUseAnalysis|null
Return values
bool

createNewGroup()

Creates new use statement group.

private createNewGroup(Tokens $tokens, int $insertIndex, NamespaceUseAnalysis $useDeclaration, string $currentNamespace) : int
Parameters
$tokens : Tokens
$insertIndex : int
$useDeclaration : NamespaceUseAnalysis
$currentNamespace : string
Return values
int

getNamespaceNameWithSlash()

private getNamespaceNameWithSlash(NamespaceUseAnalysis $useDeclaration) : string
Parameters
$useDeclaration : NamespaceUseAnalysis
Return values
string

getSameNamespacesByType()

Gets namespace use analyzers with same namespaces.

private getSameNamespacesByType(Tokens $tokens) : array<string|int, mixed>
Parameters
$tokens : Tokens
Return values
array<string|int, mixed>

insertToGroupUseWithAlias()

Insert use with alias to the group.

private insertToGroupUseWithAlias(Tokens $tokens, int $insertIndex, NamespaceUseAnalysis $useDeclaration) : int
Parameters
$tokens : Tokens
$insertIndex : int
$useDeclaration : NamespaceUseAnalysis
Return values
int

removeSingleUseStatements()

private removeSingleUseStatements(array<int, NamespaceUseAnalysis$statements, Tokens $tokens) : void
Parameters
$statements : array<int, NamespaceUseAnalysis>
$tokens : Tokens

        
On this page

Search results