ClassDefinitionFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface, WhitespacesAwareFixerInterface
uses
ConfigurableFixerTrait
FinalYes
Fixer for part of the rules defined in PSR2 ¶4.1 Extends and Implements and PSR12 ¶8. Anonymous Classes.
Tags
Table of Contents
Interfaces
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
- fixClassyDefinition() : void
- fixClassyDefinitionExtends() : _ClassExtendsInfo
- fixClassyDefinitionImplements() : _ClassImplementsInfo
- fixClassyDefinitionOpenSpacing() : int
- getClassyDefinitionInfo() : _ClassImplementsInfo, anonymousClass: bool, final: false|int, abstract: false|int, readonly: false|int}
- getClassyInheritanceInfo() : array<string, 1>|array{start: int, multiLine: bool}
- makeClassyDefinitionSingleLine() : void
- makeClassyInheritancePartMultiLine() : void
- sortClassModifiers() : void
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 BracesFixer, SingleLineEmptyBodyFixer. Must run after NewWithBracesFixer, NewWithParenthesesFixer.
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
FixerConfigurationResolverInterfacefixClassyDefinition()
private
fixClassyDefinition(Tokens $tokens, int $classyIndex) : void
Parameters
- $tokens : Tokens
- $classyIndex : int
-
Class definition token start index
fixClassyDefinitionExtends()
private
fixClassyDefinitionExtends(Tokens $tokens, int $classOpenIndex, _ClassExtendsInfo $classExtendsInfo) : _ClassExtendsInfo
Parameters
- $tokens : Tokens
- $classOpenIndex : int
- $classExtendsInfo : _ClassExtendsInfo
Return values
_ClassExtendsInfofixClassyDefinitionImplements()
private
fixClassyDefinitionImplements(Tokens $tokens, int $classOpenIndex, _ClassImplementsInfo $classImplementsInfo) : _ClassImplementsInfo
Parameters
- $tokens : Tokens
- $classOpenIndex : int
- $classImplementsInfo : _ClassImplementsInfo
Return values
_ClassImplementsInfofixClassyDefinitionOpenSpacing()
private
fixClassyDefinitionOpenSpacing(Tokens $tokens, _ClassImplementsInfo, anonymousClass: bool, final: false|int, abstract: false|int, readonly: false|int} $classDefInfo) : int
Parameters
- $tokens : Tokens
- $classDefInfo : _ClassImplementsInfo, anonymousClass: bool, final: false|int, abstract: false|int, readonly: false|int}
Return values
intgetClassyDefinitionInfo()
private
getClassyDefinitionInfo(Tokens $tokens, int $classyIndex) : _ClassImplementsInfo, anonymousClass: bool, final: false|int, abstract: false|int, readonly: false|int}
Parameters
- $tokens : Tokens
- $classyIndex : int
Return values
_ClassImplementsInfo, anonymousClass: bool, final: false|int, abstract: false|int, readonly: false|int}getClassyInheritanceInfo()
private
getClassyInheritanceInfo(Tokens $tokens, int $startIndex, string $label) : array<string, 1>|array{start: int, multiLine: bool}
Parameters
- $tokens : Tokens
- $startIndex : int
- $label : string
Return values
array<string, 1>|array{start: int, multiLine: bool}makeClassyDefinitionSingleLine()
private
makeClassyDefinitionSingleLine(Tokens $tokens, int $startIndex, int $endIndex) : void
Parameters
- $tokens : Tokens
- $startIndex : int
- $endIndex : int
makeClassyInheritancePartMultiLine()
private
makeClassyInheritancePartMultiLine(Tokens $tokens, int $startIndex, int $endIndex) : void
Parameters
- $tokens : Tokens
- $startIndex : int
- $endIndex : int
sortClassModifiers()
private
sortClassModifiers(Tokens $tokens, array{final: false|int, abstract: false|int, readonly: false|int} $classDefInfo) : void
Parameters
- $tokens : Tokens
- $classDefInfo : array{final: false|int, abstract: false|int, readonly: false|int}