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 1a726f5 commit 94561f5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Propel/Generator/Util/SqlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,21 @@ public function getNextStatement(): string
$lowercaseString = ''; // helper variable for performance sake
while ($this->pos <= $this->len) {
$char = $this->sql[$this->pos] ?? '';
if ($isCommentLine === true && $char !== "\n") {
// Skip comments
if ($isCommentLine === true && $char !== PHP_EOL) {
$this->pos++;

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

continue 2;
continue 2;
}
case "\n":
if ($isCommentLine === true) {
$isCommentLine = false;
Expand Down Expand Up @@ -313,7 +317,7 @@ public function getNextStatement(): string
$this->pos += $i; // increase position
$parsedTrimmedString = trim($parsedString);

return $parsedTrimmedString ? $parsedTrimmedString : $parsedString; // empty line
return $parsedTrimmedString ?: $parsedString; // to check empty line to avoid stop parsing
}
// avoid using strtolower on the whole parsed string every time new character is added
// there is also no point in adding characters which are in the string
Expand Down

0 comments on commit 94561f5

Please sign in to comment.