diff --git a/.github/workflows/orm2_tests.yml b/.github/workflows/orm2_tests.yml new file mode 100644 index 00000000..7756cd4d --- /dev/null +++ b/.github/workflows/orm2_tests.yml @@ -0,0 +1,35 @@ +name: ORM2 Tests + +on: ["push", "pull_request"] + +jobs: + build: + name: PHP ${{ matrix.php }} (${{ matrix.dependency }}) + + runs-on: ubuntu-latest + + strategy: + matrix: + dependency: + - lowest + - highest + php: + - 7.2 + - 7.3 + - 7.4 + - 8.0 + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - run: composer validate + + - uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependency }}" + + - run: composer run test diff --git a/.github/workflows/tests.yml b/.github/workflows/orm3_tests.yml similarity index 78% rename from .github/workflows/tests.yml rename to .github/workflows/orm3_tests.yml index cc7836c0..922a0101 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/orm3_tests.yml @@ -1,20 +1,16 @@ -name: Tests +name: ORM3 Tests on: ["push", "pull_request"] jobs: build: - name: PHP ${{ matrix.php }} + name: PHP ${{ matrix.php }} with ORM3 runs-on: ubuntu-latest strategy: matrix: php: - - 7.2 - - 7.3 - - 7.4 - - 8.0 - 8.1 - 8.2 - 8.3 @@ -29,5 +25,7 @@ jobs: - run: composer validate - uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" - run: composer run test diff --git a/composer.json b/composer.json index c3bb309e..d565a2ba 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,14 @@ ], "require": { "php": "^7.2 || ^8.0", - "doctrine/orm": "^2.15" + "doctrine/orm": "dev-feature/token-type-bridge" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/connorhu/doctrine2" + } + ], "require-dev": { "doctrine/annotations": "^1.14 || ^2", "doctrine/coding-standard": "^9.0.2 || ^12.0", diff --git a/src/Query/Mysql/Acos.php b/src/Query/Mysql/Acos.php index 46a5b795..68b9c8e3 100644 --- a/src/Query/Mysql/Acos.php +++ b/src/Query/Mysql/Acos.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Acos extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/AddTime.php b/src/Query/Mysql/AddTime.php index 37d9a037..08d84caa 100644 --- a/src/Query/Mysql/AddTime.php +++ b/src/Query/Mysql/AddTime.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Pascal Wacker */ class AddTime extends FunctionNode @@ -21,15 +21,15 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->time = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/AesDecrypt.php b/src/Query/Mysql/AesDecrypt.php index 2ae70124..3816b323 100644 --- a/src/Query/Mysql/AesDecrypt.php +++ b/src/Query/Mysql/AesDecrypt.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,12 +17,12 @@ class AesDecrypt extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->StringExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->key = $parser->StringExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/AesEncrypt.php b/src/Query/Mysql/AesEncrypt.php index 7bef1ca2..6f2c390c 100644 --- a/src/Query/Mysql/AesEncrypt.php +++ b/src/Query/Mysql/AesEncrypt.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,12 +17,12 @@ class AesEncrypt extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->StringExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->key = $parser->StringExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/AnyValue.php b/src/Query/Mysql/AnyValue.php index faffd93f..68283a31 100644 --- a/src/Query/Mysql/AnyValue.php +++ b/src/Query/Mysql/AnyValue.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -15,10 +15,10 @@ class AnyValue extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->value = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Ascii.php b/src/Query/Mysql/Ascii.php index 85ff4a84..d4d26d20 100644 --- a/src/Query/Mysql/Ascii.php +++ b/src/Query/Mysql/Ascii.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Ascii extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->string = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Asin.php b/src/Query/Mysql/Asin.php index f168ceb5..d60e5daf 100644 --- a/src/Query/Mysql/Asin.php +++ b/src/Query/Mysql/Asin.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Asin extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Atan.php b/src/Query/Mysql/Atan.php index 508f3d01..0f58b4d3 100644 --- a/src/Query/Mysql/Atan.php +++ b/src/Query/Mysql/Atan.php @@ -3,10 +3,10 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Atan extends FunctionNode { @@ -32,19 +32,19 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); try { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->optionalSecondExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } catch (QueryException $e) { - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } } diff --git a/src/Query/Mysql/Atan2.php b/src/Query/Mysql/Atan2.php index 50e7fa71..691d5f32 100644 --- a/src/Query/Mysql/Atan2.php +++ b/src/Query/Mysql/Atan2.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Atan2 extends FunctionNode { @@ -28,15 +28,15 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Binary.php b/src/Query/Mysql/Binary.php index 8d9db224..9941b623 100644 --- a/src/Query/Mysql/Binary.php +++ b/src/Query/Mysql/Binary.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Sarjono Mukti Aji */ class Binary extends FunctionNode @@ -14,12 +14,12 @@ class Binary extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/BitCount.php b/src/Query/Mysql/BitCount.php index 4e02d1e0..a2be1811 100644 --- a/src/Query/Mysql/BitCount.php +++ b/src/Query/Mysql/BitCount.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class BitCount extends FunctionNode { @@ -21,11 +21,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/BitXor.php b/src/Query/Mysql/BitXor.php index 3d6a5c1e..42326a50 100644 --- a/src/Query/Mysql/BitXor.php +++ b/src/Query/Mysql/BitXor.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "BIT_XOR" "(" ArithmeticPrimary "," ArithmeticPrimary ")" @@ -25,13 +25,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstArithmetic = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondArithmetic = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Cast.php b/src/Query/Mysql/Cast.php index a54d86df..ac5c8fd7 100644 --- a/src/Query/Mysql/Cast.php +++ b/src/Query/Mysql/Cast.php @@ -5,10 +5,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Literal; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function assert; use function implode; @@ -32,37 +32,37 @@ class Cast extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->fieldIdentifierExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_AS); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_AS); + $parser->match(TokenType::T_IDENTIFIER); $type = $parser->getLexer()->token->value; - if ($parser->getLexer()->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { - $parser->match(Lexer::T_OPEN_PARENTHESIS); + if ($parser->getLexer()->isNextToken(TokenType::T_OPEN_PARENTHESIS)) { + $parser->match(TokenType::T_OPEN_PARENTHESIS); $parameter = $parser->Literal(); assert($parameter instanceof Literal); $parameters = [$parameter->value]; - if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { + while ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $parameter = $parser->Literal(); $parameters[] = $parameter->value; } } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); $type .= '(' . implode(', ', $parameters) . ')'; } $this->castingTypeExpression = $type; - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Ceil.php b/src/Query/Mysql/Ceil.php index 9808dc3e..62aaa5ec 100644 --- a/src/Query/Mysql/Ceil.php +++ b/src/Query/Mysql/Ceil.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Ceil extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/CharLength.php b/src/Query/Mysql/CharLength.php index 58a755f4..671021b2 100644 --- a/src/Query/Mysql/CharLength.php +++ b/src/Query/Mysql/CharLength.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Metod */ class CharLength extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr1 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Collate.php b/src/Query/Mysql/Collate.php index 88d4f841..2755ff65 100644 --- a/src/Query/Mysql/Collate.php +++ b/src/Query/Mysql/Collate.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,19 +24,19 @@ class Collate extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_COMMA); + $parser->match(TokenType::T_IDENTIFIER); $lexer = $parser->getLexer(); $this->collation = $lexer->token->value; - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/ConcatWs.php b/src/Query/Mysql/ConcatWs.php index fb86097a..5707400f 100644 --- a/src/Query/Mysql/ConcatWs.php +++ b/src/Query/Mysql/ConcatWs.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; use function implode; @@ -21,8 +21,8 @@ class ConcatWs extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); // Add the concat separator to the values array. $this->values[] = $parser->ArithmeticExpression(); @@ -32,8 +32,8 @@ public function parse(Parser $parser): void $lexer = $parser->getLexer(); - while (count($this->values) < 3 || $lexer->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + while (count($this->values) < 3 || $lexer->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $peek = $lexer->glimpse(); $this->values[] = $peek->value === '(' @@ -41,21 +41,21 @@ public function parse(Parser $parser): void : $parser->ArithmeticExpression(); } - while ($lexer->lookahead->type === Lexer::T_IDENTIFIER) { + while ($lexer->lookahead->type === TokenType::T_IDENTIFIER) { switch (strtolower($lexer->lookahead->value)) { - case 'notempty': - $parser->match(Lexer::T_IDENTIFIER); + case 'notempty': + $parser->match(TokenType::T_IDENTIFIER); $this->notEmpty = true; break; default: // Identifier not recognized (causes exception). - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); break; } } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -66,14 +66,14 @@ public function getSql(SqlWalker $sqlWalker): string // Iterate over the captured expressions and add them to the query. for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $queryBuilder[] = ', '; + $queryBuilder[] = ', '; } // Dispatch the walker on the current node. $nodeSql = $sqlWalker->walkArithmeticPrimary($this->values[$i]); if ($this->notEmpty) { - // Exclude empty strings from the concatenation. + // Exclude empty strings from the concatenation. $nodeSql = sprintf("NULLIF(%s, '')", $nodeSql); } diff --git a/src/Query/Mysql/ConvertTz.php b/src/Query/Mysql/ConvertTz.php index e3e96105..34c74231 100644 --- a/src/Query/Mysql/ConvertTz.php +++ b/src/Query/Mysql/ConvertTz.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -30,16 +30,16 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateExpression = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->fromTz = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->toTz = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Cos.php b/src/Query/Mysql/Cos.php index ea12c9ca..b3f1e2f3 100644 --- a/src/Query/Mysql/Cos.php +++ b/src/Query/Mysql/Cos.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Cos extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Cot.php b/src/Query/Mysql/Cot.php index eaf2fa1c..84bdcab9 100644 --- a/src/Query/Mysql/Cot.php +++ b/src/Query/Mysql/Cot.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Cot extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/CountIf.php b/src/Query/Mysql/CountIf.php index 88475e36..aedbe2ce 100644 --- a/src/Query/Mysql/CountIf.php +++ b/src/Query/Mysql/CountIf.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; use function strtolower; @@ -21,29 +21,29 @@ class CountIf extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr1 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->expr2 = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); - while ($lexer->lookahead->type === Lexer::T_IDENTIFIER) { + while ($lexer->lookahead->type === TokenType::T_IDENTIFIER) { switch (strtolower($lexer->lookahead->value)) { - case 'inverse': - $parser->match(Lexer::T_IDENTIFIER); + case 'inverse': + $parser->match(TokenType::T_IDENTIFIER); $this->inverse = true; break; default: // Identifier not recognized (causes exception). - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); break; } } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Crc32.php b/src/Query/Mysql/Crc32.php index 23b42002..59c08f69 100644 --- a/src/Query/Mysql/Crc32.php +++ b/src/Query/Mysql/Crc32.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Igor Timoshenko */ class Crc32 extends FunctionNode @@ -21,11 +21,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Date.php b/src/Query/Mysql/Date.php index 4ad78ffb..90bbd418 100644 --- a/src/Query/Mysql/Date.php +++ b/src/Query/Mysql/Date.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Steve Lacey */ class Date extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/DateAdd.php b/src/Query/Mysql/DateAdd.php index bc5e2c7b..a17a3a8d 100644 --- a/src/Query/Mysql/DateAdd.php +++ b/src/Query/Mysql/DateAdd.php @@ -3,10 +3,10 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function in_array; use function is_string; @@ -45,18 +45,18 @@ class DateAdd extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstDateExpression = $parser->ArithmeticFactor(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->intervalExpression = $parser->ArithmeticFactor(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->unit = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/DateDiff.php b/src/Query/Mysql/DateDiff.php index b1796400..5442ed76 100644 --- a/src/Query/Mysql/DateDiff.php +++ b/src/Query/Mysql/DateDiff.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class DateDiff extends FunctionNode { @@ -15,12 +15,12 @@ class DateDiff extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/DateFormat.php b/src/Query/Mysql/DateFormat.php index 951f7d09..c6693747 100644 --- a/src/Query/Mysql/DateFormat.php +++ b/src/Query/Mysql/DateFormat.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Steve Lacey */ class DateFormat extends FunctionNode @@ -16,12 +16,12 @@ class DateFormat extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateExpression = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->patternExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Day.php b/src/Query/Mysql/Day.php index 237f4c46..2705df41 100644 --- a/src/Query/Mysql/Day.php +++ b/src/Query/Mysql/Day.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @author Rafael Kassner @@ -22,11 +22,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/DayName.php b/src/Query/Mysql/DayName.php index e7958a3d..37a0b57d 100644 --- a/src/Query/Mysql/DayName.php +++ b/src/Query/Mysql/DayName.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Steve Lacey */ class DayName extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/DayOfWeek.php b/src/Query/Mysql/DayOfWeek.php index 3e256deb..6162920d 100644 --- a/src/Query/Mysql/DayOfWeek.php +++ b/src/Query/Mysql/DayOfWeek.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class DayOfWeek extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/DayOfYear.php b/src/Query/Mysql/DayOfYear.php index 2b41c2cd..855bb843 100644 --- a/src/Query/Mysql/DayOfYear.php +++ b/src/Query/Mysql/DayOfYear.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class DayOfYear extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Degrees.php b/src/Query/Mysql/Degrees.php index 55ffa726..ee947a4f 100644 --- a/src/Query/Mysql/Degrees.php +++ b/src/Query/Mysql/Degrees.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Degrees extends FunctionNode { @@ -22,11 +22,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Div.php b/src/Query/Mysql/Div.php index 62bcaad6..f19a3c53 100644 --- a/src/Query/Mysql/Div.php +++ b/src/Query/Mysql/Div.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @link https://dev.mysql.com/doc/refman/en/arithmetic-functions.html#operator_div */ class Div extends FunctionNode @@ -25,15 +25,15 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dividend = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->divisor = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Exp.php b/src/Query/Mysql/Exp.php index 37b72a97..cb4b48ea 100644 --- a/src/Query/Mysql/Exp.php +++ b/src/Query/Mysql/Exp.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Exp extends FunctionNode { @@ -20,9 +20,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Extract.php b/src/Query/Mysql/Extract.php index ff6af97a..0d2419a3 100644 --- a/src/Query/Mysql/Extract.php +++ b/src/Query/Mysql/Extract.php @@ -2,10 +2,10 @@ namespace DoctrineExtensions\Query\Mysql; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function in_array; use function strtoupper; @@ -19,17 +19,17 @@ class Extract extends DateAdd public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $lexer = $parser->getLexer(); $this->unit = $lexer->token->value; - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Field.php b/src/Query/Mysql/Field.php index 849ca9ac..a5ccb246 100644 --- a/src/Query/Mysql/Field.php +++ b/src/Query/Mysql/Field.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -18,8 +18,8 @@ class Field extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); // Do the field. $this->field = $parser->ArithmeticPrimary(); @@ -31,13 +31,13 @@ public function parse(Parser $parser): void while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -50,7 +50,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Mysql/FindInSet.php b/src/Query/Mysql/FindInSet.php index 7cbc85e3..80115f20 100644 --- a/src/Query/Mysql/FindInSet.php +++ b/src/Query/Mysql/FindInSet.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class FindInSet extends FunctionNode { @@ -15,12 +15,12 @@ class FindInSet extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->needle = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->haystack = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Floor.php b/src/Query/Mysql/Floor.php index c2381d6c..f323a60b 100644 --- a/src/Query/Mysql/Floor.php +++ b/src/Query/Mysql/Floor.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Floor extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Format.php b/src/Query/Mysql/Format.php index f42f48ad..498db9c2 100644 --- a/src/Query/Mysql/Format.php +++ b/src/Query/Mysql/Format.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Wally Noveno */ class Format extends FunctionNode @@ -16,12 +16,12 @@ class Format extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->numberExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->patternExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/FromBase64.php b/src/Query/Mysql/FromBase64.php index 3912133c..6cdc709f 100644 --- a/src/Query/Mysql/FromBase64.php +++ b/src/Query/Mysql/FromBase64.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "FROM_BASE64" "(" "$fieldIdentifierExpression" ")" @@ -20,10 +20,10 @@ class FromBase64 extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/FromUnixtime.php b/src/Query/Mysql/FromUnixtime.php index be8fda18..30079330 100644 --- a/src/Query/Mysql/FromUnixtime.php +++ b/src/Query/Mysql/FromUnixtime.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Nima S */ class FromUnixtime extends FunctionNode @@ -31,17 +31,17 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstExpression = $parser->ArithmeticPrimary(); // parse second parameter if available - if ($lexer->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + if ($lexer->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $this->secondExpression = $parser->ArithmeticPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Greatest.php b/src/Query/Mysql/Greatest.php index 97c4e450..b8aa1e28 100644 --- a/src/Query/Mysql/Greatest.php +++ b/src/Query/Mysql/Greatest.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -21,20 +21,20 @@ class Greatest extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -47,7 +47,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Mysql/GroupConcat.php b/src/Query/Mysql/GroupConcat.php index 932d71aa..db080fc3 100644 --- a/src/Query/Mysql/GroupConcat.php +++ b/src/Query/Mysql/GroupConcat.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function implode; use function sprintf; @@ -23,44 +23,44 @@ class GroupConcat extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $lexer = $parser->getLexer(); - if ($lexer->isNextToken(Lexer::T_DISTINCT)) { - $parser->match(Lexer::T_DISTINCT); + if ($lexer->isNextToken(TokenType::T_DISTINCT)) { + $parser->match(TokenType::T_DISTINCT); $this->isDistinct = true; } // first Path Expression is mandatory $this->pathExp = []; - if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) { + if ($lexer->isNextToken(TokenType::T_IDENTIFIER)) { $this->pathExp[] = $parser->StringExpression(); } else { $this->pathExp[] = $parser->SingleValuedPathExpression(); } - while ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + while ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->pathExp[] = $parser->StringPrimary(); } - if ($lexer->isNextToken(Lexer::T_ORDER)) { + if ($lexer->isNextToken(TokenType::T_ORDER)) { $this->orderBy = $parser->OrderByClause(); } - if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) { + if ($lexer->isNextToken(TokenType::T_IDENTIFIER)) { if (strtolower($lexer->lookahead->value) !== 'separator') { - $parser->syntaxError('separator'); + $parser->syntaxError('separator'); } - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->separator = $parser->StringPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Hex.php b/src/Query/Mysql/Hex.php index 7537da57..d9a48263 100644 --- a/src/Query/Mysql/Hex.php +++ b/src/Query/Mysql/Hex.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Hex extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Hour.php b/src/Query/Mysql/Hour.php index e7f23595..5f2b9804 100644 --- a/src/Query/Mysql/Hour.php +++ b/src/Query/Mysql/Hour.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Dawid Nowak */ class Hour extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/IfElse.php b/src/Query/Mysql/IfElse.php index aa17e75b..a605a7dd 100644 --- a/src/Query/Mysql/IfElse.php +++ b/src/Query/Mysql/IfElse.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -16,27 +16,27 @@ class IfElse extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr[] = $parser->ConditionalExpression(); - $parser->match(Lexer::T_COMMA); - if ($parser->getLexer()->isNextToken(Lexer::T_NULL)) { - $parser->match(Lexer::T_NULL); + $parser->match(TokenType::T_COMMA); + if ($parser->getLexer()->isNextToken(TokenType::T_NULL)) { + $parser->match(TokenType::T_NULL); $this->expr[] = null; } else { $this->expr[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_COMMA); - if ($parser->getLexer()->isNextToken(Lexer::T_NULL)) { - $parser->match(Lexer::T_NULL); + $parser->match(TokenType::T_COMMA); + if ($parser->getLexer()->isNextToken(TokenType::T_NULL)) { + $parser->match(TokenType::T_NULL); $this->expr[] = null; } else { $this->expr[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/IfNull.php b/src/Query/Mysql/IfNull.php index a563222e..7fcebecf 100644 --- a/src/Query/Mysql/IfNull.php +++ b/src/Query/Mysql/IfNull.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Andrew Mackrodt */ class IfNull extends FunctionNode @@ -16,12 +16,12 @@ class IfNull extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr1 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->expr2 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Inet6Aton.php b/src/Query/Mysql/Inet6Aton.php index 6aec54d7..3f762a40 100644 --- a/src/Query/Mysql/Inet6Aton.php +++ b/src/Query/Mysql/Inet6Aton.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Inet6Aton extends FunctionNode { @@ -16,10 +16,10 @@ class Inet6Aton extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Inet6Ntoa.php b/src/Query/Mysql/Inet6Ntoa.php index 0780c085..f847baae 100644 --- a/src/Query/Mysql/Inet6Ntoa.php +++ b/src/Query/Mysql/Inet6Ntoa.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Inet6Ntoa extends FunctionNode { @@ -16,10 +16,10 @@ class Inet6Ntoa extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/InetAton.php b/src/Query/Mysql/InetAton.php index ce7a03ec..8038c1a8 100644 --- a/src/Query/Mysql/InetAton.php +++ b/src/Query/Mysql/InetAton.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class InetAton extends FunctionNode { @@ -16,10 +16,10 @@ class InetAton extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/InetNtoa.php b/src/Query/Mysql/InetNtoa.php index 4a09cb7f..c5bde44e 100644 --- a/src/Query/Mysql/InetNtoa.php +++ b/src/Query/Mysql/InetNtoa.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class InetNtoa extends FunctionNode { @@ -16,10 +16,10 @@ class InetNtoa extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Instr.php b/src/Query/Mysql/Instr.php index 809c253e..61596cc5 100644 --- a/src/Query/Mysql/Instr.php +++ b/src/Query/Mysql/Instr.php @@ -2,10 +2,10 @@ namespace DoctrineExtensions\Query\Mysql; -use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; -use Doctrine\ORM\Query\Parser; -use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\AST\Functions\FunctionNode; +use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,12 +17,12 @@ class Instr extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->originalString = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->subString = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/IsIpv4.php b/src/Query/Mysql/IsIpv4.php index e45f9b21..72e87fc3 100644 --- a/src/Query/Mysql/IsIpv4.php +++ b/src/Query/Mysql/IsIpv4.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class IsIpv4 extends FunctionNode { @@ -16,10 +16,10 @@ class IsIpv4 extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/IsIpv4Compat.php b/src/Query/Mysql/IsIpv4Compat.php index fa402157..544a2f14 100644 --- a/src/Query/Mysql/IsIpv4Compat.php +++ b/src/Query/Mysql/IsIpv4Compat.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class IsIpv4Compat extends FunctionNode { @@ -16,10 +16,10 @@ class IsIpv4Compat extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/IsIpv4Mapped.php b/src/Query/Mysql/IsIpv4Mapped.php index 4aec2c86..7aa6bc4c 100644 --- a/src/Query/Mysql/IsIpv4Mapped.php +++ b/src/Query/Mysql/IsIpv4Mapped.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class IsIpv4Mapped extends FunctionNode { @@ -16,10 +16,10 @@ class IsIpv4Mapped extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/IsIpv6.php b/src/Query/Mysql/IsIpv6.php index 835a8b3a..19b7f74e 100644 --- a/src/Query/Mysql/IsIpv6.php +++ b/src/Query/Mysql/IsIpv6.php @@ -4,10 +4,10 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class IsIpv6 extends FunctionNode { @@ -16,10 +16,10 @@ class IsIpv6 extends FunctionNode /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->valueExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/JsonContains.php b/src/Query/Mysql/JsonContains.php index 73e80293..7406d399 100644 --- a/src/Query/Mysql/JsonContains.php +++ b/src/Query/Mysql/JsonContains.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -19,22 +19,22 @@ class JsonContains extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->target = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->candidate = $parser->StringPrimary(); - if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->path = $parser->StringPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/JsonDepth.php b/src/Query/Mysql/JsonDepth.php index b70366ae..b995b624 100644 --- a/src/Query/Mysql/JsonDepth.php +++ b/src/Query/Mysql/JsonDepth.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -15,12 +15,12 @@ class JsonDepth extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->target = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/JsonLength.php b/src/Query/Mysql/JsonLength.php index c16ac82c..5e39883e 100644 --- a/src/Query/Mysql/JsonLength.php +++ b/src/Query/Mysql/JsonLength.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,18 +17,18 @@ class JsonLength extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->target = $parser->StringPrimary(); - if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->path = $parser->StringPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Lag.php b/src/Query/Mysql/Lag.php index d6bb169c..ced70dc1 100755 --- a/src/Query/Mysql/Lag.php +++ b/src/Query/Mysql/Lag.php @@ -6,9 +6,9 @@ use Doctrine\ORM\Query\AST\ArithmeticExpression; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Lag extends FunctionNode { @@ -38,19 +38,19 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->aggregateExpression = $parser->StringExpression(); - if (! $lexer->isNextToken(Lexer::T_CLOSE_PARENTHESIS)) { - $parser->match(Lexer::T_COMMA); + if (! $lexer->isNextToken(TokenType::T_CLOSE_PARENTHESIS)) { + $parser->match(TokenType::T_COMMA); $this->offset = $parser->ArithmeticPrimary(); } - if (! $lexer->isNextToken(Lexer::T_CLOSE_PARENTHESIS)) { - $parser->match(Lexer::T_COMMA); + if (! $lexer->isNextToken(TokenType::T_CLOSE_PARENTHESIS)) { + $parser->match(TokenType::T_COMMA); $this->defaultValue = $parser->SimpleArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/LastDay.php b/src/Query/Mysql/LastDay.php index c62c7a38..faa832e2 100644 --- a/src/Query/Mysql/LastDay.php +++ b/src/Query/Mysql/LastDay.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @author Rafael Kassner @@ -22,11 +22,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Lead.php b/src/Query/Mysql/Lead.php index 331706a7..9f43c736 100755 --- a/src/Query/Mysql/Lead.php +++ b/src/Query/Mysql/Lead.php @@ -6,9 +6,9 @@ use Doctrine\ORM\Query\AST\ArithmeticExpression; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Lead extends FunctionNode { @@ -38,19 +38,19 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->aggregateExpression = $parser->StringExpression(); - if (! $lexer->isNextToken(Lexer::T_CLOSE_PARENTHESIS)) { - $parser->match(Lexer::T_COMMA); + if (! $lexer->isNextToken(TokenType::T_CLOSE_PARENTHESIS)) { + $parser->match(TokenType::T_COMMA); $this->offset = $parser->ArithmeticPrimary(); } - if (! $lexer->isNextToken(Lexer::T_CLOSE_PARENTHESIS)) { - $parser->match(Lexer::T_COMMA); + if (! $lexer->isNextToken(TokenType::T_CLOSE_PARENTHESIS)) { + $parser->match(TokenType::T_COMMA); $this->defaultValue = $parser->SimpleArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Least.php b/src/Query/Mysql/Least.php index 4547a9b5..0dd8ff89 100644 --- a/src/Query/Mysql/Least.php +++ b/src/Query/Mysql/Least.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -18,20 +18,20 @@ class Least extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -44,7 +44,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Mysql/Log.php b/src/Query/Mysql/Log.php index 619c6b1f..e2cbf699 100644 --- a/src/Query/Mysql/Log.php +++ b/src/Query/Mysql/Log.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Log extends FunctionNode { @@ -20,9 +20,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Log10.php b/src/Query/Mysql/Log10.php index ad6f6b78..691f85e5 100644 --- a/src/Query/Mysql/Log10.php +++ b/src/Query/Mysql/Log10.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Log10 extends FunctionNode { @@ -20,9 +20,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Log2.php b/src/Query/Mysql/Log2.php index c1416aed..2515b45a 100644 --- a/src/Query/Mysql/Log2.php +++ b/src/Query/Mysql/Log2.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Log2 extends FunctionNode { @@ -20,9 +20,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Lpad.php b/src/Query/Mysql/Lpad.php index ffc47eb1..bb58823c 100644 --- a/src/Query/Mysql/Lpad.php +++ b/src/Query/Mysql/Lpad.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Giulia Santoiemma */ class Lpad extends FunctionNode @@ -18,14 +18,14 @@ class Lpad extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->string = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->length = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->padstring = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/MakeDate.php b/src/Query/Mysql/MakeDate.php index 5e82f460..7cb17a56 100644 --- a/src/Query/Mysql/MakeDate.php +++ b/src/Query/Mysql/MakeDate.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class MakeDate extends FunctionNode { @@ -15,12 +15,12 @@ class MakeDate extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->year = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->dayOfYear = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/MatchAgainst.php b/src/Query/Mysql/MatchAgainst.php index b1527d67..9c629560 100644 --- a/src/Query/Mysql/MatchAgainst.php +++ b/src/Query/Mysql/MatchAgainst.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\PathExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function implode; use function sprintf; @@ -29,8 +29,8 @@ class MatchAgainst extends FunctionNode public function parse(Parser $parser): void { // match - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); // first Path Expression is mandatory $this->pathExp = []; @@ -38,65 +38,65 @@ public function parse(Parser $parser): void // Subsequent Path Expressions are optional $lexer = $parser->getLexer(); - while ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + while ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->pathExp[] = $parser->StateFieldPathExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); // against if (strtolower($lexer->lookahead->value) !== 'against') { $parser->syntaxError('against'); } - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->against = $parser->StringPrimary(); if (strtolower($lexer->lookahead->value) === 'boolean') { - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->booleanMode = true; } elseif (strtolower($lexer->lookahead->value) === 'in') { - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); if (strtolower($lexer->lookahead->value) !== 'boolean') { - $parser->syntaxError('boolean'); + $parser->syntaxError('boolean'); } - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); if (strtolower($lexer->lookahead->value) !== 'mode') { - $parser->syntaxError('mode'); + $parser->syntaxError('mode'); } - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->booleanMode = true; } if (strtolower($lexer->lookahead->value) === 'expand') { - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->queryExpansion = true; } elseif (strtolower($lexer->lookahead->value) === 'with') { - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); if (strtolower($lexer->lookahead->value) !== 'query') { - $parser->syntaxError('query'); + $parser->syntaxError('query'); } - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); if (strtolower($lexer->lookahead->value) !== 'expansion') { - $parser->syntaxError('expansion'); + $parser->syntaxError('expansion'); } - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->queryExpansion = true; } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $walker): string diff --git a/src/Query/Mysql/Md5.php b/src/Query/Mysql/Md5.php index 3ebcd663..17299780 100644 --- a/src/Query/Mysql/Md5.php +++ b/src/Query/Mysql/Md5.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Andreas Gallien */ class Md5 extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Minute.php b/src/Query/Mysql/Minute.php index 28a3118f..ab174523 100644 --- a/src/Query/Mysql/Minute.php +++ b/src/Query/Mysql/Minute.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Martin Štekl */ class Minute extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Month.php b/src/Query/Mysql/Month.php index eac0d3a6..0d346cfd 100644 --- a/src/Query/Mysql/Month.php +++ b/src/Query/Mysql/Month.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @author Rafael Kassner @@ -22,11 +22,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/MonthName.php b/src/Query/Mysql/MonthName.php index d369b969..9668ad5f 100644 --- a/src/Query/Mysql/MonthName.php +++ b/src/Query/Mysql/MonthName.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Steve Lacey */ class MonthName extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Now.php b/src/Query/Mysql/Now.php index 0f235339..cc33ada4 100644 --- a/src/Query/Mysql/Now.php +++ b/src/Query/Mysql/Now.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Now extends FunctionNode { @@ -16,8 +16,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/NullIf.php b/src/Query/Mysql/NullIf.php index 330213c9..5cc60802 100644 --- a/src/Query/Mysql/NullIf.php +++ b/src/Query/Mysql/NullIf.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -18,12 +18,12 @@ class NullIf extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr1 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->expr2 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Over.php b/src/Query/Mysql/Over.php index 26a46ce0..8eb125e1 100755 --- a/src/Query/Mysql/Over.php +++ b/src/Query/Mysql/Over.php @@ -5,9 +5,9 @@ use Doctrine\ORM\Query\AST\ArithmeticExpression; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\OrderByClause; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; use function trim; @@ -31,14 +31,14 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->ArithmeticExpression(); - if (! $lexer->isNextToken(Lexer::T_CLOSE_PARENTHESIS)) { - $parser->match(Lexer::T_COMMA); + if (! $lexer->isNextToken(TokenType::T_CLOSE_PARENTHESIS)) { + $parser->match(TokenType::T_COMMA); $this->orderByClause = $parser->OrderByClause(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/PeriodDiff.php b/src/Query/Mysql/PeriodDiff.php index 715e4ba3..ac7c792f 100644 --- a/src/Query/Mysql/PeriodDiff.php +++ b/src/Query/Mysql/PeriodDiff.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class PeriodDiff extends FunctionNode { @@ -15,12 +15,12 @@ class PeriodDiff extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Pi.php b/src/Query/Mysql/Pi.php index 8b6f66a7..f86dfc82 100644 --- a/src/Query/Mysql/Pi.php +++ b/src/Query/Mysql/Pi.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Pi extends FunctionNode { @@ -18,8 +18,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Power.php b/src/Query/Mysql/Power.php index 076f66a6..48a7ea0d 100644 --- a/src/Query/Mysql/Power.php +++ b/src/Query/Mysql/Power.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Power extends FunctionNode { @@ -21,13 +21,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->power = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Quarter.php b/src/Query/Mysql/Quarter.php index 9a5b8875..23d4da15 100644 --- a/src/Query/Mysql/Quarter.php +++ b/src/Query/Mysql/Quarter.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Martin Štekl */ class Quarter extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Radians.php b/src/Query/Mysql/Radians.php index d6e3e738..e60105a3 100644 --- a/src/Query/Mysql/Radians.php +++ b/src/Query/Mysql/Radians.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Radians extends FunctionNode { @@ -22,11 +22,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Rand.php b/src/Query/Mysql/Rand.php index 7ed91acd..c28e3af0 100644 --- a/src/Query/Mysql/Rand.php +++ b/src/Query/Mysql/Rand.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Rand extends FunctionNode { @@ -25,13 +25,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); - if ($lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS) { + if ($lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS) { $this->expression = $parser->SimpleArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Regexp.php b/src/Query/Mysql/Regexp.php index 6fbe908c..9d29b584 100644 --- a/src/Query/Mysql/Regexp.php +++ b/src/Query/Mysql/Regexp.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Regexp extends FunctionNode { @@ -15,12 +15,12 @@ class Regexp extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->value = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->regexp = $parser->StringExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Replace.php b/src/Query/Mysql/Replace.php index 33321c9c..22721d45 100644 --- a/src/Query/Mysql/Replace.php +++ b/src/Query/Mysql/Replace.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Jarek Kostrz */ class Replace extends FunctionNode @@ -18,14 +18,14 @@ class Replace extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->subject = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->search = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->replace = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Round.php b/src/Query/Mysql/Round.php index 27c439ab..3fbef6ef 100644 --- a/src/Query/Mysql/Round.php +++ b/src/Query/Mysql/Round.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Round extends FunctionNode { @@ -16,17 +16,17 @@ class Round extends FunctionNode public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstExpression = $parser->SimpleArithmeticExpression(); // parse second parameter if available - if ($lexer->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + if ($lexer->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $this->secondExpression = $parser->ArithmeticPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Rpad.php b/src/Query/Mysql/Rpad.php index 4b94f097..56d36ccd 100644 --- a/src/Query/Mysql/Rpad.php +++ b/src/Query/Mysql/Rpad.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Giulia Santoiemma */ class Rpad extends FunctionNode @@ -18,14 +18,14 @@ class Rpad extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->string = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->length = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->padstring = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/SecToTime.php b/src/Query/Mysql/SecToTime.php index 7a4e4c8c..adcf073f 100644 --- a/src/Query/Mysql/SecToTime.php +++ b/src/Query/Mysql/SecToTime.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @link https://dev.mysql.com/doc/refman/en/date-and-time-functions.html#function_sec-to-time @@ -24,11 +24,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->time = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Second.php b/src/Query/Mysql/Second.php index 98b225a5..de641074 100644 --- a/src/Query/Mysql/Second.php +++ b/src/Query/Mysql/Second.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Martin Štekl */ class Second extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Sha1.php b/src/Query/Mysql/Sha1.php index 9948b755..4a9390bd 100644 --- a/src/Query/Mysql/Sha1.php +++ b/src/Query/Mysql/Sha1.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Andreas Gallien */ class Sha1 extends FunctionNode @@ -21,11 +21,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Sha2.php b/src/Query/Mysql/Sha2.php index a512f8bd..0f1e6ea7 100644 --- a/src/Query/Mysql/Sha2.php +++ b/src/Query/Mysql/Sha2.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Andreas Gallien */ class Sha2 extends FunctionNode @@ -25,13 +25,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Sin.php b/src/Query/Mysql/Sin.php index 0f813a4b..d2de1ce5 100644 --- a/src/Query/Mysql/Sin.php +++ b/src/Query/Mysql/Sin.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Sin extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Soundex.php b/src/Query/Mysql/Soundex.php index ec37adc9..dce20b7b 100644 --- a/src/Query/Mysql/Soundex.php +++ b/src/Query/Mysql/Soundex.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Steve Tauber */ class Soundex extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Std.php b/src/Query/Mysql/Std.php index a7825053..468fc0ec 100644 --- a/src/Query/Mysql/Std.php +++ b/src/Query/Mysql/Std.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -21,11 +21,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/StdDev.php b/src/Query/Mysql/StdDev.php index e5429df7..e238ea98 100644 --- a/src/Query/Mysql/StdDev.php +++ b/src/Query/Mysql/StdDev.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -21,11 +21,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/StrToDate.php b/src/Query/Mysql/StrToDate.php index dcbeaf00..0ad9d144 100644 --- a/src/Query/Mysql/StrToDate.php +++ b/src/Query/Mysql/StrToDate.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class StrToDate extends FunctionNode { @@ -15,12 +15,12 @@ class StrToDate extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateString = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->dateFormat = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/SubstringIndex.php b/src/Query/Mysql/SubstringIndex.php index d1d0fc33..f690763f 100644 --- a/src/Query/Mysql/SubstringIndex.php +++ b/src/Query/Mysql/SubstringIndex.php @@ -2,10 +2,10 @@ namespace DoctrineExtensions\Query\Mysql; -use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; -use Doctrine\ORM\Query\Parser; -use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\AST\Functions\FunctionNode; +use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -19,14 +19,14 @@ class SubstringIndex extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->string = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->delimiter = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->count = $parser->ArithmeticFactor(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Tan.php b/src/Query/Mysql/Tan.php index 17c9e30d..4d5a1472 100644 --- a/src/Query/Mysql/Tan.php +++ b/src/Query/Mysql/Tan.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Tan extends FunctionNode { @@ -20,11 +20,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Time.php b/src/Query/Mysql/Time.php index 76753db5..aef5c42d 100644 --- a/src/Query/Mysql/Time.php +++ b/src/Query/Mysql/Time.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @author Steve Lacey @@ -22,11 +22,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->time = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/TimeDiff.php b/src/Query/Mysql/TimeDiff.php index dda1973f..c8853087 100644 --- a/src/Query/Mysql/TimeDiff.php +++ b/src/Query/Mysql/TimeDiff.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,12 +17,12 @@ class TimeDiff extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/TimeToSec.php b/src/Query/Mysql/TimeToSec.php index 70af6ecf..a1fe1d00 100644 --- a/src/Query/Mysql/TimeToSec.php +++ b/src/Query/Mysql/TimeToSec.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @link https://dev.mysql.com/doc/refman/en/date-and-time-functions.html#function_time-to-sec @@ -24,11 +24,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->time = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/TimestampAdd.php b/src/Query/Mysql/TimestampAdd.php index 97062048..2121c3bb 100644 --- a/src/Query/Mysql/TimestampAdd.php +++ b/src/Query/Mysql/TimestampAdd.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -20,16 +20,16 @@ class TimestampAdd extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); $lexer = $parser->getLexer(); $this->unit = $lexer->token->value; - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->firstDatetimeExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondDatetimeExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/TimestampDiff.php b/src/Query/Mysql/TimestampDiff.php index 49697f69..9afc99fd 100644 --- a/src/Query/Mysql/TimestampDiff.php +++ b/src/Query/Mysql/TimestampDiff.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -20,16 +20,16 @@ class TimestampDiff extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); $lexer = $parser->getLexer(); $this->unit = $lexer->token->value; - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->firstDatetimeExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondDatetimeExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Truncate.php b/src/Query/Mysql/Truncate.php index 487f7a35..9187fe98 100644 --- a/src/Query/Mysql/Truncate.php +++ b/src/Query/Mysql/Truncate.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Evgeny Savich */ class Truncate extends FunctionNode @@ -16,12 +16,12 @@ class Truncate extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->numberExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->patternExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Unhex.php b/src/Query/Mysql/Unhex.php index 4fa000d2..ef511cd4 100644 --- a/src/Query/Mysql/Unhex.php +++ b/src/Query/Mysql/Unhex.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Unhex extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/UnixTimestamp.php b/src/Query/Mysql/UnixTimestamp.php index 16b23a84..6f5b81bb 100644 --- a/src/Query/Mysql/UnixTimestamp.php +++ b/src/Query/Mysql/UnixTimestamp.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -27,13 +27,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); - if (! $parser->getLexer()->isNextToken(Lexer::T_CLOSE_PARENTHESIS)) { + if (! $parser->getLexer()->isNextToken(TokenType::T_CLOSE_PARENTHESIS)) { $this->date = $parser->ArithmeticPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/UtcTimestamp.php b/src/Query/Mysql/UtcTimestamp.php index 096918eb..f0baba01 100644 --- a/src/Query/Mysql/UtcTimestamp.php +++ b/src/Query/Mysql/UtcTimestamp.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Marius Krämer */ class UtcTimestamp extends FunctionNode @@ -17,8 +17,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/UuidShort.php b/src/Query/Mysql/UuidShort.php index b999d70d..50011e5a 100644 --- a/src/Query/Mysql/UuidShort.php +++ b/src/Query/Mysql/UuidShort.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class UuidShort extends FunctionNode { @@ -18,8 +18,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Variance.php b/src/Query/Mysql/Variance.php index 59a12744..df6ba3ec 100644 --- a/src/Query/Mysql/Variance.php +++ b/src/Query/Mysql/Variance.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,12 +17,12 @@ class Variance extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->arithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Mysql/Week.php b/src/Query/Mysql/Week.php index e34eeb2a..1bc0c575 100644 --- a/src/Query/Mysql/Week.php +++ b/src/Query/Mysql/Week.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @author Rafael Kassner @@ -32,16 +32,16 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - if ($parser->getLexer()->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + if ($parser->getLexer()->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $this->mode = $parser->Literal(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/WeekDay.php b/src/Query/Mysql/WeekDay.php index e16e7dba..17da16e4 100644 --- a/src/Query/Mysql/WeekDay.php +++ b/src/Query/Mysql/WeekDay.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Pavlo Cherniavskyi */ class WeekDay extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/WeekOfYear.php b/src/Query/Mysql/WeekOfYear.php index 29915f2d..708dafee 100644 --- a/src/Query/Mysql/WeekOfYear.php +++ b/src/Query/Mysql/WeekOfYear.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class WeekOfYear extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/Year.php b/src/Query/Mysql/Year.php index 2464743d..29bcd586 100644 --- a/src/Query/Mysql/Year.php +++ b/src/Query/Mysql/Year.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Rafael Kassner */ class Year extends FunctionNode @@ -19,11 +19,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/YearMonth.php b/src/Query/Mysql/YearMonth.php index df51e844..9db21a4b 100644 --- a/src/Query/Mysql/YearMonth.php +++ b/src/Query/Mysql/YearMonth.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Mysql/YearWeek.php b/src/Query/Mysql/YearWeek.php index 04f2e136..d8c61e77 100644 --- a/src/Query/Mysql/YearWeek.php +++ b/src/Query/Mysql/YearWeek.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Mysql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Michael Kimpton */ class YearWeek extends FunctionNode @@ -28,16 +28,16 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - if ($parser->getLexer()->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + if ($parser->getLexer()->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $this->mode = $parser->Literal(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/MysqlWalker.php b/src/Query/MysqlWalker.php index e49d31b6..e7e00933 100644 --- a/src/Query/MysqlWalker.php +++ b/src/Query/MysqlWalker.php @@ -13,7 +13,7 @@ class MysqlWalker extends SqlWalker * * @inheritdoc */ - public function walkSelectClause($selectClause) + public function walkSelectClause($selectClause): string { $sql = parent::walkSelectClause($selectClause); diff --git a/src/Query/Oracle/Ceil.php b/src/Query/Oracle/Ceil.php index 5af8c3b2..a318007e 100755 --- a/src/Query/Oracle/Ceil.php +++ b/src/Query/Oracle/Ceil.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->number = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Day.php b/src/Query/Oracle/Day.php index 9fa2e6c2..02fcb2aa 100644 --- a/src/Query/Oracle/Day.php +++ b/src/Query/Oracle/Day.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Floor.php b/src/Query/Oracle/Floor.php index ddfe1ba5..3f33e7a5 100755 --- a/src/Query/Oracle/Floor.php +++ b/src/Query/Oracle/Floor.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->number = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Hour.php b/src/Query/Oracle/Hour.php index f308cd38..29976d38 100644 --- a/src/Query/Oracle/Hour.php +++ b/src/Query/Oracle/Hour.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Listagg.php b/src/Query/Oracle/Listagg.php index 562849fb..0ba51f56 100644 --- a/src/Query/Oracle/Listagg.php +++ b/src/Query/Oracle/Listagg.php @@ -5,9 +5,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\AST\OrderByClause; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; use function implode; @@ -32,51 +32,51 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->listaggField = $parser->StringPrimary(); - if ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->separator = $parser->StringExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); - if (! $lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead->value) !== 'within') { + if (! $lexer->isNextToken(TokenType::T_IDENTIFIER) || strtolower($lexer->lookahead->value) !== 'within') { $parser->syntaxError('WITHIN GROUP'); } - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_GROUP); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_GROUP); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->orderBy = $parser->OrderByClause(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); - if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) { + if ($lexer->isNextToken(TokenType::T_IDENTIFIER)) { if (strtolower($lexer->lookahead->value) !== 'over') { - $parser->syntaxError('OVER'); + $parser->syntaxError('OVER'); } - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); - if (! $lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead->value) !== 'partition') { - $parser->syntaxError('PARTITION BY'); + if (! $lexer->isNextToken(TokenType::T_IDENTIFIER) || strtolower($lexer->lookahead->value) !== 'partition') { + $parser->syntaxError('PARTITION BY'); } - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_BY); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_BY); $this->partitionBy[] = $parser->StringPrimary(); - while ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + while ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->partitionBy[] = $parser->StringPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } @@ -94,7 +94,7 @@ public function getSql(SqlWalker $sqlWalker): string if (count($this->partitionBy)) { $partitionBy = []; foreach ($this->partitionBy as $part) { - $partitionBy[] = $part->dispatch($sqlWalker); + $partitionBy[] = $part->dispatch($sqlWalker); } $result .= ' PARTITION BY (' . implode(',', $partitionBy) . ')'; diff --git a/src/Query/Oracle/Minute.php b/src/Query/Oracle/Minute.php index 4af5a515..a24cf168 100644 --- a/src/Query/Oracle/Minute.php +++ b/src/Query/Oracle/Minute.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Month.php b/src/Query/Oracle/Month.php index f0752111..966dcbfc 100644 --- a/src/Query/Oracle/Month.php +++ b/src/Query/Oracle/Month.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Nvl.php b/src/Query/Oracle/Nvl.php index 967d0c9b..d5394482 100644 --- a/src/Query/Oracle/Nvl.php +++ b/src/Query/Oracle/Nvl.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -27,11 +27,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr1 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->expr2 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Second.php b/src/Query/Oracle/Second.php index 49e629df..78108679 100644 --- a/src/Query/Oracle/Second.php +++ b/src/Query/Oracle/Second.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/ToChar.php b/src/Query/Oracle/ToChar.php index d9963f74..29c982b3 100755 --- a/src/Query/Oracle/ToChar.php +++ b/src/Query/Oracle/ToChar.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -40,17 +40,17 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->datetime = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->fmt = $parser->StringExpression(); - if ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->nls = $parser->StringExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/ToDate.php b/src/Query/Oracle/ToDate.php index f5782f4e..77b03ef2 100644 --- a/src/Query/Oracle/ToDate.php +++ b/src/Query/Oracle/ToDate.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -27,11 +27,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->fmt = $parser->StringExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Trunc.php b/src/Query/Oracle/Trunc.php index a32aa689..b143a2a9 100755 --- a/src/Query/Oracle/Trunc.php +++ b/src/Query/Oracle/Trunc.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -39,15 +39,15 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticExpression(); - if ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->fmt = $parser->StringExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Oracle/Year.php b/src/Query/Oracle/Year.php index 2a54076f..87d9b0a9 100644 --- a/src/Query/Oracle/Year.php +++ b/src/Query/Oracle/Year.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Oracle; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -24,9 +24,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/AtTimeZoneFunction.php b/src/Query/Postgresql/AtTimeZoneFunction.php index 409e484d..a6fe984d 100644 --- a/src/Query/Postgresql/AtTimeZoneFunction.php +++ b/src/Query/Postgresql/AtTimeZoneFunction.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -20,12 +20,12 @@ class AtTimeZoneFunction extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->timezoneExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/CountFilterFunction.php b/src/Query/Postgresql/CountFilterFunction.php index 3d24a58c..d65e07d9 100644 --- a/src/Query/Postgresql/CountFilterFunction.php +++ b/src/Query/Postgresql/CountFilterFunction.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -20,12 +20,12 @@ class CountFilterFunction extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->countExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->whereExpression = $parser->WhereClause(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/Date.php b/src/Query/Postgresql/Date.php index d7e128c5..9c032794 100644 --- a/src/Query/Postgresql/Date.php +++ b/src/Query/Postgresql/Date.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Date extends FunctionNode { @@ -18,11 +18,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/DateFormat.php b/src/Query/Postgresql/DateFormat.php index 59031420..e533e228 100644 --- a/src/Query/Postgresql/DateFormat.php +++ b/src/Query/Postgresql/DateFormat.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Silvio */ class DateFormat extends FunctionNode @@ -16,12 +16,12 @@ class DateFormat extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateExpression = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->patternExpression = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/DatePart.php b/src/Query/Postgresql/DatePart.php index f162aa6e..bf6d18cd 100644 --- a/src/Query/Postgresql/DatePart.php +++ b/src/Query/Postgresql/DatePart.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Geovani Roggeo */ class DatePart extends FunctionNode @@ -16,12 +16,12 @@ class DatePart extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateString = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->dateFormat = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/DateTrunc.php b/src/Query/Postgresql/DateTrunc.php index b2e6e1a5..8ea90b51 100644 --- a/src/Query/Postgresql/DateTrunc.php +++ b/src/Query/Postgresql/DateTrunc.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -17,12 +17,12 @@ class DateTrunc extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->fieldText = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->fieldTimestamp = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/Day.php b/src/Query/Postgresql/Day.php index d3339f40..6f83b79a 100644 --- a/src/Query/Postgresql/Day.php +++ b/src/Query/Postgresql/Day.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/ExtractFunction.php b/src/Query/Postgresql/ExtractFunction.php index 2cd0126a..f13da1bb 100644 --- a/src/Query/Postgresql/ExtractFunction.php +++ b/src/Query/Postgresql/ExtractFunction.php @@ -5,10 +5,10 @@ use Doctrine\ORM\Query\AST\ASTException; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\PathExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -33,16 +33,16 @@ public function getSql(SqlWalker $sqlWalker): string /** @throws QueryException */ public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); $this->field = $parser->getLexer()->token->value; - $parser->match(Lexer::T_FROM); + $parser->match(TokenType::T_FROM); $this->value = $parser->ScalarExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/Greatest.php b/src/Query/Postgresql/Greatest.php index f3d5950b..b60d0f57 100644 --- a/src/Query/Postgresql/Greatest.php +++ b/src/Query/Postgresql/Greatest.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -22,20 +22,20 @@ class Greatest extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -48,7 +48,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Postgresql/Hour.php b/src/Query/Postgresql/Hour.php index 9f3989a5..1e1c66c4 100644 --- a/src/Query/Postgresql/Hour.php +++ b/src/Query/Postgresql/Hour.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/Least.php b/src/Query/Postgresql/Least.php index 6190452e..75ec1419 100644 --- a/src/Query/Postgresql/Least.php +++ b/src/Query/Postgresql/Least.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -21,20 +21,20 @@ class Least extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -47,7 +47,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Postgresql/Minute.php b/src/Query/Postgresql/Minute.php index a1676c08..7a74b0ee 100644 --- a/src/Query/Postgresql/Minute.php +++ b/src/Query/Postgresql/Minute.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/Month.php b/src/Query/Postgresql/Month.php index 16492a5d..d0550203 100644 --- a/src/Query/Postgresql/Month.php +++ b/src/Query/Postgresql/Month.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/RegexpReplace.php b/src/Query/Postgresql/RegexpReplace.php index ea82e6e5..eb4f4d8b 100644 --- a/src/Query/Postgresql/RegexpReplace.php +++ b/src/Query/Postgresql/RegexpReplace.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * @link https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-TABLE @@ -27,15 +27,15 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->string = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->search = $parser->StringExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->replace = $parser->StringExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/Second.php b/src/Query/Postgresql/Second.php index 21790beb..d9fedfe6 100644 --- a/src/Query/Postgresql/Second.php +++ b/src/Query/Postgresql/Second.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Postgresql/StrToDate.php b/src/Query/Postgresql/StrToDate.php index 205c1a89..352c284d 100644 --- a/src/Query/Postgresql/StrToDate.php +++ b/src/Query/Postgresql/StrToDate.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class StrToDate extends FunctionNode { @@ -15,12 +15,12 @@ class StrToDate extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->dateString = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->dateFormat = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/StringAgg.php b/src/Query/Postgresql/StringAgg.php index 73d34d6d..49905ba3 100644 --- a/src/Query/Postgresql/StringAgg.php +++ b/src/Query/Postgresql/StringAgg.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\PathExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -26,25 +26,25 @@ class StringAgg extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $lexer = $parser->getLexer(); - if ($lexer->isNextToken(Lexer::T_DISTINCT)) { - $parser->match(Lexer::T_DISTINCT); + if ($lexer->isNextToken(TokenType::T_DISTINCT)) { + $parser->match(TokenType::T_DISTINCT); $this->isDistinct = true; } $this->expression = $parser->PathExpression(PathExpression::TYPE_STATE_FIELD); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->delimiter = $parser->StringPrimary(); - if ($lexer->isNextToken(Lexer::T_ORDER)) { + if ($lexer->isNextToken(TokenType::T_ORDER)) { $this->orderBy = $parser->OrderByClause(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Postgresql/Year.php b/src/Query/Postgresql/Year.php index 83a168d7..bed71d5b 100644 --- a/src/Query/Postgresql/Year.php +++ b/src/Query/Postgresql/Year.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Postgresql; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -23,9 +23,9 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/SortableNullsWalker.php b/src/Query/SortableNullsWalker.php index fa5f8c5f..317bbeb7 100644 --- a/src/Query/SortableNullsWalker.php +++ b/src/Query/SortableNullsWalker.php @@ -40,7 +40,7 @@ class SortableNullsWalker extends Query\SqlWalker /** * {@inheritDoc} */ - public function walkOrderByItem($orderByItem) + public function walkOrderByItem($orderByItem): string { $sql = parent::walkOrderByItem($orderByItem); $hint = $this->getQuery()->getHint('sortableNulls.fields'); @@ -53,12 +53,12 @@ public function walkOrderByItem($orderByItem) $expr instanceof Query\AST\PathExpression && $expr->type === Query\AST\PathExpression::TYPE_STATE_FIELD ) { - $fieldName = $expr->field; + $fieldName = $expr->field; $dqlAlias = $expr->identificationVariable; $search = $this->walkPathExpression($expr) . ' ' . $type; $index = $dqlAlias . '.' . $fieldName; if (isset($hint[$index])) { - $sql = str_replace($search, $search . ' ' . $hint[$index], $sql); + $sql = str_replace($search, $search . ' ' . $hint[$index], $sql); } } } diff --git a/src/Query/Sqlite/AbstractStrfTime.php b/src/Query/Sqlite/AbstractStrfTime.php index c8ce727d..57d87a0d 100644 --- a/src/Query/Sqlite/AbstractStrfTime.php +++ b/src/Query/Sqlite/AbstractStrfTime.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Tarjei Huse */ abstract class AbstractStrfTime extends FunctionNode @@ -23,12 +23,12 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } abstract protected function getFormat(): string; diff --git a/src/Query/Sqlite/ConcatWs.php b/src/Query/Sqlite/ConcatWs.php index 62b474ac..845b24e7 100644 --- a/src/Query/Sqlite/ConcatWs.php +++ b/src/Query/Sqlite/ConcatWs.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; use function implode; @@ -21,8 +21,8 @@ class ConcatWs extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); // Add the concat separator to the values array. $this->values[] = $parser->ArithmeticExpression(); @@ -32,8 +32,8 @@ public function parse(Parser $parser): void $lexer = $parser->getLexer(); - while (count($this->values) < 3 || $lexer->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + while (count($this->values) < 3 || $lexer->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $peek = $lexer->glimpse(); $this->values[] = $peek->value === '(' @@ -41,21 +41,21 @@ public function parse(Parser $parser): void : $parser->ArithmeticExpression(); } - while ($lexer->lookahead->type === Lexer::T_IDENTIFIER) { + while ($lexer->lookahead->type === TokenType::T_IDENTIFIER) { switch (strtolower($lexer->lookahead->value)) { - case 'notempty': - $parser->match(Lexer::T_IDENTIFIER); + case 'notempty': + $parser->match(TokenType::T_IDENTIFIER); $this->notEmpty = true; break; default: // Identifier not recognized (causes exception). - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); break; } } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -68,7 +68,7 @@ public function getSql(SqlWalker $sqlWalker): string // Iterate over the captured expressions and add them to the query. for ($i = 1; $i < count($this->values); $i++) { if ($i > 1) { - $queryBuilder[] = ' || \'' . $separator . '\' || '; + $queryBuilder[] = ' || \'' . $separator . '\' || '; } // Dispatch the walker on the current node. diff --git a/src/Query/Sqlite/DateFormat.php b/src/Query/Sqlite/DateFormat.php index b700c823..7edb7c88 100644 --- a/src/Query/Sqlite/DateFormat.php +++ b/src/Query/Sqlite/DateFormat.php @@ -4,9 +4,9 @@ use Doctrine\ORM\Query\AST\ArithmeticExpression; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function str_replace; @@ -33,12 +33,12 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->format = $this->convertFormat($parser->ArithmeticExpression()); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } /** diff --git a/src/Query/Sqlite/Greatest.php b/src/Query/Sqlite/Greatest.php index 7d820203..a0c3910c 100644 --- a/src/Query/Sqlite/Greatest.php +++ b/src/Query/Sqlite/Greatest.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -21,20 +21,20 @@ class Greatest extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -47,7 +47,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Sqlite/IfElse.php b/src/Query/Sqlite/IfElse.php index f57fe325..4e4705e2 100644 --- a/src/Query/Sqlite/IfElse.php +++ b/src/Query/Sqlite/IfElse.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -16,16 +16,16 @@ class IfElse extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr[] = $parser->ConditionalExpression(); for ($i = 0; $i < 2; $i++) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->expr[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Sqlite/IfNull.php b/src/Query/Sqlite/IfNull.php index 11cb6eb9..550f8f5c 100644 --- a/src/Query/Sqlite/IfNull.php +++ b/src/Query/Sqlite/IfNull.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author winkbrace */ class IfNull extends FunctionNode @@ -16,12 +16,12 @@ class IfNull extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->expr1 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->expr2 = $parser->ArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Sqlite/Least.php b/src/Query/Sqlite/Least.php index 0ce11c0e..73583cc5 100644 --- a/src/Query/Sqlite/Least.php +++ b/src/Query/Sqlite/Least.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function count; @@ -18,20 +18,20 @@ class Least extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while ( count($this->values) < 1 || - $lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS + $lexer->lookahead->type !== TokenType::T_CLOSE_PARENTHESIS ) { - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->values[] = $parser->ArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string @@ -44,7 +44,7 @@ public function getSql(SqlWalker $sqlWalker): string for ($i = 0; $i < count($this->values); $i++) { if ($i > 0) { - $query .= ', '; + $query .= ', '; } $query .= $this->values[$i]->dispatch($sqlWalker); diff --git a/src/Query/Sqlite/Random.php b/src/Query/Sqlite/Random.php index 4c9b3b60..2dbd4ea8 100644 --- a/src/Query/Sqlite/Random.php +++ b/src/Query/Sqlite/Random.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; class Random extends FunctionNode { @@ -16,8 +16,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Sqlite/Replace.php b/src/Query/Sqlite/Replace.php index cbbfd36d..f6189819 100644 --- a/src/Query/Sqlite/Replace.php +++ b/src/Query/Sqlite/Replace.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author winkbrace */ class Replace extends FunctionNode @@ -18,14 +18,14 @@ class Replace extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->subject = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->search = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->replace = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Sqlite/Round.php b/src/Query/Sqlite/Round.php index 658ff4fa..27c8b0a5 100644 --- a/src/Query/Sqlite/Round.php +++ b/src/Query/Sqlite/Round.php @@ -3,9 +3,9 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author winkbrace */ class Round extends FunctionNode @@ -17,17 +17,17 @@ class Round extends FunctionNode public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstExpression = $parser->SimpleArithmeticExpression(); // parse second parameter if available - if ($lexer->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + if ($lexer->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $this->secondExpression = $parser->ArithmeticPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/src/Query/Sqlite/StrfTime.php b/src/Query/Sqlite/StrfTime.php index 280bb32a..1a3a39b7 100644 --- a/src/Query/Sqlite/StrfTime.php +++ b/src/Query/Sqlite/StrfTime.php @@ -3,10 +3,10 @@ namespace DoctrineExtensions\Query\Sqlite; use Doctrine\ORM\Query\AST\Functions\FunctionNode; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** @author Tarjei Huse */ class StrfTime extends FunctionNode @@ -27,14 +27,14 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->formatter = $parser->Literal(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->date = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/src/Query/Sqlite/Week.php b/src/Query/Sqlite/Week.php index 5d48a2bb..a4f77de2 100644 --- a/src/Query/Sqlite/Week.php +++ b/src/Query/Sqlite/Week.php @@ -2,8 +2,8 @@ namespace DoctrineExtensions\Query\Sqlite; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\TokenType; /** @author Aleksandr Klimenkov */ class Week extends NumberFromStrfTime @@ -17,17 +17,17 @@ class Week extends NumberFromStrfTime public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date = $parser->ArithmeticPrimary(); - if ($parser->getLexer()->lookahead->type === Lexer::T_COMMA) { - $parser->match(Lexer::T_COMMA); + if ($parser->getLexer()->lookahead->type === TokenType::T_COMMA) { + $parser->match(TokenType::T_COMMA); $this->mode = $parser->Literal(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } protected function getFormat(): string diff --git a/src/Types/CarbonDateTimeType.php b/src/Types/CarbonDateTimeType.php index 03350b46..b2ae5455 100644 --- a/src/Types/CarbonDateTimeType.php +++ b/src/Types/CarbonDateTimeType.php @@ -3,10 +3,12 @@ namespace DoctrineExtensions\Types; use Carbon\Carbon; +use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\DateTimeType; +use Doctrine\DBAL\Types\Exception\InvalidType; class CarbonDateTimeType extends DateTimeType { @@ -25,7 +27,7 @@ public function getName() * * @return Carbon|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonDateTimeTzType.php b/src/Types/CarbonDateTimeTzType.php index ff8f183b..1aafbd7a 100644 --- a/src/Types/CarbonDateTimeTzType.php +++ b/src/Types/CarbonDateTimeTzType.php @@ -3,10 +3,12 @@ namespace DoctrineExtensions\Types; use Carbon\Carbon; +use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\DateTimeTzType; +use Doctrine\DBAL\Types\Exception\InvalidType; class CarbonDateTimeTzType extends DateTimeTzType { @@ -25,7 +27,7 @@ public function getName() * * @return Carbon|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonDateType.php b/src/Types/CarbonDateType.php index 0e398cc4..f846ae8a 100644 --- a/src/Types/CarbonDateType.php +++ b/src/Types/CarbonDateType.php @@ -3,10 +3,12 @@ namespace DoctrineExtensions\Types; use Carbon\Carbon; +use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\DateType; +use Doctrine\DBAL\Types\Exception\InvalidType; class CarbonDateType extends DateType { @@ -25,7 +27,7 @@ public function getName() * * @return Carbon|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonImmutableDateTimeType.php b/src/Types/CarbonImmutableDateTimeType.php index d03dcadf..3fa76e21 100644 --- a/src/Types/CarbonImmutableDateTimeType.php +++ b/src/Types/CarbonImmutableDateTimeType.php @@ -2,11 +2,13 @@ namespace DoctrineExtensions\Types; +use Carbon\Carbon; use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\DateTimeType; +use Doctrine\DBAL\Types\Exception\InvalidType; class CarbonImmutableDateTimeType extends DateTimeType { @@ -25,7 +27,7 @@ public function getName() * * @return CarbonImmutable|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonImmutableDateTimeTzType.php b/src/Types/CarbonImmutableDateTimeTzType.php index f73747cf..3d849278 100644 --- a/src/Types/CarbonImmutableDateTimeTzType.php +++ b/src/Types/CarbonImmutableDateTimeTzType.php @@ -2,11 +2,13 @@ namespace DoctrineExtensions\Types; +use Carbon\Carbon; use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\DateTimeTzType; +use Doctrine\DBAL\Types\Exception\InvalidType; class CarbonImmutableDateTimeTzType extends DateTimeTzType { @@ -25,7 +27,7 @@ public function getName() * * @return CarbonImmutable|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonImmutableDateType.php b/src/Types/CarbonImmutableDateType.php index 72cc6e11..760a3177 100644 --- a/src/Types/CarbonImmutableDateType.php +++ b/src/Types/CarbonImmutableDateType.php @@ -2,11 +2,13 @@ namespace DoctrineExtensions\Types; +use Carbon\Carbon; use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\DateType; +use Doctrine\DBAL\Types\Exception\InvalidType; class CarbonImmutableDateType extends DateType { @@ -25,7 +27,7 @@ public function getName() * * @return CarbonImmutable|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonImmutableTimeType.php b/src/Types/CarbonImmutableTimeType.php index b1402fc8..42d10cf1 100644 --- a/src/Types/CarbonImmutableTimeType.php +++ b/src/Types/CarbonImmutableTimeType.php @@ -2,10 +2,12 @@ namespace DoctrineExtensions\Types; +use Carbon\Carbon; use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Exception\InvalidType; use Doctrine\DBAL\Types\TimeType; class CarbonImmutableTimeType extends TimeType @@ -25,7 +27,7 @@ public function getName() * * @return CarbonImmutable|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/CarbonTimeType.php b/src/Types/CarbonTimeType.php index fa38fcf8..16dd25e8 100644 --- a/src/Types/CarbonTimeType.php +++ b/src/Types/CarbonTimeType.php @@ -3,9 +3,11 @@ namespace DoctrineExtensions\Types; use Carbon\Carbon; +use Carbon\CarbonImmutable; use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Exception\InvalidType; use Doctrine\DBAL\Types\TimeType; class CarbonTimeType extends TimeType @@ -25,7 +27,7 @@ public function getName() * * @return Carbon|DateTimeInterface */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DateTime { $result = parent::convertToPHPValue($value, $platform); @@ -36,6 +38,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $result; } + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + { + if ($value === null) { + return $value; + } + + if ($value instanceof CarbonImmutable || $value instanceof Carbon) { + return $value->format($platform->getDateTimeFormatString()); + } + + throw InvalidType::new( + $value, + static::class, + ['null', CarbonImmutable::class, Carbon::class] + ); + } + /** * {@inheritDoc} */ diff --git a/src/Types/PolygonType.php b/src/Types/PolygonType.php index aba8d939..ba7e90c3 100644 --- a/src/Types/PolygonType.php +++ b/src/Types/PolygonType.php @@ -24,7 +24,7 @@ public function getName() /** * {@inheritDoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string { return 'POLYGON'; } @@ -42,7 +42,7 @@ public function canRequireSQLConversion() * * @return string */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): string { preg_match('/POLYGON\(\((.*)\)\)/', $value, $matches); if (! isset($matches[1])) { @@ -55,7 +55,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToPHPValueSQL($sqlExpr, $platform) + public function convertToPHPValueSQL($sqlExpr, $platform): string { return sprintf('AsText(%s)', $sqlExpr); } @@ -63,7 +63,7 @@ public function convertToPHPValueSQL($sqlExpr, $platform) /** * {@inheritDoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { return sprintf('POLYGON((%s))', $value); } @@ -71,7 +71,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): string { return sprintf('ST_PolygonFromText(%s)', $sqlExpr); } diff --git a/src/Types/ZendDateType.php b/src/Types/ZendDateType.php index 4a1e4cef..adeb9c48 100755 --- a/src/Types/ZendDateType.php +++ b/src/Types/ZendDateType.php @@ -2,8 +2,10 @@ namespace DoctrineExtensions\Types; +use DateTime; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\Exception\ValueNotConvertible; use Doctrine\DBAL\Types\Type; use Zend_Date; use Zend_Locale_Format; @@ -34,7 +36,7 @@ public function getName() /** * {@inheritDoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string { return $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration); } @@ -42,7 +44,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla /** * {@inheritDoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { return $value !== null ? $value->toString(Zend_Locale_Format::convertPhpToIsoFormat( @@ -56,7 +58,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) * * @return Zend_Date */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?DateTime { if ($value === null) { return null; @@ -68,16 +70,18 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $val = new Zend_Date($value, $dateTimeFormatString); if (! $val) { - throw ConversionException::conversionFailed($value, $this->getName()); + // dbal <4.x compatibility + if (class_exists(ValueNotConvertible::class)) { + throw ValueNotConvertible::new($value, $this->getName()); + } else { + throw ConversionException::conversionFailed($value, $this->getName()); + } } return $val; } - /** - * {@inheritDoc} - */ - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/tests/Entities/Blank.php b/tests/Entities/Blank.php index abb8e8b6..c704bde0 100644 --- a/tests/Entities/Blank.php +++ b/tests/Entities/Blank.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class Blank { /** @@ -12,5 +13,8 @@ class Blank * @ORM\Column(type="string") * @ORM\GeneratedValue */ + #[ORM\Id] + #[ORM\Column(type: 'string')] + #[ORM\GeneratedValue] public $id; } diff --git a/tests/Entities/BlogPost.php b/tests/Entities/BlogPost.php index b33c83b2..328bcb7e 100644 --- a/tests/Entities/BlogPost.php +++ b/tests/Entities/BlogPost.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class BlogPost { /** @@ -12,14 +13,20 @@ class BlogPost * @ORM\Column(type="string") * @ORM\GeneratedValue */ + #[ORM\Id] + #[ORM\Column(type: 'string')] + #[ORM\GeneratedValue] public $id; - /** @ORM\Column(type="DateTime") */ + /** @ORM\Column(type="datetime") */ + #[ORM\Column(type: 'datetime')] public $created; /** @ORM\Column(type="decimal", precision=12, scale=8) */ + #[ORM\Column(type: 'decimal', precision: 12, scale: 8)] public $longitude; /** @ORM\Column(type="decimal", precision=12, scale=8) */ + #[ORM\Column(type: 'decimal', precision: 12, scale: 8)] public $latitude; } diff --git a/tests/Entities/CarbonDate.php b/tests/Entities/CarbonDate.php index 49e1f231..7af8eba4 100644 --- a/tests/Entities/CarbonDate.php +++ b/tests/Entities/CarbonDate.php @@ -5,35 +5,46 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class CarbonDate { /** * @ORM\Id * @ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] public $id; /** @ORM\Column(type="CarbonDate", nullable=true) */ + #[ORM\Column(type: 'CarbonDate', nullable: true)] public $date; /** @ORM\Column(type="CarbonDateTime", nullable=true) */ + #[ORM\Column(type: 'CarbonDateTime', nullable: true)] public $datetime; /** @ORM\Column(type="CarbonDateTimeTz", nullable=true) */ + #[ORM\Column(type: 'CarbonDateTimeTz', nullable: true)] public $datetimeTz; /** @ORM\Column(type="CarbonTime", nullable=true) */ + #[ORM\Column(type: 'CarbonTime', nullable: true)] public $time; /** @ORM\Column(type="CarbonImmutableDate", nullable=true) */ + #[ORM\Column(type: 'CarbonImmutableDate', nullable: true)] public $dateImmutable; /** @ORM\Column(type="CarbonImmutableDateTime", nullable=true) */ + #[ORM\Column(type: 'CarbonImmutableDateTime', nullable: true)] public $datetimeImmutable; /** @ORM\Column(type="CarbonImmutableDateTimeTz", nullable=true) */ + #[ORM\Column(type: 'CarbonImmutableDateTimeTz', nullable: true)] public $datetimeTzImmutable; /** @ORM\Column(type="CarbonImmutableTime", nullable=true) */ + #[ORM\Column(type: 'CarbonImmutableTime', nullable: true)] public $timeImmutable; } diff --git a/tests/Entities/Date.php b/tests/Entities/Date.php index 7217d305..3a436900 100644 --- a/tests/Entities/Date.php +++ b/tests/Entities/Date.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class Date { /** @@ -12,8 +13,12 @@ class Date * @ORM\Column(type="string") * @ORM\GeneratedValue */ + #[ORM\Id] + #[ORM\Column(type: 'string')] + #[ORM\GeneratedValue] public $id; /** @ORM\Column(type="datetime") */ + #[ORM\Column(type: 'datetime')] public $created; } diff --git a/tests/Entities/Product.php b/tests/Entities/Product.php index 41b1cc5a..76e9fde2 100644 --- a/tests/Entities/Product.php +++ b/tests/Entities/Product.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class Product { /** @@ -12,17 +13,24 @@ class Product * @ORM\Column(type="string") * @ORM\GeneratedValue */ + #[ORM\Id] + #[ORM\Column(type: 'string')] + #[ORM\GeneratedValue] public $id; /** @ORM\Column(type="string") */ + #[ORM\Column(type: 'string')] public $name; /** @ORM\Column(type="DateTime") */ + #[ORM\Column(type: 'DateTime')] public $created; /** @ORM\Column(type="decimal", precision=10, scale=2) */ + #[ORM\Column(type: 'decimal', precision: 10, scale: 2)] public $price; /** @ORM\Column(type="decimal", precision=5, scale=2) */ + #[ORM\Column(type: 'decimal', precision: 5, scale: 2)] public $weight; } diff --git a/tests/Entities/Set.php b/tests/Entities/Set.php index 9f6de54a..f3313949 100644 --- a/tests/Entities/Set.php +++ b/tests/Entities/Set.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class Set { /** @@ -12,8 +13,12 @@ class Set * @ORM\Column(type="string") * @ORM\GeneratedValue */ + #[ORM\Id] + #[ORM\Column(type: 'string')] + #[ORM\GeneratedValue] public $id; - /** @ORM\Column(type="String") */ + /** @ORM\Column(type="string") */ + #[ORM\Column(type: 'string')] public $set; } diff --git a/tests/Entities/ZendDate.php b/tests/Entities/ZendDate.php index 413e1123..524e9cc1 100644 --- a/tests/Entities/ZendDate.php +++ b/tests/Entities/ZendDate.php @@ -5,15 +5,19 @@ use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ +#[ORM\Entity] class ZendDate { /** * @ORM\Id * @ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\Column(type: 'string')] public $id; /** @ORM\Column(type="ZendDate") */ + #[ORM\Column(type: 'ZendDate')] public $date; public function __construct($id, $date) diff --git a/tests/Query/DbTestCase.php b/tests/Query/DbTestCase.php index b4c43f0a..85c55d6d 100644 --- a/tests/Query/DbTestCase.php +++ b/tests/Query/DbTestCase.php @@ -9,6 +9,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use const PHP_VERSION_ID; + class DbTestCase extends TestCase { /** @var EntityManager */ @@ -19,13 +21,18 @@ class DbTestCase extends TestCase public function setUp(): void { - $this->configuration = new Configuration(); + if (PHP_VERSION_ID < 80000) { + $this->configuration = new Configuration(); + $this->configuration->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); + } else { + $this->configuration = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/../Entities'], true); + } + $this->configuration->setMetadataCache(new ArrayAdapter()); $this->configuration->setQueryCache(new ArrayAdapter()); $this->configuration->setProxyDir(__DIR__ . '/Proxies'); $this->configuration->setProxyNamespace('DoctrineExtensions\Tests\Proxies'); $this->configuration->setAutoGenerateProxyClasses(true); - $this->configuration->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../Entities'])); $this->entityManager = new EntityManager( DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $this->configuration), $this->configuration diff --git a/tests/Types/CarbonDateTest.php b/tests/Types/CarbonDateTest.php index 15bf8499..d7c2d9c0 100755 --- a/tests/Types/CarbonDateTest.php +++ b/tests/Types/CarbonDateTest.php @@ -17,6 +17,8 @@ use function assert; +use const PHP_VERSION_ID; + /** * Test type that maps an SQL DATETIME/TIMESTAMP to a Carbon/Carbon object. * @@ -40,13 +42,18 @@ public static function setUpBeforeClass(): void public function setUp(): void { - $config = new Configuration(); + if (PHP_VERSION_ID < 80000) { + $config = new Configuration(); + $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); + } else { + $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/../Entities'], true); + } + $config->setMetadataCache(new ArrayAdapter()); $config->setQueryCache(new ArrayAdapter()); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('DoctrineExtensions\Tests\PHPUnit\Proxies'); $config->setAutoGenerateProxyClasses(true); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); $this->em = new EntityManager( DriverManager::getConnection([ diff --git a/tests/Types/ZendDateTest.php b/tests/Types/ZendDateTest.php index f84c00e5..259d9d2d 100755 --- a/tests/Types/ZendDateTest.php +++ b/tests/Types/ZendDateTest.php @@ -16,6 +16,8 @@ use function assert; +use const PHP_VERSION_ID; + /** * Test type that maps an SQL DATETIME/TIMESTAMP to a Zend_Date object. * @@ -35,13 +37,18 @@ public static function setUpBeforeClass(): void public function setUp(): void { - $config = new Configuration(); + if (PHP_VERSION_ID < 80000) { + $config = new Configuration(); + $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); + } else { + $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/../Entities'], true); + } + $config->setMetadataCache(new ArrayAdapter()); $config->setQueryCache(new ArrayAdapter()); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('DoctrineExtensions\Tests\PHPUnit\Proxies'); $config->setAutoGenerateProxyClasses(true); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); $this->em = new EntityManager( DriverManager::getConnection([