NodesFactory
in package
Factory to create a array of nodes from a provided file.
This factory will use PhpParser and NodeTraverser to do the real processing.
Table of Contents
- $parser : Parser
- Parser used to parse the code to nodes.
- $traverser : NodeTraverserInterface
- Containing a number of visitors to do some post processing steps on nodes.
- __construct() : mixed
- create() : array<string|int, Node>
- Will convert the provided code to nodes.
- createInstance() : static
- Creates a new instance of NodeFactory with default Parser ands Traverser.
Properties
$parser
Parser used to parse the code to nodes.
private
Parser
$parser
$traverser
Containing a number of visitors to do some post processing steps on nodes.
private
NodeTraverserInterface
$traverser
Methods
__construct()
public
final __construct(Parser $parser, NodeTraverserInterface $traverser) : mixed
Parameters
- $parser : Parser
-
used to parse the code
- $traverser : NodeTraverserInterface
-
used to do some post processing on the nodes
Return values
mixed —create()
Will convert the provided code to nodes.
public
create(string $code) : array<string|int, Node>
Parameters
- $code : string
-
code to process.
Return values
array<string|int, Node> —createInstance()
Creates a new instance of NodeFactory with default Parser ands Traverser.
public
static createInstance([int $kind = ParserFactory::PREFER_PHP7 ]) : static
Parameters
- $kind : int = ParserFactory::PREFER_PHP7
-
One of ParserFactory::PREFER_PHP7, ParserFactory::PREFER_PHP5, ParserFactory::ONLY_PHP7 or ParserFactory::ONLY_PHP5