Guides

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

Properties

$parser  : Parser
$traverser  : NodeTraverserInterface

Methods

__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

$traverser read-only

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

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 = 1 ]) : static
Parameters
$kind : int = 1

One of ParserFactory::PREFER_PHP7, ParserFactory::PREFER_PHP5, ParserFactory::ONLY_PHP7 or ParserFactory::ONLY_PHP5

Return values
static

        
On this page

Search results