ReturnAssignmentFixer
extends AbstractFixer
in package
FinalYes
Table of Contents
Properties
- $tokensAnalyzer : TokensAnalyzer
Methods
- getDefinition() : FixerDefinitionInterface
- getPriority() : int
- {@inheritdoc}
- isCandidate() : bool
- applyFix() : void
- clearIfSave() : void
- fixFunction() : int
- isCloseBracePartOfDefinition() : null|int
- isOpenBraceOfAnonymousClass() : null|int
- isOpenBraceOfLambda() : null|int
- isOpenBraceOfMatch() : null|int
- isUsedInCatchOrFinally() : bool
- simplifyReturnStatement() : int
Properties
$tokensAnalyzer
private
TokensAnalyzer
$tokensAnalyzer
Methods
getDefinition()
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
{@inheritdoc}
public
getPriority() : int
Must run before BlankLineBeforeStatementFixer. Must run after NoEmptyStatementFixer, NoUnneededBracesFixer, NoUnneededCurlyBracesFixer.
Return values
intisCandidate()
public
isCandidate(Tokens $tokens) : bool
Parameters
- $tokens : Tokens
Return values
boolapplyFix()
protected
applyFix(SplFileInfo $file, Tokens $tokens) : void
Parameters
- $file : SplFileInfo
- $tokens : Tokens
clearIfSave()
private
clearIfSave(Tokens $tokens, int $index) : void
Parameters
- $tokens : Tokens
- $index : int
fixFunction()
private
fixFunction(Tokens $tokens, int $functionIndex, int $functionOpenIndex, int $functionCloseIndex) : int
Parameters
- $tokens : Tokens
- $functionIndex : int
-
token index of T_FUNCTION
- $functionOpenIndex : int
-
token index of the opening brace token of the function
- $functionCloseIndex : int
-
token index of the closing brace token of the function
Return values
int —= 0 number of tokens inserted into the Tokens collection
isCloseBracePartOfDefinition()
private
isCloseBracePartOfDefinition(Tokens $tokens, int $index) : null|int
Parameters
- $tokens : Tokens
- $index : int
-
open brace index
Return values
null|int —index of the first token of a definition (lambda, anonymous class or match) or null
if not an anonymous
isOpenBraceOfAnonymousClass()
private
isOpenBraceOfAnonymousClass(Tokens $tokens, int $index) : null|int
Parameters
- $tokens : Tokens
- $index : int
-
open brace index
Return values
null|int —index of T_NEW of anonymous class or null
if not an anonymous
isOpenBraceOfLambda()
private
isOpenBraceOfLambda(Tokens $tokens, int $index) : null|int
Parameters
- $tokens : Tokens
- $index : int
-
open brace index
Return values
null|int —index of T_FUNCTION or T_STATIC of lambda or null
if not a lambda
isOpenBraceOfMatch()
private
isOpenBraceOfMatch(Tokens $tokens, int $index) : null|int
Parameters
- $tokens : Tokens
- $index : int
-
open brace index
Return values
null|int —index of T_MATCH or null
if not a match
isUsedInCatchOrFinally()
private
isUsedInCatchOrFinally(Tokens $tokens, int $returnVarIndex, int $functionOpenIndex, int $functionCloseIndex) : bool
Parameters
- $tokens : Tokens
- $returnVarIndex : int
- $functionOpenIndex : int
- $functionCloseIndex : int
Return values
boolsimplifyReturnStatement()
private
simplifyReturnStatement(Tokens $tokens, int $assignVarIndex, int $assignVarOperatorIndex, int $returnIndex, int $returnVarEndIndex) : int
Parameters
- $tokens : Tokens
- $assignVarIndex : int
- $assignVarOperatorIndex : int
- $returnIndex : int
- $returnVarEndIndex : int
Return values
int —= 0 number of tokens inserted into the Tokens collection