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
2 changes: 1 addition & 1 deletion src/Node/CatchClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CatchClause extends Node {
* TODO: In the next backwards incompatible release, replace qualifiedName with qualifiedNameList?
*/
public $otherQualifiedNameList;
/** @var Token */
/** @var Token|null */
public $variableName;
/** @var Token */
public $closeParen;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ private function parseCatchClause($parentNode) {
$qualifiedNameList = $this->parseQualifiedNameCatchList($catchClause)->children ?? [];
$catchClause->qualifiedName = $qualifiedNameList[0] ?? null; // TODO generate missing token or error if null
$catchClause->otherQualifiedNameList = array_slice($qualifiedNameList, 1); // TODO: Generate error if the name list has missing tokens
$catchClause->variableName = $this->eat1(TokenKind::VariableName);
$catchClause->variableName = $this->eatOptional1(TokenKind::VariableName);
$catchClause->closeParen = $this->eat1(TokenKind::CloseParenToken);
$catchClause->compoundStatement = $this->parseCompoundStatement($catchClause);

Expand Down
9 changes: 1 addition & 8 deletions tests/cases/parser/tryStatement10.php.diag
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
[
{
"kind": 0,
"message": "'VariableName' expected.",
"start": 22,
"length": 0
}
]
[]
6 changes: 1 addition & 5 deletions tests/cases/parser/tryStatement10.php.tree
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
},
"qualifiedName": null,
"otherQualifiedNameList": [],
"variableName": {
"error": "MissingToken",
"kind": "VariableName",
"textLength": 0
},
"variableName": null,
"closeParen": {
"kind": "CloseParenToken",
"textLength": 1
Expand Down
6 changes: 0 additions & 6 deletions tests/cases/parser/tryStatement13.php.diag
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
[
{
"kind": 0,
"message": "'VariableName' expected.",
"start": 169,
"length": 0
},
{
"kind": 0,
"message": "')' expected.",
Expand Down
6 changes: 1 addition & 5 deletions tests/cases/parser/tryStatement13.php.tree
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
},
"qualifiedName": null,
"otherQualifiedNameList": [],
"variableName": {
"error": "MissingToken",
"kind": "VariableName",
"textLength": 0
},
"variableName": null,
"closeParen": {
"error": "MissingToken",
"kind": "CloseParenToken",
Expand Down
6 changes: 0 additions & 6 deletions tests/cases/parser/tryStatement8.php.diag
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
"start": 21,
"length": 0
},
{
"kind": 0,
"message": "'VariableName' expected.",
"start": 21,
"length": 0
},
{
"kind": 0,
"message": "')' expected.",
Expand Down
6 changes: 1 addition & 5 deletions tests/cases/parser/tryStatement8.php.tree
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
},
"qualifiedName": null,
"otherQualifiedNameList": [],
"variableName": {
"error": "MissingToken",
"kind": "VariableName",
"textLength": 0
},
"variableName": null,
"closeParen": {
"error": "MissingToken",
"kind": "CloseParenToken",
Expand Down
9 changes: 1 addition & 8 deletions tests/cases/parser/tryStatement9.php.diag
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
[
{
"kind": 0,
"message": "'VariableName' expected.",
"start": 27,
"length": 0
}
]
[]
6 changes: 1 addition & 5 deletions tests/cases/parser/tryStatement9.php.tree
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@
}
},
"otherQualifiedNameList": [],
"variableName": {
"error": "MissingToken",
"kind": "VariableName",
"textLength": 0
},
"variableName": null,
"closeParen": {
"kind": "CloseParenToken",
"textLength": 1
Expand Down