function Parser::parseArrowFunction
Parses an arrow function
Return value
Node\ArrowFunctionExpression|null
1 call to Parser::parseArrowFunction()
- Parser::parseAssignmentExpression in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an assignment expression
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 2776
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseArrowFunction() {
$state = $this->scanner
->getState();
$async = false;
if ($this->features->asyncAwait && ($async = $this->checkAsyncFunctionStart(false))) {
$this->scanner
->consumeToken();
}
if (($params = $this->parseArrowParameters()) !== null) {
if ($this->scanner
->noLineTerminators() && $this->scanner
->consume("=>")) {
if ($body = $this->parseConciseBody((bool) $async)) {
if (is_array($params)) {
$pos = $params[1];
$params = $params[0];
}
else {
$pos = $params;
$params = array(
$params,
);
}
if ($async) {
$pos = $async;
}
$node = $this->createNode("ArrowFunctionExpression", $pos);
$node->setParams($params);
$node->setBody($body[0]);
$node->setExpression($body[1]);
$node->setAsync((bool) $async);
return $this->completeNode($node);
}
$this->error();
}
}
$this->scanner
->setState($state);
return null;
}