GroupImportFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface
uses
ConfigurableFixerTrait
FinalYes
Tags
Table of Contents
Interfaces
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
getDefinition()
Returns the definition of the fixer.
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfaceisCandidate()
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
createConfigurationDefinition()
protected
createConfigurationDefinition() : FixerConfigurationResolverInterface
Return values
FixerConfigurationResolverInterfaceaddGroupUseStatements()
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
boolcreateNewGroup()
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
intgetNamespaceNameWithSlash()
private
getNamespaceNameWithSlash(NamespaceUseAnalysis $useDeclaration) : string
Parameters
- $useDeclaration : NamespaceUseAnalysis
Return values
stringgetSameNamespacesByType()
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
intremoveSingleUseStatements()
private
removeSingleUseStatements(array<int, NamespaceUseAnalysis> $statements, Tokens $tokens) : void
Parameters
- $statements : array<int, NamespaceUseAnalysis>
- $tokens : Tokens