function Parser::parseFormalParameterList
Parses a parameter list
Return value
Node\Node[]|null
1 call to Parser::parseFormalParameterList()
- Parser::parseArrowParameters in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses parameters in an arrow function. If the parameters are wrapped in round brackets, the returned value is an array where the first element is the parameters list and the second element is the open round brackets, this is needed to know the start…
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 1594
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseFormalParameterList() {
$hasComma = false;
$list = array();
while (($param = $this->parseBindingRestElement()) || ($param = $this->parseBindingElement())) {
$hasComma = false;
$list[] = $param;
if ($param->getType() === "RestElement") {
break;
}
elseif ($this->scanner
->consume(",")) {
$hasComma = true;
}
else {
break;
}
}
//Check if it ends with a comma, then check if the comma is a trailing comma,
//in that case throw an error if the trailing comma feature is not enabled
if ($hasComma && !$this->features->trailingCommaFunctionCallDeclaration) {
$token = $this->scanner
->getToken();
if ($token && $token->value === ")") {
$this->error();
}
}
return $list;
}