Documentation

FunctionReturnInWriteContextPass extends CodeCleanerPass
in package

Validate that the functions are used correctly.

Tags
author

Martin Hasoň martin.hason@gmail.com

Table of Contents

EXCEPTION_MESSAGE  = "Can't use function return value in write context"
PHP55_MESSAGE  = 'Cannot use isset() on the result of a function call (you can use "null !== func()" instead)'
$atLeastPhp55  : mixed
__construct()  : mixed
afterTraverse()  : null|array<string|int, Node>
Called once after traversal.
beforeTraverse()  : null|array<string|int, Node>
Called once before traversal.
enterNode()  : mixed
Validate that the functions are used correctly.
leaveNode()  : null|int|Node|array<string|int, Node>
Called when leaving a node.
isCallNode()  : mixed

Constants

PHP55_MESSAGE

public mixed PHP55_MESSAGE = 'Cannot use isset() on the result of a function call (you can use "null !== func()" instead)'

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

Called once before traversal.

public beforeTraverse(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

enterNode()

Validate that the functions are used correctly.

public enterNode(Node $node) : mixed
Parameters
$node : Node
Tags
throws
FatalErrorException

if a function is passed as an argument reference

throws
FatalErrorException

if a function is used as an argument in the isset

throws
FatalErrorException

if a function is used as an argument in the empty, only for PHP < 5.5

throws
FatalErrorException

if a value is assigned to a function

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