NoPhp4ConstructorFixer
extends AbstractFixer
in package
Tags
Table of Contents
Methods
- getDefinition() : FixerDefinitionInterface
- getPriority() : int
- {@inheritdoc}
- isCandidate() : bool
- isRisky() : bool
- applyFix() : void
-
findFunction()
: null|array{nameIndex: int, startIndex: int, endIndex: int, bodyIndex: int, modifiers: list
} - Find a function or method matching a given name within certain bounds.
- fixConstructor() : void
- Fix constructor within a class, if possible.
- fixInfiniteRecursion() : void
- Fix a particular infinite recursion issue happening when the parent class has __construct and the child has only a PHP4 constructor that calls the parent constructor as $this->__construct().
- fixParent() : void
- Fix calls to the parent constructor within a class.
-
getWrapperMethodSequence()
: array{: list
- >, : array{3: false}}
- Generate the sequence of tokens necessary for the body of a wrapper method that simply calls $this->{$method}( [args...] ) with the same arguments as its own signature.
Methods
getDefinition()
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
{@inheritdoc}
public
getPriority() : int
Must run before OrderedClassElementsFixer.
Return values
intisCandidate()
public
isCandidate(Tokens $tokens) : bool
Parameters
- $tokens : Tokens
Return values
boolisRisky()
public
isRisky() : bool
Return values
boolapplyFix()
protected
applyFix(SplFileInfo $file, Tokens $tokens) : void
Parameters
- $file : SplFileInfo
- $tokens : Tokens
findFunction()
Find a function or method matching a given name within certain bounds.
private
findFunction(Tokens $tokens, string $name, int $startIndex, int $endIndex) : null|array{nameIndex: int, startIndex: int, endIndex: int, bodyIndex: int, modifiers: list}
Returns:
- nameIndex (int): The index of the function/method name.
- startIndex (int): The index of the function/method start.
- endIndex (int): The index of the function/method end.
- bodyIndex (int): The index of the function/method body.
- modifiers (array): The modifiers as array keys and their index as the values, e.g. array(T_PUBLIC => 10)
Parameters
- $tokens : Tokens
-
the Tokens instance
- $name : string
-
the function/Method name
- $startIndex : int
-
the search start index
- $endIndex : int
-
the search end index
Return values
null|array{nameIndex: int, startIndex: int, endIndex: int, bodyIndex: int, modifiers: listfixConstructor()
Fix constructor within a class, if possible.
private
fixConstructor(Tokens $tokens, string $className, int $classStart, int $classEnd) : void
Parameters
- $tokens : Tokens
-
the Tokens instance
- $className : string
-
the class name
- $classStart : int
-
the class start index
- $classEnd : int
-
the class end index
fixInfiniteRecursion()
Fix a particular infinite recursion issue happening when the parent class has __construct and the child has only a PHP4 constructor that calls the parent constructor as $this->__construct().
private
fixInfiniteRecursion(Tokens $tokens, int $start, int $end) : void
Parameters
- $tokens : Tokens
-
the Tokens instance
- $start : int
-
the PHP4 constructor body start
- $end : int
-
the PHP4 constructor body end
fixParent()
Fix calls to the parent constructor within a class.
private
fixParent(Tokens $tokens, int $classStart, int $classEnd) : void
Parameters
- $tokens : Tokens
-
the Tokens instance
- $classStart : int
-
the class start index
- $classEnd : int
-
the class end index
getWrapperMethodSequence()
Generate the sequence of tokens necessary for the body of a wrapper method that simply calls $this->{$method}( [args...] ) with the same arguments as its own signature.
private
getWrapperMethodSequence(Tokens $tokens, string $method, int $startIndex, int $bodyIndex) : array{: list>, : array{3: false}}
Parameters
- $tokens : Tokens
-
the Tokens instance
- $method : string
-
the wrapped method name
- $startIndex : int
-
function/method start index
- $bodyIndex : int
-
function/method body index
Return values
array{: list- >, : array{3: false}}