Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Node/AnonymousFunctionUseClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Microsoft\PhpParser\Node;

use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\UseVariableNameList;
use Microsoft\PhpParser\Token;
Expand All @@ -17,7 +18,7 @@ class AnonymousFunctionUseClause extends Node {
/** @var Token */
public $openParen;

/** @var UseVariableNameList */
/** @var UseVariableNameList|MissingToken */
public $useVariableNameList;

/** @var Token */
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3566,7 +3566,7 @@ function ($parentNode) {
return $useVariableName;
},
$anonymousFunctionUseClause
);
) ?: (new MissingToken(TokenKind::VariableName, $this->token->fullStart));
$anonymousFunctionUseClause->closeParen = $this->eat1(TokenKind::CloseParenToken);

return $anonymousFunctionUseClause;
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/parser/anonymousFunctionCreationExpression11.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
function () use() {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"kind": 0,
"message": "'VariableName' expected.",
"start": 22,
"length": 0
}
]
86 changes: 86 additions & 0 deletions tests/cases/parser/anonymousFunctionCreationExpression11.php.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"SourceFileNode": {
"statementList": [
{
"InlineHtml": {
"scriptSectionEndTag": null,
"text": null,
"scriptSectionStartTag": {
"kind": "ScriptSectionStartTag",
"textLength": 6
}
}
},
{
"ExpressionStatement": {
"expression": {
"AnonymousFunctionCreationExpression": {
"staticModifier": null,
"functionKeyword": {
"kind": "FunctionKeyword",
"textLength": 8
},
"byRefToken": null,
"name": null,
"openParen": {
"kind": "OpenParenToken",
"textLength": 1
},
"parameters": null,
"closeParen": {
"kind": "CloseParenToken",
"textLength": 1
},
"anonymousFunctionUseClause": {
"AnonymousFunctionUseClause": {
"useKeyword": {
"kind": "UseKeyword",
"textLength": 3
},
"openParen": {
"kind": "OpenParenToken",
"textLength": 1
},
"useVariableNameList": {
"error": "MissingToken",
"kind": "VariableName",
"textLength": 0
},
"closeParen": {
"kind": "CloseParenToken",
"textLength": 1
}
}
},
"colonToken": null,
"questionToken": null,
"returnType": null,
"otherReturnTypes": null,
"compoundStatementOrSemicolon": {
"CompoundStatementNode": {
"openBrace": {
"kind": "OpenBraceToken",
"textLength": 1
},
"statements": [],
"closeBrace": {
"kind": "CloseBraceToken",
"textLength": 1
}
}
}
}
},
"semicolon": {
"kind": "SemicolonToken",
"textLength": 1
}
}
}
],
"endOfFileToken": {
"kind": "EndOfFileToken",
"textLength": 0
}
}
}