Documentation

NoUnusedImportsFixer extends AbstractFixer
in package

FinalYes
Tags
author

Dariusz Rumiński dariusz.ruminski@gmail.com

Table of Contents

Methods

getDefinition()  : FixerDefinitionInterface
getPriority()  : int
{@inheritdoc}
isCandidate()  : bool
applyFix()  : void
cleanUpAfterImportChunkRemoval()  : void
cleanUpSurroundingNewLines()  : void
isImportUsed()  : bool
removeImportStatementIfEmpty()  : void
removeLineIfEmpty()  : void
removeUseDeclaration()  : void
removeUsesInSameNamespace()  : void
scanForNonEmptyTokensUntilNewLineFound()  : array{0: null|int, 1: bool}
Returns tuple with the index of first token with whitespace containing new line char and a flag if any non-empty token was found along the way.

Methods

getPriority()

{@inheritdoc}

public getPriority() : int

Must run before BlankLineAfterNamespaceFixer, NoExtraBlankLinesFixer, NoLeadingImportSlashFixer, SingleLineAfterImportsFixer. Must run after ClassKeywordRemoveFixer, GlobalNamespaceImportFixer, PhpUnitDedicateAssertFixer, PhpUnitFqcnAnnotationFixer, SingleImportPerStatementFixer.

Return values
int

cleanUpAfterImportChunkRemoval()

private cleanUpAfterImportChunkRemoval(Tokens $tokens, NamespaceUseAnalysis $useDeclaration) : void
Parameters
$tokens : Tokens
$useDeclaration : NamespaceUseAnalysis

cleanUpSurroundingNewLines()

private cleanUpSurroundingNewLines(Tokens $tokens, NamespaceUseAnalysis $useDeclaration) : void
Parameters
$tokens : Tokens
$useDeclaration : NamespaceUseAnalysis

isImportUsed()

private isImportUsed(Tokens $tokens, NamespaceAnalysis $namespace, NamespaceUseAnalysis $import, array<int, int> $ignoredIndices) : bool
Parameters
$tokens : Tokens
$namespace : NamespaceAnalysis
$import : NamespaceUseAnalysis
$ignoredIndices : array<int, int>

indices of the use statements themselves that should not be checked as being "used"

Return values
bool

removeImportStatementIfEmpty()

private removeImportStatementIfEmpty(Tokens $tokens, NamespaceUseAnalysis $useDeclaration) : void
Parameters
$tokens : Tokens
$useDeclaration : NamespaceUseAnalysis

removeLineIfEmpty()

private removeLineIfEmpty(Tokens $tokens, NamespaceUseAnalysis $useAnalysis) : void
Parameters
$tokens : Tokens
$useAnalysis : NamespaceUseAnalysis

removeUseDeclaration()

private removeUseDeclaration(Tokens $tokens, NamespaceUseAnalysis $useDeclaration[, bool $forceCompleteRemoval = false ]) : void
Parameters
$tokens : Tokens
$useDeclaration : NamespaceUseAnalysis
$forceCompleteRemoval : bool = false

removeUsesInSameNamespace()

private removeUsesInSameNamespace(Tokens $tokens, array<int, NamespaceUseAnalysis$useDeclarations, NamespaceAnalysis $namespaceDeclaration) : void
Parameters
$tokens : Tokens
$useDeclarations : array<int, NamespaceUseAnalysis>
$namespaceDeclaration : NamespaceAnalysis

scanForNonEmptyTokensUntilNewLineFound()

Returns tuple with the index of first token with whitespace containing new line char and a flag if any non-empty token was found along the way.

private scanForNonEmptyTokensUntilNewLineFound(Tokens $tokens, int $index, -1|1 $direction) : array{0: null|int, 1: bool}
Parameters
$tokens : Tokens
$index : int
$direction : -1|1
Return values
array{0: null|int, 1: bool}

        
On this page

Search results