FullyQualifiedStrictTypesFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface, WhitespacesAwareFixerInterface
uses
ConfigurableFixerTrait
Tags
Table of Contents
Interfaces
Constants
- REGEX_CLASS = '(?:\\\\?+' . \PhpCsFixer\DocBlock\TypeExpression::REGEX_IDENTIFIER . '(\\\\' . \PhpCsFixer\DocBlock\TypeExpression::REGEX_IDENTIFIER . ')*+)'
Properties
- $cacheUseNameByShortNameLower : array<string, string>
- $cacheUseShortNameByNameLower : array<string, string>
- $cacheUsesLast : array<string, string>
-
$discoveredSymbols
: array{const?: list
, class?: list , function?: list }|null - $reservedIdentifiersByLevel : array<int<0, max>, array<string, true>>
-
$symbolsForImport
: array{const?: array
, class?: array , function?: array }
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
- createImportProcessor() : ImportProcessor
- We need to create import processor dynamically (not in costructor), because actual whitespace configuration is set later, not when fixer's instance is created.
- determineShortType() : null|array<int, Token>
- Determines short type based on FQCN, current namespace and imports (`use` declarations).
- fixAttribute() : void
- fixCatch() : void
- fixExtendsImplements() : void
- fixFunction() : void
- fixNextName() : void
- fixPhpDoc() : void
- fixPrevName() : void
- getTypes() : iterable<string|int, array{: int, : int}>
- isReservedIdentifier() : bool
- namespacedStringToTokens() : array<int, Token>
- refreshUsesCache() : void
- replaceByShortType() : void
- resolveSymbol() : string
- Resolve absolute or relative symbol to normalized FQCN.
- setupUsesFromDiscoveredSymbols() : void
- shortenClassIfPossible() : int
- shortenSymbol() : string
- Shorten normalized FQCN as much as possible.
Constants
REGEX_CLASS
private
mixed
REGEX_CLASS
= '(?:\\\\?+' . \PhpCsFixer\DocBlock\TypeExpression::REGEX_IDENTIFIER . '(\\\\' . \PhpCsFixer\DocBlock\TypeExpression::REGEX_IDENTIFIER . ')*+)'
Properties
$cacheUseNameByShortNameLower
private
array<string, string>
$cacheUseNameByShortNameLower
$cacheUseShortNameByNameLower
private
array<string, string>
$cacheUseShortNameByNameLower
$cacheUsesLast
private
array<string, string>
$cacheUsesLast
= []
$discoveredSymbols
private
array{const?: list, class?: list, function?: list}|null
$discoveredSymbols
$reservedIdentifiersByLevel
private
array<int<0, max>, array<string, true>>
$reservedIdentifiersByLevel
$symbolsForImport
private
array{const?: array, class?: array, function?: array}
$symbolsForImport
= []
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 NoSuperfluousPhpdocTagsFixer, OrderedAttributesFixer, OrderedImportsFixer, OrderedInterfacesFixer, StatementIndentationFixer. Must run after ClassKeywordFixer, PhpUnitAttributesFixer, PhpdocToReturnTypeFixer.
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
FixerConfigurationResolverInterfacecreateImportProcessor()
We need to create import processor dynamically (not in costructor), because actual whitespace configuration is set later, not when fixer's instance is created.
private
createImportProcessor() : ImportProcessor
Return values
ImportProcessordetermineShortType()
Determines short type based on FQCN, current namespace and imports (`use` declarations).
private
determineShortType(string $typeName, array<string, string> $uses, string $namespaceName) : null|array<int, Token>
Parameters
- $typeName : string
- $uses : array<string, string>
- $namespaceName : string
Return values
null|array<int, Token>fixAttribute()
private
fixAttribute(Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
fixCatch()
private
fixCatch(Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
fixExtendsImplements()
private
fixExtendsImplements(Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
fixFunction()
private
fixFunction(FunctionsAnalyzer $functionsAnalyzer, Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $functionsAnalyzer : FunctionsAnalyzer
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
fixNextName()
private
fixNextName(Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
fixPhpDoc()
private
fixPhpDoc(Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
fixPrevName()
private
fixPrevName(Tokens $tokens, int $index, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $index : int
- $uses : array<string, string>
- $namespaceName : string
getTypes()
private
getTypes(Tokens $tokens, int $index, int $endIndex) : iterable<string|int, array{: int, : int}>
Parameters
- $tokens : Tokens
- $index : int
- $endIndex : int
Return values
iterable<string|int, array{: int, : int}>isReservedIdentifier()
private
isReservedIdentifier(string $symbol) : bool
Parameters
- $symbol : string
Return values
boolnamespacedStringToTokens()
private
namespacedStringToTokens(string $input) : array<int, Token>
Parameters
- $input : string
Return values
array<int, Token>refreshUsesCache()
private
refreshUsesCache(array<string, string> $uses) : void
Parameters
- $uses : array<string, string>
replaceByShortType()
private
replaceByShortType(Tokens $tokens, TypeAnalysis $type, array<string, string> $uses, string $namespaceName) : void
Parameters
- $tokens : Tokens
- $type : TypeAnalysis
- $uses : array<string, string>
- $namespaceName : string
resolveSymbol()
Resolve absolute or relative symbol to normalized FQCN.
private
resolveSymbol(string $symbol, array<string, string> $uses, string $namespaceName) : string
Parameters
- $symbol : string
- $uses : array<string, string>
- $namespaceName : string
Return values
stringsetupUsesFromDiscoveredSymbols()
private
setupUsesFromDiscoveredSymbols(array<string, string> &$uses, string $namespaceName) : void
Parameters
- $uses : array<string, string>
- $namespaceName : string
shortenClassIfPossible()
private
shortenClassIfPossible(Tokens $tokens, int $typeStartIndex, int $typeEndIndex, array<string, string> $uses, string $namespaceName) : int
Parameters
- $tokens : Tokens
- $typeStartIndex : int
- $typeEndIndex : int
- $uses : array<string, string>
- $namespaceName : string
Return values
intshortenSymbol()
Shorten normalized FQCN as much as possible.
private
shortenSymbol(string $fqcn, array<string, string> $uses, string $namespaceName) : string
Parameters
- $fqcn : string
- $uses : array<string, string>
- $namespaceName : string