function Parser::parseConciseBody
Parses the body of an arrow function. The returned value is an array where the first element is the function body and the second element is a boolean indicating if the body is wrapped in curly braces
Parameters
bool $async Async body mode:
Return value
array|null
1 call to Parser::parseConciseBody()
- Parser::parseArrowFunction in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses an arrow function
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 2742
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseConciseBody($async = false) {
if ($token = $this->scanner
->consume("{")) {
if (($body = $this->isolateContext($async ? array(
null,
"allowAwait" => true,
) : null, "parseFunctionBody")) && $this->scanner
->consume("}")) {
$body->location->start = $token->location->start;
$body->location->end = $this->scanner
->getPosition();
return array(
$body,
false,
);
}
$this->error();
}
elseif (!$this->scanner
->isBefore(array(
"{",
)) && ($body = $this->isolateContext($this->features->asyncAwait ? array(
"allowYield" => false,
"allowAwait" => $async,
) : array(
"allowYield" => false,
), "parseAssignmentExpression"))) {
return array(
$body,
true,
);
}
return null;
}