@@ -1167,17 +1167,17 @@ private function lexUnquotedString(int &$cursor): string
1167
1167
return substr ($ this ->currentLine , $ offset , $ cursor - $ offset );
1168
1168
}
1169
1169
1170
- private function lexInlineMapping (int &$ cursor = 0 ): string
1170
+ private function lexInlineMapping (int &$ cursor = 0 , bool $ consumeUntilEol = true ): string
1171
1171
{
1172
- return $ this ->lexInlineStructure ($ cursor , '} ' );
1172
+ return $ this ->lexInlineStructure ($ cursor , '} ' , $ consumeUntilEol );
1173
1173
}
1174
1174
1175
- private function lexInlineSequence (int &$ cursor = 0 ): string
1175
+ private function lexInlineSequence (int &$ cursor = 0 , bool $ consumeUntilEol = true ): string
1176
1176
{
1177
- return $ this ->lexInlineStructure ($ cursor , '] ' );
1177
+ return $ this ->lexInlineStructure ($ cursor , '] ' , $ consumeUntilEol );
1178
1178
}
1179
1179
1180
- private function lexInlineStructure (int &$ cursor , string $ closingTag ): string
1180
+ private function lexInlineStructure (int &$ cursor , string $ closingTag, bool $ consumeUntilEol = true ): string
1181
1181
{
1182
1182
$ value = $ this ->currentLine [$ cursor ];
1183
1183
++$ cursor ;
@@ -1197,15 +1197,19 @@ private function lexInlineStructure(int &$cursor, string $closingTag): string
1197
1197
++$ cursor ;
1198
1198
break ;
1199
1199
case '{ ' :
1200
- $ value .= $ this ->lexInlineMapping ($ cursor );
1200
+ $ value .= $ this ->lexInlineMapping ($ cursor, false );
1201
1201
break ;
1202
1202
case '[ ' :
1203
- $ value .= $ this ->lexInlineSequence ($ cursor );
1203
+ $ value .= $ this ->lexInlineSequence ($ cursor, false );
1204
1204
break ;
1205
1205
case $ closingTag :
1206
1206
$ value .= $ this ->currentLine [$ cursor ];
1207
1207
++$ cursor ;
1208
1208
1209
+ if ($ consumeUntilEol && isset ($ this ->currentLine [$ cursor ]) && (strspn ($ this ->currentLine , ' ' , $ cursor ) + $ cursor ) < strlen ($ this ->currentLine )) {
1210
+ throw new ParseException (sprintf ('Unexpected token "%s". ' , trim (substr ($ this ->currentLine , $ cursor ))));
1211
+ }
1212
+
1209
1213
return $ value ;
1210
1214
case '# ' :
1211
1215
break 2 ;
0 commit comments