Skip to content

Commit d7b87fd

Browse files
committed
Adjusted code
1 parent 94561f5 commit d7b87fd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Propel/Generator/Util/SqlParser.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,28 @@ public function getNextStatement(): string
239239
$lowercaseString = ''; // helper variable for performance sake
240240
while ($this->pos <= $this->len) {
241241
$char = $this->sql[$this->pos] ?? '';
242+
243+
$newLine = !isset($this->sql[$this->pos - 1]) || $this->sql[$this->pos - 1] === PHP_EOL;
244+
242245
// Skip comments
243-
if ($isCommentLine === true && $char !== PHP_EOL) {
246+
if ($isCommentLine === true) {
244247
$this->pos++;
248+
if ($char === PHP_EOL) {
249+
$isCommentLine = false; // end of comments line
250+
}
245251

246252
continue;
247253
}
248254
// check flags for strings or escaper
249255
switch ($char) {
250256
case '#':
251257
// detect comment line
252-
if ($this->sql[$this->pos--] === PHP_EOL) {
258+
if ($newLine === true && $isCommentLine === false) {
259+
$this->pos++;
253260
$isCommentLine = true;
254261

255262
continue 2;
256263
}
257-
case "\n":
258-
if ($isCommentLine === true) {
259-
$isCommentLine = false;
260-
}
261264

262265
break;
263266
case '\\':

0 commit comments

Comments
 (0)