Skip to content

Commit

Permalink
Adjusted code
Browse files Browse the repository at this point in the history
  • Loading branch information
vol4onok committed Mar 29, 2024
1 parent 94561f5 commit d7b87fd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Propel/Generator/Util/SqlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,28 @@ public function getNextStatement(): string
$lowercaseString = ''; // helper variable for performance sake
while ($this->pos <= $this->len) {
$char = $this->sql[$this->pos] ?? '';

$newLine = !isset($this->sql[$this->pos - 1]) || $this->sql[$this->pos - 1] === PHP_EOL;

// Skip comments
if ($isCommentLine === true && $char !== PHP_EOL) {
if ($isCommentLine === true) {
$this->pos++;
if ($char === PHP_EOL) {
$isCommentLine = false; // end of comments line
}

continue;
}
// check flags for strings or escaper
switch ($char) {
case '#':
// detect comment line
if ($this->sql[$this->pos--] === PHP_EOL) {
if ($newLine === true && $isCommentLine === false) {
$this->pos++;
$isCommentLine = true;

continue 2;
}
case "\n":
if ($isCommentLine === true) {
$isCommentLine = false;
}

break;
case '\\':
Expand Down

0 comments on commit d7b87fd

Please sign in to comment.