function ParserAbstract::createNode
Creates a node
@codeCoverageIgnore
Parameters
string $nodeType Node's type:
mixed $position Node's start position:
Return value
Node\Node
75 calls to ParserAbstract::createNode()
- Parser::expressionToPattern in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Converts an expression node to a pattern node
- Parser::parse in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses the source
- Parser::parseArgumentList in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an arguments list
- Parser::parseArrayBindingPattern in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an array binding pattern
- Parser::parseArrayLiteral in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an array literal
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ ParserAbstract.php, line 231
Class
- ParserAbstract
- Base class for parsers.
Namespace
Peast\SyntaxCode
protected function createNode($nodeType, $position) {
//Use the right class to get an instance of the node
$nodeClass = "\\Peast\\Syntax\\Node\\" . $nodeType;
$node = new $nodeClass();
//Add the node start position
if ($position instanceof Node\Node || $position instanceof Token) {
$position = $position->location->start;
}
elseif (is_array($position)) {
if (count($position)) {
$position = $position[0]->location->start;
}
else {
$position = $this->scanner
->getPosition();
}
}
$node->location->start = $position;
//Emit the NodeCreated event for the node
$this->eventsEmitter && $this->eventsEmitter
->fire("NodeCreated", array(
$node,
));
return $node;
}