StrictTypesPass
extends CodeCleanerPass
in package
Provide implicit strict types declarations for for subsequent execution.
The strict types pass remembers the last strict types declaration:
declare(strict_types=1);
... which it then applies implicitly to all future evaluated code, until it is replaced by a new declaration.
Table of Contents
- EXCEPTION_MESSAGE = 'strict_types declaration must have 0 or 1 as its value'
- $atLeastPhp7 : mixed
- $strictTypes : mixed
- __construct() : mixed
- afterTraverse() : null|array<string|int, Node>
- Called once after traversal.
- beforeTraverse() : mixed
- If this is a standalone strict types declaration, remember it for later.
- enterNode() : null|int|Node
- Called when entering a node.
- leaveNode() : null|int|Node|array<string|int, Node>
- Called when leaving a node.
Constants
EXCEPTION_MESSAGE
public
mixed
EXCEPTION_MESSAGE
= 'strict_types declaration must have 0 or 1 as its value'
Properties
$atLeastPhp7
private
mixed
$atLeastPhp7
$strictTypes
private
mixed
$strictTypes
= false
Methods
__construct()
public
__construct() : mixed
Return values
mixed —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()
If this is a standalone strict types declaration, remember it for later.
public
beforeTraverse(array<string|int, mixed> $nodes) : mixed
Otherwise, apply remembered strict types declaration to to the code until a new declaration is encountered.
Parameters
- $nodes : array<string|int, mixed>
Tags
Return values
mixed —enterNode()
Called when entering a node.
public
enterNode(Node $node) : null|int|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
- $node : Node
-
Node
Return values
null|int|Node —Replacement node (or special return value)
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)