Skip to content

Commit 833fb1e

Browse files
committed
Ref #291 - Fix #156 - Parser mistakes with comments
Signed-off-by: William Desportes <[email protected]>
1 parent 614b944 commit 833fb1e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Components/ExpressionArray.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,13 @@ public static function parse(Parser $parser, TokensList $list, array $options =
108108
--$list->idx;
109109

110110
if (is_array($ret)) {
111-
$expr = $ret[count($ret) - 1]->expr;
112-
if (preg_match('/\s*--\s.*$/', $expr, $matches)) {
113-
$found = $matches[0];
114-
$ret[count($ret) - 1]->expr = substr($expr, 0, strlen($expr) - strlen($found));
111+
$retIndex = count($ret) - 1;
112+
if (isset($ret[$retIndex])) {
113+
$expr = $ret[$retIndex]->expr;
114+
if (preg_match('/\s*--\s.*$/', $expr, $matches)) {
115+
$found = $matches[0];
116+
$ret[$retIndex]->expr = substr($expr, 0, strlen($expr) - strlen($found));
117+
}
115118
}
116119
}
117120

0 commit comments

Comments
 (0)