NoSuperfluousPhpdocTagsFixer
extends AbstractFixer
in package
implements
ConfigurableFixerInterface
uses
ConfigurableFixerTrait
Tags
Table of Contents
Interfaces
Constants
- NO_TYPE_INFO = ['types' => [], 'allows_null' => true]
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
- annotationIsSuperfluous() : bool
- findDocumentedElement() : null|_DocumentElement
- fixClassDocComment() : string
- fixFunctionDocComment() : string
- fixPropertyDocComment() : string
- getArgumentsInfo() : array<non-empty-string, _TypeInfo>
- getReturnTypeInfo() : _TypeInfo
- parseTypeHint() : _TypeInfo
- removeSuperfluousInheritDoc() : string
- removeSuperfluousModifierAnnotation() : void
- toComparableNames() : array<int, string>
- Normalizes types to make them comparable.
Constants
NO_TYPE_INFO
private
_TypeInfo
NO_TYPE_INFO
= ['types' => [], 'allows_null' => true]
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 NoEmptyPhpdocFixer, PhpdocAlignFixer, VoidReturnFixer. Must run after AlignMultilineCommentFixer, CommentToPhpdocFixer, FullyQualifiedStrictTypesFixer, PhpdocAddMissingParamAnnotationFixer, PhpdocIndentFixer, PhpdocLineSpanFixer, PhpdocReturnSelfReferenceFixer, PhpdocScalarFixer, PhpdocToCommentFixer, PhpdocToParamTypeFixer, PhpdocToPropertyTypeFixer, PhpdocToReturnTypeFixer, PhpdocTypesFixer.
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
FixerConfigurationResolverInterfaceannotationIsSuperfluous()
private
annotationIsSuperfluous(Annotation $annotation, _TypeInfo $info, null|non-empty-string $namespace, string|null $currentSymbol, array<string, string> $symbolShortNames) : bool
Parameters
- $annotation : Annotation
- $info : _TypeInfo
- $namespace : null|non-empty-string
- $currentSymbol : string|null
- $symbolShortNames : array<string, string>
Return values
boolfindDocumentedElement()
private
findDocumentedElement(Tokens $tokens, int $docCommentIndex) : null|_DocumentElement
Parameters
- $tokens : Tokens
- $docCommentIndex : int
Return values
null|_DocumentElementfixClassDocComment()
private
fixClassDocComment(string $content, _DocumentElement|array{type: "classy"} $element) : string
Parameters
- $content : string
- $element : _DocumentElement|array{type: "classy"}
Return values
stringfixFunctionDocComment()
private
fixFunctionDocComment(string $content, Tokens $tokens, _DocumentElement|array{type: "function"} $element, null|non-empty-string $namespace, string|null $currentSymbol, array<string, string> $shortNames) : string
Parameters
- $content : string
- $tokens : Tokens
- $element : _DocumentElement|array{type: "function"}
- $namespace : null|non-empty-string
- $currentSymbol : string|null
- $shortNames : array<string, string>
Return values
stringfixPropertyDocComment()
private
fixPropertyDocComment(string $content, Tokens $tokens, _DocumentElement|array{type: "property"} $element, null|non-empty-string $namespace, string|null $currentSymbol, array<string, string> $shortNames) : string
Parameters
- $content : string
- $tokens : Tokens
- $element : _DocumentElement|array{type: "property"}
- $namespace : null|non-empty-string
- $currentSymbol : string|null
- $shortNames : array<string, string>
Return values
stringgetArgumentsInfo()
private
getArgumentsInfo(Tokens $tokens, int $start, int $end) : array<non-empty-string, _TypeInfo>
Parameters
- $tokens : Tokens
- $start : int
- $end : int
Return values
array<non-empty-string, _TypeInfo>getReturnTypeInfo()
private
getReturnTypeInfo(Tokens $tokens, int $closingParenthesisIndex) : _TypeInfo
Parameters
- $tokens : Tokens
- $closingParenthesisIndex : int
Return values
_TypeInfoparseTypeHint()
private
parseTypeHint(Tokens $tokens, int $index) : _TypeInfo
Parameters
- $tokens : Tokens
- $index : int
-
The index of the first token of the type hint
Return values
_TypeInforemoveSuperfluousInheritDoc()
private
removeSuperfluousInheritDoc(string $docComment) : string
Parameters
- $docComment : string
Return values
stringremoveSuperfluousModifierAnnotation()
private
removeSuperfluousModifierAnnotation(DocBlock $docBlock, _DocumentElement $element) : void
Parameters
- $docBlock : DocBlock
- $element : _DocumentElement
toComparableNames()
Normalizes types to make them comparable.
private
toComparableNames(array<int, string> $types, null|non-empty-string $namespace, string|null $currentSymbol, array<string, string> $symbolShortNames) : array<int, string>
Converts given types to lowercase, replaces imports aliases with their matching FQCN, and finally sorts the result.
Parameters
- $types : array<int, string>
-
The types to normalize
- $namespace : null|non-empty-string
- $currentSymbol : string|null
- $symbolShortNames : array<string, string>
-
The imports aliases
Return values
array<int, string> —The normalized types