Skip to content

Commit 83d8b91

Browse files
committed
Fix InlineHtml in control structures
Fixes microsoft#309
1 parent e8c3d19 commit 83d8b91

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private function parseList($parentNode, int $listParseContext) {
200200
$nodeArray[] = $element;
201201
if ($element instanceof Node) {
202202
$element->parent = $parentNode;
203-
if ($element instanceof InlineHtml && $element->echoStatement && $listParseContext === ParseContext::SourceElements) {
203+
if ($element instanceof InlineHtml && $element->echoStatement) {
204204
$nodeArray[] = $element->echoStatement;
205205
$element->echoStatement->parent = $parentNode;
206206
$element->echoStatement = null;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php if (true): ?><?= 'x' ?><?php endif; ?>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
"IfStatementNode": {
16+
"ifKeyword": {
17+
"kind": "IfKeyword",
18+
"textLength": 2
19+
},
20+
"openParen": {
21+
"kind": "OpenParenToken",
22+
"textLength": 1
23+
},
24+
"expression": {
25+
"ReservedWord": {
26+
"children": {
27+
"kind": "TrueReservedWord",
28+
"textLength": 4
29+
}
30+
}
31+
},
32+
"closeParen": {
33+
"kind": "CloseParenToken",
34+
"textLength": 1
35+
},
36+
"colon": {
37+
"kind": "ColonToken",
38+
"textLength": 1
39+
},
40+
"statements": [
41+
{
42+
"InlineHtml": {
43+
"scriptSectionEndTag": {
44+
"kind": "ScriptSectionEndTag",
45+
"textLength": 2
46+
},
47+
"text": null,
48+
"scriptSectionStartTag": {
49+
"kind": "ScriptSectionStartWithEchoTag",
50+
"textLength": 3
51+
}
52+
}
53+
},
54+
{
55+
"ExpressionStatement": {
56+
"expression": {
57+
"EchoExpression": {
58+
"echoKeyword": null,
59+
"expressions": {
60+
"ExpressionList": {
61+
"children": [
62+
{
63+
"StringLiteral": {
64+
"startQuote": null,
65+
"children": {
66+
"kind": "StringLiteralToken",
67+
"textLength": 3
68+
},
69+
"endQuote": null
70+
}
71+
}
72+
]
73+
}
74+
}
75+
}
76+
},
77+
"semicolon": null
78+
}
79+
},
80+
{
81+
"InlineHtml": {
82+
"scriptSectionEndTag": {
83+
"kind": "ScriptSectionEndTag",
84+
"textLength": 2
85+
},
86+
"text": null,
87+
"scriptSectionStartTag": {
88+
"kind": "ScriptSectionStartTag",
89+
"textLength": 6
90+
}
91+
}
92+
}
93+
],
94+
"elseIfClauses": [],
95+
"elseClause": null,
96+
"endifKeyword": {
97+
"kind": "EndIfKeyword",
98+
"textLength": 5
99+
},
100+
"semicolon": {
101+
"kind": "SemicolonToken",
102+
"textLength": 1
103+
}
104+
}
105+
},
106+
{
107+
"InlineHtml": {
108+
"scriptSectionEndTag": {
109+
"kind": "ScriptSectionEndTag",
110+
"textLength": 3
111+
},
112+
"text": null,
113+
"scriptSectionStartTag": null
114+
}
115+
}
116+
],
117+
"endOfFileToken": {
118+
"kind": "EndOfFileToken",
119+
"textLength": 0
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)