OrderedClassElementsFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface
uses
ConfigurableFixerTrait
Tags
Table of Contents
Interfaces
Constants
- SUPPORTED_SORT_ALGORITHMS = [self::SORT_NONE, self::SORT_ALPHA]
Properties
- $specialTypes : array<string, null>
- $typeHierarchy : array<string, null|array<int, string>>
- $typePosition : array<string, int>
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
- configurePostNormalisation() : void
- createConfigurationDefinition() : FixerConfigurationResolverInterface
- detectElementType() : array<int, string>|string
- findElementEnd() : int
- getElements() : array<int, _ClassElement>
- sortElements() : array<int, _ClassElement>
- sortGroupElements() : int
- sortTokens() : void
Constants
SUPPORTED_SORT_ALGORITHMS
private
mixed
SUPPORTED_SORT_ALGORITHMS
= [self::SORT_NONE, self::SORT_ALPHA]
Properties
$specialTypes
private
static array<string, null>
$specialTypes
= ['construct' => null, 'destruct' => null, 'magic' => null, 'phpunit' => null]
Array containing special method types
$typeHierarchy
private
static array<string, null|array<int, string>>
$typeHierarchy
= ['use_trait' => null, 'public' => null, 'protected' => null, 'private' => null, 'case' => ['public'], 'constant' => null, 'constant_public' => ['constant', 'public'], 'constant_protected' => ['constant', 'protected'], 'constant_private' => ['constant', 'private'], 'property' => null, 'property_static' => ['property'], 'property_public' => ['property', 'public'], 'property_protected' => ['property', 'protected'], 'property_private' => ['property', 'private'], 'property_public_readonly' => ['property_readonly', 'property_public'], 'property_protected_readonly' => ['property_readonly', 'property_protected'], 'property_private_readonly' => ['property_readonly', 'property_private'], 'property_public_static' => ['property_static', 'property_public'], 'property_protected_static' => ['property_static', 'property_protected'], 'property_private_static' => ['property_static', 'property_private'], 'method' => null, 'method_abstract' => ['method'], 'method_static' => ['method'], 'method_public' => ['method', 'public'], 'method_protected' => ['method', 'protected'], 'method_private' => ['method', 'private'], 'method_public_abstract' => ['method_abstract', 'method_public'], 'method_protected_abstract' => ['method_abstract', 'method_protected'], 'method_private_abstract' => ['method_abstract', 'method_private'], 'method_public_abstract_static' => ['method_abstract', 'method_static', 'method_public'], 'method_protected_abstract_static' => ['method_abstract', 'method_static', 'method_protected'], 'method_private_abstract_static' => ['method_abstract', 'method_static', 'method_private'], 'method_public_static' => ['method_static', 'method_public'], 'method_protected_static' => ['method_static', 'method_protected'], 'method_private_static' => ['method_static', 'method_private']]
Array containing all class element base types (keys) and their parent types (values)
$typePosition
private
array<string, int>
$typePosition
Resolved configuration array (type => position)
Methods
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 ClassAttributesSeparationFixer, NoBlankLinesAfterClassOpeningFixer, SpaceAfterSemicolonFixer. Must run after NoPhp4ConstructorFixer, ProtectedToPrivateFixer.
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
configurePostNormalisation()
protected
configurePostNormalisation() : void
createConfigurationDefinition()
protected
createConfigurationDefinition() : FixerConfigurationResolverInterface
Return values
FixerConfigurationResolverInterfacedetectElementType()
private
detectElementType(Tokens $tokens, int $index) : array<int, string>|string
Parameters
- $tokens : Tokens
- $index : int
Return values
array<int, string>|string —type or array of type and name
findElementEnd()
private
findElementEnd(Tokens $tokens, int $index) : int
Parameters
- $tokens : Tokens
- $index : int
Return values
intgetElements()
private
getElements(Tokens $tokens, int $startIndex) : array<int, _ClassElement>
Parameters
- $tokens : Tokens
- $startIndex : int
Return values
array<int, _ClassElement>sortElements()
private
sortElements(array<int, _ClassElement> $elements) : array<int, _ClassElement>
Parameters
- $elements : array<int, _ClassElement>
Return values
array<int, _ClassElement>sortGroupElements()
private
sortGroupElements(_ClassElement $a, _ClassElement $b) : int
Parameters
- $a : _ClassElement
- $b : _ClassElement
Return values
intsortTokens()
private
sortTokens(Tokens $tokens, int $startIndex, int $endIndex, array<int, _ClassElement> $elements) : void
Parameters
- $tokens : Tokens
- $startIndex : int
- $endIndex : int
- $elements : array<int, _ClassElement>