Documentation

ValidConstructorPass extends CodeCleanerPass
in package

Validate that the constructor method is not static, and does not have a return type.

Checks both explicit __construct methods as well as old-style constructor methods with the same name as the class (for non-namespaced classes).

As of PHP 5.3.3, methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn't affect non-namespaced classes.

Tags
author

Martin Hasoň martin.hason@gmail.com

Table of Contents

$namespace  : mixed
afterTraverse()  : null|array<string|int, Node>
Called once after traversal.
beforeTraverse()  : mixed
enterNode()  : mixed
Validate that the constructor is not static and does not have a return type.
leaveNode()  : null|int|Node|array<string|int, Node>
Called when leaving a node.
validateConstructor()  : mixed

Properties

Methods

afterTraverse()

Called once after traversal.

public afterTraverse(array<string|int, mixed> $nodes) : null|array<string|int, Node>

Return value semantics:

  • null: $nodes stays as-is
  • otherwise: $nodes is set to the return value
Parameters
$nodes : array<string|int, mixed>

Array of nodes

Return values
null|array<string|int, Node>

Array of nodes

beforeTraverse()

public beforeTraverse(array<string|int, mixed> $nodes) : mixed
Parameters
$nodes : array<string|int, mixed>
Return values
mixed

leaveNode()

Called when leaving a node.

public leaveNode(Node $node) : null|int|Node|array<string|int, Node>

Return value semantics:

  • null => $node stays as-is
  • NodeTraverser::REMOVE_NODE => $node is removed from the parent array
  • NodeTraverser::STOP_TRAVERSAL => Traversal is aborted. $node stays as-is
  • array (of Nodes) => The return value is merged into the parent array (at the position of the $node)
  • otherwise => $node is set to the return value
Parameters
$node : Node

Node

Return values
null|int|Node|array<string|int, Node>

Replacement node (or special return value)

Search results