Documentation

GlobalNamespaceImportFixer extends AbstractFixer
in package
implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface uses ConfigurableFixerTrait

FinalYes
Tags
author

Gregor Harlan gharlan@web.de

implements

ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>

phpstan-type

_AutogeneratedInputConfiguration array{ import_classes?: bool|null, import_constants?: bool|null, import_functions?: bool|null }

phpstan-type

_AutogeneratedComputedConfiguration array{ import_classes: bool|null, import_constants: bool|null, import_functions: bool|null }

Table of Contents

Interfaces

ConfigurableFixerInterface
WhitespacesAwareFixerInterface

Properties

$importProcessor  : ImportProcessor

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

Methods

getPriority()

Returns the priority of the fixer.

public getPriority() : int

Must run before NoUnusedImportsFixer, OrderedImportsFixer, StatementIndentationFixer. Must run after NativeConstantInvocationFixer, NativeFunctionInvocationFixer.

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

filterUseDeclarations()

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: array, 1: array}

findFunctionDeclarations()

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


        
On this page

Search results