Skip to content

Commit 648a246

Browse files
committed
Next try to fix HHVM build
1 parent 2e5ae28 commit 648a246

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/PhpParser/Lexer.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,24 @@ protected function handleErrors() {
159159
$line += substr_count($tokenValue, "\n");
160160
}
161161

162-
// Invalid characters at the end of the input
163162
if ($filePos !== \strlen($this->code)) {
164-
$this->handleInvalidCharacterRange($filePos, \strlen($this->code), $line);
163+
if (substr($this->code, $filePos, 2) === '/*') {
164+
// Unlike PHP, HHVM will drop unterminated comments entirely
165+
$comment = substr($this->code, $filePos);
166+
$this->errors[] = new Error('Unterminated comment', [
167+
'startLine' => $line,
168+
'endLine' => $line + substr_count($comment, "\n"),
169+
'startFilePos' => $filePos,
170+
'endFilePos' => $filePos + \strlen($comment),
171+
]);
172+
173+
// Emulate the PHP behavior
174+
$isDocComment = isset($comment[3]) && $comment[3] === '*';
175+
$this->tokens[] = [$isDocComment ? T_DOC_COMMENT : T_COMMENT, $comment, $line];
176+
} else {
177+
// Invalid characters at the end of the input
178+
$this->handleInvalidCharacterRange($filePos, \strlen($this->code), $line);
179+
}
165180
}
166181

167182
// Check for unterminated comment

0 commit comments

Comments
 (0)