Skip to content

Commit ba4615a

Browse files
committed
Fix checking and extending token list when parsing compound statements
1 parent 3c42371 commit ba4615a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sources/Parser/TokenList.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
use function is_scalar;
5656
use function ltrim;
5757
use function mb_strlen;
58+
use function min;
5859
use function preg_match;
5960
use function rtrim;
6061
use function strlen;
@@ -303,7 +304,7 @@ public function isFinished(): bool
303304
}
304305

305306
// do not reset trailing delimiter on next run
306-
$this->position = $n + 1; // @phpstan-ignore-line $n is always defined
307+
$this->position = min($n + 1, count($this->tokens)); // @phpstan-ignore-line $n is always defined
307308

308309
return true;
309310
}

0 commit comments

Comments
 (0)