Documentation

OrderedImportsFixer extends AbstractFixer
in package
implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface uses ConfigurableFixerTrait

FinalYes
Tags
author

Sebastiaan Stok s.stok@rollerscapes.net

author

Dariusz Rumiński dariusz.ruminski@gmail.com

author

Darius Matulionis darius@matulionis.lt

author

Adriano Pilger adriano.pilger@gmail.com

phpstan-type

UseImportInfo array{ namespace: non-empty-string, startIndex: int, endIndex: int, importType: self::IMPORT_TYPE*, group: bool, }

phpstan-type

_AutogeneratedInputConfiguration array{ case_sensitive?: bool, imports_order?: list|null, sort_algorithm?: 'alpha'|'length'|'none' }

phpstan-type

_AutogeneratedComputedConfiguration array{ case_sensitive: bool, imports_order: list|null, sort_algorithm: 'alpha'|'length'|'none' }

implements

ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>

Table of Contents

Interfaces

ConfigurableFixerInterface
WhitespacesAwareFixerInterface

Constants

SUPPORTED_SORT_ALGORITHMS  = [self::SORT_ALPHA, self::SORT_LENGTH, self::SORT_NONE]
Array of supported sort algorithms in configuration.
SUPPORTED_SORT_TYPES  = [self::IMPORT_TYPE_CLASS, self::IMPORT_TYPE_CONST, self::IMPORT_TYPE_FUNCTION]
Array of supported sort types in configuration.

Methods

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
getNewOrder()  : array<int, _UseImportInfo>
prepareNamespace()  : string
setNewOrder()  : void
sortAlphabetically()  : int
This method is used for sorting the uses in a namespace.
sortByAlgorithm()  : array<int, _UseImportInfo>
sortByLength()  : int
This method is used for sorting the uses statements in a namespace by length.

Constants

SUPPORTED_SORT_ALGORITHMS

Array of supported sort algorithms in configuration.

private array<int, string> SUPPORTED_SORT_ALGORITHMS = [self::SORT_ALPHA, self::SORT_LENGTH, self::SORT_NONE]

SUPPORTED_SORT_TYPES

Array of supported sort types in configuration.

private array<int, string> SUPPORTED_SORT_TYPES = [self::IMPORT_TYPE_CLASS, self::IMPORT_TYPE_CONST, self::IMPORT_TYPE_FUNCTION]

Methods

getPriority()

Returns the priority of the fixer.

public getPriority() : int

Must run before BlankLineBetweenImportGroupsFixer. Must run after FullyQualifiedStrictTypesFixer, GlobalNamespaceImportFixer, NoLeadingImportSlashFixer.

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

getNewOrder()

private getNewOrder(array<int, int> $uses, Tokens $tokens) : array<int, _UseImportInfo>
Parameters
$uses : array<int, int>
$tokens : Tokens
Return values
array<int, _UseImportInfo>

prepareNamespace()

private prepareNamespace(string $namespace) : string
Parameters
$namespace : string
Return values
string

setNewOrder()

private setNewOrder(Tokens $tokens, array<int, _UseImportInfo$usesOrder) : void
Parameters
$tokens : Tokens
$usesOrder : array<int, _UseImportInfo>

sortAlphabetically()

This method is used for sorting the uses in a namespace.

private sortAlphabetically(_UseImportInfo $first, _UseImportInfo $second) : int
Parameters
$first : _UseImportInfo
$second : _UseImportInfo
Return values
int

sortByAlgorithm()

private sortByAlgorithm(array<int, _UseImportInfo$indices) : array<int, _UseImportInfo>
Parameters
$indices : array<int, _UseImportInfo>
Return values
array<int, _UseImportInfo>

sortByLength()

This method is used for sorting the uses statements in a namespace by length.

private sortByLength(_UseImportInfo $first, _UseImportInfo $second) : int
Parameters
$first : _UseImportInfo
$second : _UseImportInfo
Return values
int

        
On this page

Search results