|
8 | 8 |
|
9 | 9 | final class SqlParser extends AbstractSqlParser |
10 | 10 | { |
| 11 | + /** @var string Identifier characters, equivalent to `[$\w]` in regular expressions */ |
| 12 | + private const IDENTIFIER_CHARS = '$' . self::WORD_CHARS; |
| 13 | + |
11 | 14 | public function getNextPlaceholder(?int &$position = null): ?string |
12 | 15 | { |
13 | 16 | $result = null; |
@@ -67,21 +70,11 @@ private function skipQuotedWithDollar(): void |
67 | 70 | } |
68 | 71 |
|
69 | 72 | /** |
70 | | - * Skips an identifier. Equals to `[$\w]+` in regular expressions. |
| 73 | + * Skips an identifier. Equivalent to `[$\w]*` in regular expressions. |
71 | 74 | */ |
72 | 75 | private function skipIdentifier(): void |
73 | 76 | { |
74 | | - $continue = true; |
75 | | - |
76 | | - while ($continue && $this->position < $this->length) { |
77 | | - match ($this->sql[$this->position]) { |
78 | | - '$', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
79 | | - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', |
80 | | - 'v', 'w', 'x', 'y', 'z', |
81 | | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', |
82 | | - 'V', 'W', 'X', 'Y', 'Z' => ++$this->position, |
83 | | - default => $continue = false, |
84 | | - }; |
85 | | - } |
| 77 | + $length = strspn($this->sql, self::IDENTIFIER_CHARS, $this->position); |
| 78 | + $this->position += $length; |
86 | 79 | } |
87 | 80 | } |
0 commit comments