File tree 4 files changed +83
-5
lines changed
4 files changed +83
-5
lines changed Original file line number Diff line number Diff line change @@ -2066,10 +2066,19 @@ private function parseSimpleVariableFn() {
2066
2066
$ variable ->dollar = $ this ->eat1 (TokenKind::DollarToken);
2067
2067
$ token = $ this ->getCurrentToken ();
2068
2068
2069
- $ variable ->name =
2070
- $ token ->kind === TokenKind::OpenBraceToken ?
2071
- $ this ->parseBracedExpression ($ variable ) :
2072
- $ this ->parseSimpleVariable ($ variable );
2069
+ switch ($ token ->kind ) {
2070
+ case TokenKind::OpenBraceToken:
2071
+ $ variable ->name = $ this ->parseBracedExpression ($ variable );
2072
+ break ;
2073
+ case TokenKind::VariableName:
2074
+ case TokenKind::StringVarname:
2075
+ case TokenKind::DollarToken:
2076
+ $ variable ->name = $ this ->parseSimpleVariable ($ variable );
2077
+ break ;
2078
+ default :
2079
+ $ variable ->name = new MissingToken (TokenKind::VariableName, $ token ->fullStart );
2080
+ break ;
2081
+ }
2073
2082
} elseif ($ token ->kind === TokenKind::VariableName || $ token ->kind === TokenKind::StringVarname) {
2074
2083
// TODO consider splitting into dollar and name.
2075
2084
// StringVarname is the variable name without $, used in a template string e.g. `"${foo}"`
@@ -2089,7 +2098,6 @@ private function parseYieldExpression($parentNode) {
2089
2098
TokenKind::YieldFromKeyword,
2090
2099
TokenKind::YieldKeyword
2091
2100
);
2092
-
2093
2101
$ yieldExpression ->arrayElement = $ this ->parseArrayElement ($ yieldExpression );
2094
2102
return $ yieldExpression ;
2095
2103
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ $ x = $ ;
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "kind": 0,
4
+ "message": "'VariableName' expected.",
5
+ "start": 13,
6
+ "length": 0
7
+ }
8
+ ]
Original file line number Diff line number Diff line change
1
+ {
2
+ "SourceFileNode": {
3
+ "statementList": [
4
+ {
5
+ "InlineHtml": {
6
+ "scriptSectionEndTag": null,
7
+ "text": null,
8
+ "scriptSectionStartTag": {
9
+ "kind": "ScriptSectionStartTag",
10
+ "textLength": 6
11
+ }
12
+ }
13
+ },
14
+ {
15
+ "ExpressionStatement": {
16
+ "expression": {
17
+ "AssignmentExpression": {
18
+ "leftOperand": {
19
+ "Variable": {
20
+ "dollar": null,
21
+ "name": {
22
+ "kind": "VariableName",
23
+ "textLength": 2
24
+ }
25
+ }
26
+ },
27
+ "operator": {
28
+ "kind": "EqualsToken",
29
+ "textLength": 1
30
+ },
31
+ "byRef": null,
32
+ "rightOperand": {
33
+ "Variable": {
34
+ "dollar": {
35
+ "kind": "DollarToken",
36
+ "textLength": 1
37
+ },
38
+ "name": {
39
+ "error": "MissingToken",
40
+ "kind": "VariableName",
41
+ "textLength": 0
42
+ }
43
+ }
44
+ }
45
+ }
46
+ },
47
+ "semicolon": {
48
+ "kind": "SemicolonToken",
49
+ "textLength": 1
50
+ }
51
+ }
52
+ }
53
+ ],
54
+ "endOfFileToken": {
55
+ "kind": "EndOfFileToken",
56
+ "textLength": 0
57
+ }
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments