GlobalNamespaceImportFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface, WhitespacesAwareFixerInterface
uses
ConfigurableFixerTrait
Tags
Table of Contents
Interfaces
Properties
Methods
- __construct() : mixed
- 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
- createConfigurationDefinition() : FixerConfigurationResolverInterface
-
filterUseDeclarations()
: array{0: array
, 1: array } - findFunctionDeclarations() : iterable<string|int, string>
- fullyQualifyClasses() : void
- fullyQualifyConstants() : void
- fullyQualifyFunctions() : void
- importClasses() : array<string, string>
- importConstants() : array<string, string>
- importFunctions() : array<string, string>
- prepareImports() : array<string, class-string>
- Removes the leading slash at the given indices (when the name is not already used).
- traverseDocBlockTypes() : bool
Properties
$importProcessor
private
ImportProcessor
$importProcessor
Methods
__construct()
public
__construct() : mixed
getDefinition()
Returns the definition of the fixer.
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
Returns the priority of the fixer.
public
getPriority() : int
Must run before NoUnusedImportsFixer, OrderedImportsFixer, StatementIndentationFixer. Must run after NativeConstantInvocationFixer, NativeFunctionInvocationFixer.
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
createConfigurationDefinition()
protected
createConfigurationDefinition() : FixerConfigurationResolverInterface
Return values
FixerConfigurationResolverInterfacefilterUseDeclarations()
private
filterUseDeclarations(array<int, NamespaceUseAnalysis> $declarations, callable $callback, bool $caseSensitive) : array{0: array, 1: array}
Parameters
- $declarations : array<int, NamespaceUseAnalysis>
- $callback : callable
- $caseSensitive : bool
Return values
array{0: arrayfindFunctionDeclarations()
private
findFunctionDeclarations(Tokens $tokens, int $start, int $end) : iterable<string|int, string>
Parameters
- $tokens : Tokens
- $start : int
- $end : int
Return values
iterable<string|int, string>fullyQualifyClasses()
private
fullyQualifyClasses(Tokens $tokens, array<int, NamespaceUseAnalysis> $useDeclarations) : void
Parameters
- $tokens : Tokens
- $useDeclarations : array<int, NamespaceUseAnalysis>
fullyQualifyConstants()
private
fullyQualifyConstants(Tokens $tokens, array<int, NamespaceUseAnalysis> $useDeclarations) : void
Parameters
- $tokens : Tokens
- $useDeclarations : array<int, NamespaceUseAnalysis>
fullyQualifyFunctions()
private
fullyQualifyFunctions(Tokens $tokens, array<int, NamespaceUseAnalysis> $useDeclarations) : void
Parameters
- $tokens : Tokens
- $useDeclarations : array<int, NamespaceUseAnalysis>
importClasses()
private
importClasses(Tokens $tokens, array<int, NamespaceUseAnalysis> $useDeclarations) : array<string, string>
Parameters
- $tokens : Tokens
- $useDeclarations : array<int, NamespaceUseAnalysis>
Return values
array<string, string>importConstants()
private
importConstants(Tokens $tokens, array<int, NamespaceUseAnalysis> $useDeclarations) : array<string, string>
Parameters
- $tokens : Tokens
- $useDeclarations : array<int, NamespaceUseAnalysis>
Return values
array<string, string>importFunctions()
private
importFunctions(Tokens $tokens, array<int, NamespaceUseAnalysis> $useDeclarations) : array<string, string>
Parameters
- $tokens : Tokens
- $useDeclarations : array<int, NamespaceUseAnalysis>
Return values
array<string, string>prepareImports()
Removes the leading slash at the given indices (when the name is not already used).
private
prepareImports(Tokens $tokens, array<int, int> $indices, array<string, string|true> $global, array<string, true> $other, bool $caseSensitive) : array<string, class-string>
Parameters
- $tokens : Tokens
- $indices : array<int, int>
- $global : array<string, string|true>
- $other : array<string, true>
- $caseSensitive : bool
Return values
array<string, class-string> —array keys contain the names that must be imported
traverseDocBlockTypes()
private
traverseDocBlockTypes(DocBlock $doc, callable $callback) : bool
Parameters
- $doc : DocBlock
- $callback : callable