Documentation

NoPhp4ConstructorFixer extends AbstractFixer
in package

Tags
author

Matteo Beccati matteo@beccati.com

Table of Contents

getDefinition()  : mixed
{@inheritdoc}
getPriority()  : mixed
{@inheritdoc}
isCandidate()  : mixed
{@inheritdoc}
isRisky()  : mixed
{@inheritdoc}
applyFix()  : mixed
{@inheritdoc}
findFunction()  : null|array<string|int, mixed>
Find a function or method matching a given name within certain bounds.
fixConstructor()  : mixed
Fix constructor within a class, if possible.
fixInfiniteRecursion()  : mixed
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()  : mixed
Fix calls to the parent constructor within a class.
getWrapperMethodSequence()  : array<string|int, mixed>
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

getPriority()

{@inheritdoc}

public getPriority() : mixed

Must run before OrderedClassElementsFixer.

Return values
mixed

applyFix()

{@inheritdoc}

protected applyFix(SplFileInfo $file, Tokens $tokens) : mixed
Parameters
$file : SplFileInfo
$tokens : Tokens
Return values
mixed

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<string|int, mixed>
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<string|int, mixed>

An associative array, if a match is found:

  • 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)

fixConstructor()

Fix constructor within a class, if possible.

private fixConstructor(Tokens $tokens, string $className, int $classStart, int $classEnd) : mixed
Parameters
$tokens : Tokens

the Tokens instance

$className : string

the class name

$classStart : int

the class start index

$classEnd : int

the class end index

Return values
mixed

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) : mixed
Parameters
$tokens : Tokens

the Tokens instance

$start : int

the PHP4 constructor body start

$end : int

the PHP4 constructor body end

Return values
mixed

fixParent()

Fix calls to the parent constructor within a class.

private fixParent(Tokens $tokens, int $classStart, int $classEnd) : mixed
Parameters
$tokens : Tokens

the Tokens instance

$classStart : int

the class start index

$classEnd : int

the class end index

Return values
mixed

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<string|int, mixed>
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<string|int, mixed>

an array containing the sequence and case sensitiveness [ 0 => $seq, 1 => $case ]

Search results