\SuperClosure\Analyzer\VisitorClosureLocatorVisitor

This is a visitor that extends the nikic/php-parser library and looks for a closure node and its location.

Summary

Methods
Properties
Constants
beforeTraverse()
enterNode()
leaveNode()
afterTraverse()
__construct()
$closureNode
$location
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$reflection
N/A

Properties

$location

$location : array

Type

array

$reflection

$reflection : \ReflectionFunction

Type

\ReflectionFunction

Methods

beforeTraverse()

beforeTraverse(array  $nodes) : null|array<mixed,\PhpParser\Node>

Called once before traversal.

Return value semantics:

  • null: $nodes stays as-is
  • otherwise: $nodes is set to the return value

Parameters

array $nodes

Array of nodes

Returns

null|array<mixed,\PhpParser\Node> —

Array of nodes

enterNode()

enterNode(\PhpParser\Node  $node) : null|integer|\PhpParser\Node

Called when entering a node.

Return value semantics:

  • null => $node stays as-is
  • NodeTraverser::DONT_TRAVERSE_CHILDREN => Children of $node are not traversed. $node stays as-is
  • NodeTraverser::STOP_TRAVERSAL => Traversal is aborted. $node stays as-is
  • otherwise => $node is set to the return value

Parameters

\PhpParser\Node $node

Node

Returns

null|integer|\PhpParser\Node

Node

leaveNode()

leaveNode(\PhpParser\Node  $node) : null|false|integer|\PhpParser\Node|array<mixed,\PhpParser\Node>

Called when leaving a 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

\PhpParser\Node $node

Node

Returns

null|false|integer|\PhpParser\Node|array<mixed,\PhpParser\Node> —

Node

afterTraverse()

afterTraverse(array  $nodes) : null|array<mixed,\PhpParser\Node>

Called once after traversal.

Return value semantics:

  • null: $nodes stays as-is
  • otherwise: $nodes is set to the return value

Parameters

array $nodes

Array of nodes

Returns

null|array<mixed,\PhpParser\Node> —

Array of nodes

__construct()

__construct(\ReflectionFunction  $reflection) 

Parameters

\ReflectionFunction $reflection