Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions src/SqlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

final class SqlParser extends AbstractSqlParser
{
/** @var string Identifier characters, equivalent to `[$\w]` in regular expressions */
private const IDENTIFIER_CHARS = '$' . self::WORD_CHARS;

public function getNextPlaceholder(?int &$position = null): ?string
{
$result = null;
Expand Down Expand Up @@ -67,21 +70,11 @@ private function skipQuotedWithDollar(): void
}

/**
* Skips an identifier. Equals to `[$\w]+` in regular expressions.
* Skips an identifier. Equivalent to `[$\w]*` in regular expressions.
*/
private function skipIdentifier(): void
{
$continue = true;

while ($continue && $this->position < $this->length) {
match ($this->sql[$this->position]) {
'$', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z' => ++$this->position,
default => $continue = false,
};
}
$length = strspn($this->sql, self::IDENTIFIER_CHARS, $this->position);
Comment thread
Tigrov marked this conversation as resolved.
Outdated
$this->position += $length;
}
}
Loading