diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Query/AST/Functions | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Query/AST/Functions')
26 files changed, 1279 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/AbsFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/AbsFunction.php new file mode 100644 index 0000000..4edff06 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/AbsFunction.php | |||
@@ -0,0 +1,37 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "ABS" "(" SimpleArithmeticExpression ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class AbsFunction extends FunctionNode | ||
18 | { | ||
19 | public Node|string $simpleArithmeticExpression; | ||
20 | |||
21 | public function getSql(SqlWalker $sqlWalker): string | ||
22 | { | ||
23 | return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression( | ||
24 | $this->simpleArithmeticExpression, | ||
25 | ) . ')'; | ||
26 | } | ||
27 | |||
28 | public function parse(Parser $parser): void | ||
29 | { | ||
30 | $parser->match(TokenType::T_IDENTIFIER); | ||
31 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
32 | |||
33 | $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
34 | |||
35 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
36 | } | ||
37 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/AvgFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/AvgFunction.php new file mode 100644 index 0000000..ba7b7f3 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/AvgFunction.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\AggregateExpression; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | |||
11 | /** | ||
12 | * "AVG" "(" ["DISTINCT"] StringPrimary ")" | ||
13 | */ | ||
14 | final class AvgFunction extends FunctionNode | ||
15 | { | ||
16 | private AggregateExpression $aggregateExpression; | ||
17 | |||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $this->aggregateExpression->dispatch($sqlWalker); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $this->aggregateExpression = $parser->AggregateExpression(); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/BitAndFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/BitAndFunction.php new file mode 100644 index 0000000..f2d3146 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/BitAndFunction.php | |||
@@ -0,0 +1,43 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class BitAndFunction extends FunctionNode | ||
18 | { | ||
19 | public Node $firstArithmetic; | ||
20 | public Node $secondArithmetic; | ||
21 | |||
22 | public function getSql(SqlWalker $sqlWalker): string | ||
23 | { | ||
24 | $platform = $sqlWalker->getConnection()->getDatabasePlatform(); | ||
25 | |||
26 | return $platform->getBitAndComparisonExpression( | ||
27 | $this->firstArithmetic->dispatch($sqlWalker), | ||
28 | $this->secondArithmetic->dispatch($sqlWalker), | ||
29 | ); | ||
30 | } | ||
31 | |||
32 | public function parse(Parser $parser): void | ||
33 | { | ||
34 | $parser->match(TokenType::T_IDENTIFIER); | ||
35 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
36 | |||
37 | $this->firstArithmetic = $parser->ArithmeticPrimary(); | ||
38 | $parser->match(TokenType::T_COMMA); | ||
39 | $this->secondArithmetic = $parser->ArithmeticPrimary(); | ||
40 | |||
41 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
42 | } | ||
43 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/BitOrFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/BitOrFunction.php new file mode 100644 index 0000000..f3f84da --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/BitOrFunction.php | |||
@@ -0,0 +1,43 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class BitOrFunction extends FunctionNode | ||
18 | { | ||
19 | public Node $firstArithmetic; | ||
20 | public Node $secondArithmetic; | ||
21 | |||
22 | public function getSql(SqlWalker $sqlWalker): string | ||
23 | { | ||
24 | $platform = $sqlWalker->getConnection()->getDatabasePlatform(); | ||
25 | |||
26 | return $platform->getBitOrComparisonExpression( | ||
27 | $this->firstArithmetic->dispatch($sqlWalker), | ||
28 | $this->secondArithmetic->dispatch($sqlWalker), | ||
29 | ); | ||
30 | } | ||
31 | |||
32 | public function parse(Parser $parser): void | ||
33 | { | ||
34 | $parser->match(TokenType::T_IDENTIFIER); | ||
35 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
36 | |||
37 | $this->firstArithmetic = $parser->ArithmeticPrimary(); | ||
38 | $parser->match(TokenType::T_COMMA); | ||
39 | $this->secondArithmetic = $parser->ArithmeticPrimary(); | ||
40 | |||
41 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
42 | } | ||
43 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/ConcatFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/ConcatFunction.php new file mode 100644 index 0000000..5b8d696 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/ConcatFunction.php | |||
@@ -0,0 +1,58 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "CONCAT" "(" StringPrimary "," StringPrimary {"," StringPrimary }* ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class ConcatFunction extends FunctionNode | ||
18 | { | ||
19 | public Node $firstStringPrimary; | ||
20 | public Node $secondStringPrimary; | ||
21 | |||
22 | /** @psalm-var list<Node> */ | ||
23 | public array $concatExpressions = []; | ||
24 | |||
25 | public function getSql(SqlWalker $sqlWalker): string | ||
26 | { | ||
27 | $platform = $sqlWalker->getConnection()->getDatabasePlatform(); | ||
28 | |||
29 | $args = []; | ||
30 | |||
31 | foreach ($this->concatExpressions as $expression) { | ||
32 | $args[] = $sqlWalker->walkStringPrimary($expression); | ||
33 | } | ||
34 | |||
35 | return $platform->getConcatExpression(...$args); | ||
36 | } | ||
37 | |||
38 | public function parse(Parser $parser): void | ||
39 | { | ||
40 | $parser->match(TokenType::T_IDENTIFIER); | ||
41 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
42 | |||
43 | $this->firstStringPrimary = $parser->StringPrimary(); | ||
44 | $this->concatExpressions[] = $this->firstStringPrimary; | ||
45 | |||
46 | $parser->match(TokenType::T_COMMA); | ||
47 | |||
48 | $this->secondStringPrimary = $parser->StringPrimary(); | ||
49 | $this->concatExpressions[] = $this->secondStringPrimary; | ||
50 | |||
51 | while ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { | ||
52 | $parser->match(TokenType::T_COMMA); | ||
53 | $this->concatExpressions[] = $parser->StringPrimary(); | ||
54 | } | ||
55 | |||
56 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
57 | } | ||
58 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/CountFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/CountFunction.php new file mode 100644 index 0000000..dc926a5 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/CountFunction.php | |||
@@ -0,0 +1,35 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\DBAL\Types\Type; | ||
8 | use Doctrine\DBAL\Types\Types; | ||
9 | use Doctrine\ORM\Query\AST\AggregateExpression; | ||
10 | use Doctrine\ORM\Query\AST\TypedExpression; | ||
11 | use Doctrine\ORM\Query\Parser; | ||
12 | use Doctrine\ORM\Query\SqlWalker; | ||
13 | |||
14 | /** | ||
15 | * "COUNT" "(" ["DISTINCT"] StringPrimary ")" | ||
16 | */ | ||
17 | final class CountFunction extends FunctionNode implements TypedExpression | ||
18 | { | ||
19 | private AggregateExpression $aggregateExpression; | ||
20 | |||
21 | public function getSql(SqlWalker $sqlWalker): string | ||
22 | { | ||
23 | return $this->aggregateExpression->dispatch($sqlWalker); | ||
24 | } | ||
25 | |||
26 | public function parse(Parser $parser): void | ||
27 | { | ||
28 | $this->aggregateExpression = $parser->AggregateExpression(); | ||
29 | } | ||
30 | |||
31 | public function getReturnType(): Type | ||
32 | { | ||
33 | return Type::getType(Types::INTEGER); | ||
34 | } | ||
35 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/CurrentDateFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/CurrentDateFunction.php new file mode 100644 index 0000000..cec9632 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/CurrentDateFunction.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\Parser; | ||
8 | use Doctrine\ORM\Query\SqlWalker; | ||
9 | use Doctrine\ORM\Query\TokenType; | ||
10 | |||
11 | /** | ||
12 | * "CURRENT_DATE" | ||
13 | * | ||
14 | * @link www.doctrine-project.org | ||
15 | */ | ||
16 | class CurrentDateFunction extends FunctionNode | ||
17 | { | ||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSQL(); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $parser->match(TokenType::T_IDENTIFIER); | ||
26 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
27 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
28 | } | ||
29 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/CurrentTimeFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/CurrentTimeFunction.php new file mode 100644 index 0000000..6473fce --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/CurrentTimeFunction.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\Parser; | ||
8 | use Doctrine\ORM\Query\SqlWalker; | ||
9 | use Doctrine\ORM\Query\TokenType; | ||
10 | |||
11 | /** | ||
12 | * "CURRENT_TIME" | ||
13 | * | ||
14 | * @link www.doctrine-project.org | ||
15 | */ | ||
16 | class CurrentTimeFunction extends FunctionNode | ||
17 | { | ||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSQL(); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $parser->match(TokenType::T_IDENTIFIER); | ||
26 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
27 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
28 | } | ||
29 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/CurrentTimestampFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/CurrentTimestampFunction.php new file mode 100644 index 0000000..edcd27c --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/CurrentTimestampFunction.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\Parser; | ||
8 | use Doctrine\ORM\Query\SqlWalker; | ||
9 | use Doctrine\ORM\Query\TokenType; | ||
10 | |||
11 | /** | ||
12 | * "CURRENT_TIMESTAMP" | ||
13 | * | ||
14 | * @link www.doctrine-project.org | ||
15 | */ | ||
16 | class CurrentTimestampFunction extends FunctionNode | ||
17 | { | ||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSQL(); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $parser->match(TokenType::T_IDENTIFIER); | ||
26 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
27 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
28 | } | ||
29 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/DateAddFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/DateAddFunction.php new file mode 100644 index 0000000..12920dc --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/DateAddFunction.php | |||
@@ -0,0 +1,83 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\ASTException; | ||
8 | use Doctrine\ORM\Query\AST\Node; | ||
9 | use Doctrine\ORM\Query\Parser; | ||
10 | use Doctrine\ORM\Query\QueryException; | ||
11 | use Doctrine\ORM\Query\SqlWalker; | ||
12 | use Doctrine\ORM\Query\TokenType; | ||
13 | |||
14 | use function strtolower; | ||
15 | |||
16 | /** | ||
17 | * "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" | ||
18 | * | ||
19 | * @link www.doctrine-project.org | ||
20 | */ | ||
21 | class DateAddFunction extends FunctionNode | ||
22 | { | ||
23 | public Node $firstDateExpression; | ||
24 | public Node $intervalExpression; | ||
25 | public Node $unit; | ||
26 | |||
27 | public function getSql(SqlWalker $sqlWalker): string | ||
28 | { | ||
29 | return match (strtolower((string) $this->unit->value)) { | ||
30 | 'second' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( | ||
31 | $this->firstDateExpression->dispatch($sqlWalker), | ||
32 | $this->dispatchIntervalExpression($sqlWalker), | ||
33 | ), | ||
34 | 'minute' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( | ||
35 | $this->firstDateExpression->dispatch($sqlWalker), | ||
36 | $this->dispatchIntervalExpression($sqlWalker), | ||
37 | ), | ||
38 | 'hour' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( | ||
39 | $this->firstDateExpression->dispatch($sqlWalker), | ||
40 | $this->dispatchIntervalExpression($sqlWalker), | ||
41 | ), | ||
42 | 'day' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( | ||
43 | $this->firstDateExpression->dispatch($sqlWalker), | ||
44 | $this->dispatchIntervalExpression($sqlWalker), | ||
45 | ), | ||
46 | 'week' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( | ||
47 | $this->firstDateExpression->dispatch($sqlWalker), | ||
48 | $this->dispatchIntervalExpression($sqlWalker), | ||
49 | ), | ||
50 | 'month' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( | ||
51 | $this->firstDateExpression->dispatch($sqlWalker), | ||
52 | $this->dispatchIntervalExpression($sqlWalker), | ||
53 | ), | ||
54 | 'year' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( | ||
55 | $this->firstDateExpression->dispatch($sqlWalker), | ||
56 | $this->dispatchIntervalExpression($sqlWalker), | ||
57 | ), | ||
58 | default => throw QueryException::semanticalError( | ||
59 | 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.', | ||
60 | ), | ||
61 | }; | ||
62 | } | ||
63 | |||
64 | /** @throws ASTException */ | ||
65 | private function dispatchIntervalExpression(SqlWalker $sqlWalker): string | ||
66 | { | ||
67 | return $this->intervalExpression->dispatch($sqlWalker); | ||
68 | } | ||
69 | |||
70 | public function parse(Parser $parser): void | ||
71 | { | ||
72 | $parser->match(TokenType::T_IDENTIFIER); | ||
73 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
74 | |||
75 | $this->firstDateExpression = $parser->ArithmeticPrimary(); | ||
76 | $parser->match(TokenType::T_COMMA); | ||
77 | $this->intervalExpression = $parser->ArithmeticPrimary(); | ||
78 | $parser->match(TokenType::T_COMMA); | ||
79 | $this->unit = $parser->StringPrimary(); | ||
80 | |||
81 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
82 | } | ||
83 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/DateDiffFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/DateDiffFunction.php new file mode 100644 index 0000000..55598c0 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/DateDiffFunction.php | |||
@@ -0,0 +1,41 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class DateDiffFunction extends FunctionNode | ||
18 | { | ||
19 | public Node $date1; | ||
20 | public Node $date2; | ||
21 | |||
22 | public function getSql(SqlWalker $sqlWalker): string | ||
23 | { | ||
24 | return $sqlWalker->getConnection()->getDatabasePlatform()->getDateDiffExpression( | ||
25 | $this->date1->dispatch($sqlWalker), | ||
26 | $this->date2->dispatch($sqlWalker), | ||
27 | ); | ||
28 | } | ||
29 | |||
30 | public function parse(Parser $parser): void | ||
31 | { | ||
32 | $parser->match(TokenType::T_IDENTIFIER); | ||
33 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
34 | |||
35 | $this->date1 = $parser->ArithmeticPrimary(); | ||
36 | $parser->match(TokenType::T_COMMA); | ||
37 | $this->date2 = $parser->ArithmeticPrimary(); | ||
38 | |||
39 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
40 | } | ||
41 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/DateSubFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/DateSubFunction.php new file mode 100644 index 0000000..5363680 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/DateSubFunction.php | |||
@@ -0,0 +1,62 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\ASTException; | ||
8 | use Doctrine\ORM\Query\QueryException; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | |||
11 | use function strtolower; | ||
12 | |||
13 | /** | ||
14 | * "DATE_SUB(date1, interval, unit)" | ||
15 | * | ||
16 | * @link www.doctrine-project.org | ||
17 | */ | ||
18 | class DateSubFunction extends DateAddFunction | ||
19 | { | ||
20 | public function getSql(SqlWalker $sqlWalker): string | ||
21 | { | ||
22 | return match (strtolower((string) $this->unit->value)) { | ||
23 | 'second' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( | ||
24 | $this->firstDateExpression->dispatch($sqlWalker), | ||
25 | $this->dispatchIntervalExpression($sqlWalker), | ||
26 | ), | ||
27 | 'minute' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( | ||
28 | $this->firstDateExpression->dispatch($sqlWalker), | ||
29 | $this->dispatchIntervalExpression($sqlWalker), | ||
30 | ), | ||
31 | 'hour' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( | ||
32 | $this->firstDateExpression->dispatch($sqlWalker), | ||
33 | $this->dispatchIntervalExpression($sqlWalker), | ||
34 | ), | ||
35 | 'day' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( | ||
36 | $this->firstDateExpression->dispatch($sqlWalker), | ||
37 | $this->dispatchIntervalExpression($sqlWalker), | ||
38 | ), | ||
39 | 'week' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( | ||
40 | $this->firstDateExpression->dispatch($sqlWalker), | ||
41 | $this->dispatchIntervalExpression($sqlWalker), | ||
42 | ), | ||
43 | 'month' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( | ||
44 | $this->firstDateExpression->dispatch($sqlWalker), | ||
45 | $this->dispatchIntervalExpression($sqlWalker), | ||
46 | ), | ||
47 | 'year' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( | ||
48 | $this->firstDateExpression->dispatch($sqlWalker), | ||
49 | $this->dispatchIntervalExpression($sqlWalker), | ||
50 | ), | ||
51 | default => throw QueryException::semanticalError( | ||
52 | 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.', | ||
53 | ), | ||
54 | }; | ||
55 | } | ||
56 | |||
57 | /** @throws ASTException */ | ||
58 | private function dispatchIntervalExpression(SqlWalker $sqlWalker): string | ||
59 | { | ||
60 | return $this->intervalExpression->dispatch($sqlWalker); | ||
61 | } | ||
62 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/FunctionNode.php b/vendor/doctrine/orm/src/Query/AST/Functions/FunctionNode.php new file mode 100644 index 0000000..4cc549e --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/FunctionNode.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | |||
11 | /** | ||
12 | * Abstract Function Node. | ||
13 | * | ||
14 | * @link www.doctrine-project.org | ||
15 | * | ||
16 | * @psalm-consistent-constructor | ||
17 | */ | ||
18 | abstract class FunctionNode extends Node | ||
19 | { | ||
20 | public function __construct(public string $name) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | abstract public function getSql(SqlWalker $sqlWalker): string; | ||
25 | |||
26 | public function dispatch(SqlWalker $sqlWalker): string | ||
27 | { | ||
28 | return $sqlWalker->walkFunction($this); | ||
29 | } | ||
30 | |||
31 | abstract public function parse(Parser $parser): void; | ||
32 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/IdentityFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/IdentityFunction.php new file mode 100644 index 0000000..1dd1bf5 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/IdentityFunction.php | |||
@@ -0,0 +1,90 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\PathExpression; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\QueryException; | ||
10 | use Doctrine\ORM\Query\SqlWalker; | ||
11 | use Doctrine\ORM\Query\TokenType; | ||
12 | |||
13 | use function assert; | ||
14 | use function reset; | ||
15 | use function sprintf; | ||
16 | |||
17 | /** | ||
18 | * "IDENTITY" "(" SingleValuedAssociationPathExpression {"," string} ")" | ||
19 | * | ||
20 | * @link www.doctrine-project.org | ||
21 | */ | ||
22 | class IdentityFunction extends FunctionNode | ||
23 | { | ||
24 | public PathExpression $pathExpression; | ||
25 | |||
26 | public string|null $fieldMapping = null; | ||
27 | |||
28 | public function getSql(SqlWalker $sqlWalker): string | ||
29 | { | ||
30 | assert($this->pathExpression->field !== null); | ||
31 | $entityManager = $sqlWalker->getEntityManager(); | ||
32 | $platform = $entityManager->getConnection()->getDatabasePlatform(); | ||
33 | $quoteStrategy = $entityManager->getConfiguration()->getQuoteStrategy(); | ||
34 | $dqlAlias = $this->pathExpression->identificationVariable; | ||
35 | $assocField = $this->pathExpression->field; | ||
36 | $assoc = $sqlWalker->getMetadataForDqlAlias($dqlAlias)->associationMappings[$assocField]; | ||
37 | $targetEntity = $entityManager->getClassMetadata($assoc->targetEntity); | ||
38 | |||
39 | assert($assoc->isToOneOwningSide()); | ||
40 | $joinColumn = reset($assoc->joinColumns); | ||
41 | |||
42 | if ($this->fieldMapping !== null) { | ||
43 | if (! isset($targetEntity->fieldMappings[$this->fieldMapping])) { | ||
44 | throw new QueryException(sprintf('Undefined reference field mapping "%s"', $this->fieldMapping)); | ||
45 | } | ||
46 | |||
47 | $field = $targetEntity->fieldMappings[$this->fieldMapping]; | ||
48 | $joinColumn = null; | ||
49 | |||
50 | foreach ($assoc->joinColumns as $mapping) { | ||
51 | if ($mapping->referencedColumnName === $field->columnName) { | ||
52 | $joinColumn = $mapping; | ||
53 | |||
54 | break; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | if ($joinColumn === null) { | ||
59 | throw new QueryException(sprintf('Unable to resolve the reference field mapping "%s"', $this->fieldMapping)); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | // The table with the relation may be a subclass, so get the table name from the association definition | ||
64 | $tableName = $entityManager->getClassMetadata($assoc->sourceEntity)->getTableName(); | ||
65 | |||
66 | $tableAlias = $sqlWalker->getSQLTableAlias($tableName, $dqlAlias); | ||
67 | $columnName = $quoteStrategy->getJoinColumnName($joinColumn, $targetEntity, $platform); | ||
68 | |||
69 | return $tableAlias . '.' . $columnName; | ||
70 | } | ||
71 | |||
72 | public function parse(Parser $parser): void | ||
73 | { | ||
74 | $parser->match(TokenType::T_IDENTIFIER); | ||
75 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
76 | |||
77 | $this->pathExpression = $parser->SingleValuedAssociationPathExpression(); | ||
78 | |||
79 | if ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { | ||
80 | $parser->match(TokenType::T_COMMA); | ||
81 | $parser->match(TokenType::T_STRING); | ||
82 | |||
83 | $token = $parser->getLexer()->token; | ||
84 | assert($token !== null); | ||
85 | $this->fieldMapping = $token->value; | ||
86 | } | ||
87 | |||
88 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
89 | } | ||
90 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/LengthFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/LengthFunction.php new file mode 100644 index 0000000..3994918 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/LengthFunction.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\DBAL\Types\Type; | ||
8 | use Doctrine\DBAL\Types\Types; | ||
9 | use Doctrine\ORM\Query\AST\Node; | ||
10 | use Doctrine\ORM\Query\AST\TypedExpression; | ||
11 | use Doctrine\ORM\Query\Parser; | ||
12 | use Doctrine\ORM\Query\SqlWalker; | ||
13 | use Doctrine\ORM\Query\TokenType; | ||
14 | |||
15 | /** | ||
16 | * "LENGTH" "(" StringPrimary ")" | ||
17 | * | ||
18 | * @link www.doctrine-project.org | ||
19 | */ | ||
20 | class LengthFunction extends FunctionNode implements TypedExpression | ||
21 | { | ||
22 | public Node $stringPrimary; | ||
23 | |||
24 | public function getSql(SqlWalker $sqlWalker): string | ||
25 | { | ||
26 | return $sqlWalker->getConnection()->getDatabasePlatform()->getLengthExpression( | ||
27 | $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | public function parse(Parser $parser): void | ||
32 | { | ||
33 | $parser->match(TokenType::T_IDENTIFIER); | ||
34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
35 | |||
36 | $this->stringPrimary = $parser->StringPrimary(); | ||
37 | |||
38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
39 | } | ||
40 | |||
41 | public function getReturnType(): Type | ||
42 | { | ||
43 | return Type::getType(Types::INTEGER); | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/LocateFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/LocateFunction.php new file mode 100644 index 0000000..c0d3b4a --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/LocateFunction.php | |||
@@ -0,0 +1,62 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class LocateFunction extends FunctionNode | ||
18 | { | ||
19 | public Node|string $firstStringPrimary; | ||
20 | public Node|string $secondStringPrimary; | ||
21 | |||
22 | public Node|string|bool $simpleArithmeticExpression = false; | ||
23 | |||
24 | public function getSql(SqlWalker $sqlWalker): string | ||
25 | { | ||
26 | $platform = $sqlWalker->getConnection()->getDatabasePlatform(); | ||
27 | |||
28 | $firstString = $sqlWalker->walkStringPrimary($this->firstStringPrimary); | ||
29 | $secondString = $sqlWalker->walkStringPrimary($this->secondStringPrimary); | ||
30 | |||
31 | if ($this->simpleArithmeticExpression) { | ||
32 | return $platform->getLocateExpression( | ||
33 | $secondString, | ||
34 | $firstString, | ||
35 | $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression), | ||
36 | ); | ||
37 | } | ||
38 | |||
39 | return $platform->getLocateExpression($secondString, $firstString); | ||
40 | } | ||
41 | |||
42 | public function parse(Parser $parser): void | ||
43 | { | ||
44 | $parser->match(TokenType::T_IDENTIFIER); | ||
45 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
46 | |||
47 | $this->firstStringPrimary = $parser->StringPrimary(); | ||
48 | |||
49 | $parser->match(TokenType::T_COMMA); | ||
50 | |||
51 | $this->secondStringPrimary = $parser->StringPrimary(); | ||
52 | |||
53 | $lexer = $parser->getLexer(); | ||
54 | if ($lexer->isNextToken(TokenType::T_COMMA)) { | ||
55 | $parser->match(TokenType::T_COMMA); | ||
56 | |||
57 | $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
58 | } | ||
59 | |||
60 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
61 | } | ||
62 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/LowerFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/LowerFunction.php new file mode 100644 index 0000000..8ae337a --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/LowerFunction.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | use function sprintf; | ||
13 | |||
14 | /** | ||
15 | * "LOWER" "(" StringPrimary ")" | ||
16 | * | ||
17 | * @link www.doctrine-project.org | ||
18 | */ | ||
19 | class LowerFunction extends FunctionNode | ||
20 | { | ||
21 | public Node $stringPrimary; | ||
22 | |||
23 | public function getSql(SqlWalker $sqlWalker): string | ||
24 | { | ||
25 | return sprintf( | ||
26 | 'LOWER(%s)', | ||
27 | $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | public function parse(Parser $parser): void | ||
32 | { | ||
33 | $parser->match(TokenType::T_IDENTIFIER); | ||
34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
35 | |||
36 | $this->stringPrimary = $parser->StringPrimary(); | ||
37 | |||
38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
39 | } | ||
40 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/MaxFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/MaxFunction.php new file mode 100644 index 0000000..8a6eecf --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/MaxFunction.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\AggregateExpression; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | |||
11 | /** | ||
12 | * "MAX" "(" ["DISTINCT"] StringPrimary ")" | ||
13 | */ | ||
14 | final class MaxFunction extends FunctionNode | ||
15 | { | ||
16 | private AggregateExpression $aggregateExpression; | ||
17 | |||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $this->aggregateExpression->dispatch($sqlWalker); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $this->aggregateExpression = $parser->AggregateExpression(); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/MinFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/MinFunction.php new file mode 100644 index 0000000..98d73a2 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/MinFunction.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\AggregateExpression; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | |||
11 | /** | ||
12 | * "MIN" "(" ["DISTINCT"] StringPrimary ")" | ||
13 | */ | ||
14 | final class MinFunction extends FunctionNode | ||
15 | { | ||
16 | private AggregateExpression $aggregateExpression; | ||
17 | |||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $this->aggregateExpression->dispatch($sqlWalker); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $this->aggregateExpression = $parser->AggregateExpression(); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/ModFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/ModFunction.php new file mode 100644 index 0000000..7c1af0b --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/ModFunction.php | |||
@@ -0,0 +1,43 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class ModFunction extends FunctionNode | ||
18 | { | ||
19 | public Node|string $firstSimpleArithmeticExpression; | ||
20 | public Node|string $secondSimpleArithmeticExpression; | ||
21 | |||
22 | public function getSql(SqlWalker $sqlWalker): string | ||
23 | { | ||
24 | return $sqlWalker->getConnection()->getDatabasePlatform()->getModExpression( | ||
25 | $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), | ||
26 | $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression), | ||
27 | ); | ||
28 | } | ||
29 | |||
30 | public function parse(Parser $parser): void | ||
31 | { | ||
32 | $parser->match(TokenType::T_IDENTIFIER); | ||
33 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
34 | |||
35 | $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
36 | |||
37 | $parser->match(TokenType::T_COMMA); | ||
38 | |||
39 | $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
40 | |||
41 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
42 | } | ||
43 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/SizeFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/SizeFunction.php new file mode 100644 index 0000000..87ee713 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/SizeFunction.php | |||
@@ -0,0 +1,113 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\PathExpression; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | use function assert; | ||
13 | |||
14 | /** | ||
15 | * "SIZE" "(" CollectionValuedPathExpression ")" | ||
16 | * | ||
17 | * @link www.doctrine-project.org | ||
18 | */ | ||
19 | class SizeFunction extends FunctionNode | ||
20 | { | ||
21 | public PathExpression $collectionPathExpression; | ||
22 | |||
23 | /** | ||
24 | * @inheritdoc | ||
25 | * @todo If the collection being counted is already joined, the SQL can be simpler (more efficient). | ||
26 | */ | ||
27 | public function getSql(SqlWalker $sqlWalker): string | ||
28 | { | ||
29 | assert($this->collectionPathExpression->field !== null); | ||
30 | $entityManager = $sqlWalker->getEntityManager(); | ||
31 | $platform = $entityManager->getConnection()->getDatabasePlatform(); | ||
32 | $quoteStrategy = $entityManager->getConfiguration()->getQuoteStrategy(); | ||
33 | $dqlAlias = $this->collectionPathExpression->identificationVariable; | ||
34 | $assocField = $this->collectionPathExpression->field; | ||
35 | |||
36 | $class = $sqlWalker->getMetadataForDqlAlias($dqlAlias); | ||
37 | $assoc = $class->associationMappings[$assocField]; | ||
38 | $sql = 'SELECT COUNT(*) FROM '; | ||
39 | |||
40 | if ($assoc->isOneToMany()) { | ||
41 | $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); | ||
42 | $targetTableAlias = $sqlWalker->getSQLTableAlias($targetClass->getTableName()); | ||
43 | $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); | ||
44 | |||
45 | $sql .= $quoteStrategy->getTableName($targetClass, $platform) . ' ' . $targetTableAlias . ' WHERE '; | ||
46 | |||
47 | $owningAssoc = $targetClass->associationMappings[$assoc->mappedBy]; | ||
48 | assert($owningAssoc->isManyToOne()); | ||
49 | |||
50 | $first = true; | ||
51 | |||
52 | foreach ($owningAssoc->targetToSourceKeyColumns as $targetColumn => $sourceColumn) { | ||
53 | if ($first) { | ||
54 | $first = false; | ||
55 | } else { | ||
56 | $sql .= ' AND '; | ||
57 | } | ||
58 | |||
59 | $sql .= $targetTableAlias . '.' . $sourceColumn | ||
60 | . ' = ' | ||
61 | . $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform); | ||
62 | } | ||
63 | } else { // many-to-many | ||
64 | assert($assoc->isManyToMany()); | ||
65 | $owningAssoc = $entityManager->getMetadataFactory()->getOwningSide($assoc); | ||
66 | $joinTable = $owningAssoc->joinTable; | ||
67 | |||
68 | // SQL table aliases | ||
69 | $joinTableAlias = $sqlWalker->getSQLTableAlias($joinTable->name); | ||
70 | $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); | ||
71 | |||
72 | // join to target table | ||
73 | $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); | ||
74 | $sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE '; | ||
75 | |||
76 | $joinColumns = $assoc->isOwningSide() | ||
77 | ? $joinTable->joinColumns | ||
78 | : $joinTable->inverseJoinColumns; | ||
79 | |||
80 | $first = true; | ||
81 | |||
82 | foreach ($joinColumns as $joinColumn) { | ||
83 | if ($first) { | ||
84 | $first = false; | ||
85 | } else { | ||
86 | $sql .= ' AND '; | ||
87 | } | ||
88 | |||
89 | $sourceColumnName = $quoteStrategy->getColumnName( | ||
90 | $class->fieldNames[$joinColumn->referencedColumnName], | ||
91 | $class, | ||
92 | $platform, | ||
93 | ); | ||
94 | |||
95 | $sql .= $joinTableAlias . '.' . $joinColumn->name | ||
96 | . ' = ' | ||
97 | . $sourceTableAlias . '.' . $sourceColumnName; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | return '(' . $sql . ')'; | ||
102 | } | ||
103 | |||
104 | public function parse(Parser $parser): void | ||
105 | { | ||
106 | $parser->match(TokenType::T_IDENTIFIER); | ||
107 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
108 | |||
109 | $this->collectionPathExpression = $parser->CollectionValuedPathExpression(); | ||
110 | |||
111 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
112 | } | ||
113 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/SqrtFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/SqrtFunction.php new file mode 100644 index 0000000..e643663 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/SqrtFunction.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | use function sprintf; | ||
13 | |||
14 | /** | ||
15 | * "SQRT" "(" SimpleArithmeticExpression ")" | ||
16 | * | ||
17 | * @link www.doctrine-project.org | ||
18 | */ | ||
19 | class SqrtFunction extends FunctionNode | ||
20 | { | ||
21 | public Node|string $simpleArithmeticExpression; | ||
22 | |||
23 | public function getSql(SqlWalker $sqlWalker): string | ||
24 | { | ||
25 | return sprintf( | ||
26 | 'SQRT(%s)', | ||
27 | $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression), | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | public function parse(Parser $parser): void | ||
32 | { | ||
33 | $parser->match(TokenType::T_IDENTIFIER); | ||
34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
35 | |||
36 | $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
37 | |||
38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
39 | } | ||
40 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/SubstringFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/SubstringFunction.php new file mode 100644 index 0000000..5744f08 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/SubstringFunction.php | |||
@@ -0,0 +1,58 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | /** | ||
13 | * "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class SubstringFunction extends FunctionNode | ||
18 | { | ||
19 | public Node $stringPrimary; | ||
20 | |||
21 | public Node|string $firstSimpleArithmeticExpression; | ||
22 | public Node|string|null $secondSimpleArithmeticExpression = null; | ||
23 | |||
24 | public function getSql(SqlWalker $sqlWalker): string | ||
25 | { | ||
26 | $optionalSecondSimpleArithmeticExpression = null; | ||
27 | if ($this->secondSimpleArithmeticExpression !== null) { | ||
28 | $optionalSecondSimpleArithmeticExpression = $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression); | ||
29 | } | ||
30 | |||
31 | return $sqlWalker->getConnection()->getDatabasePlatform()->getSubstringExpression( | ||
32 | $sqlWalker->walkStringPrimary($this->stringPrimary), | ||
33 | $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), | ||
34 | $optionalSecondSimpleArithmeticExpression, | ||
35 | ); | ||
36 | } | ||
37 | |||
38 | public function parse(Parser $parser): void | ||
39 | { | ||
40 | $parser->match(TokenType::T_IDENTIFIER); | ||
41 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
42 | |||
43 | $this->stringPrimary = $parser->StringPrimary(); | ||
44 | |||
45 | $parser->match(TokenType::T_COMMA); | ||
46 | |||
47 | $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
48 | |||
49 | $lexer = $parser->getLexer(); | ||
50 | if ($lexer->isNextToken(TokenType::T_COMMA)) { | ||
51 | $parser->match(TokenType::T_COMMA); | ||
52 | |||
53 | $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); | ||
54 | } | ||
55 | |||
56 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
57 | } | ||
58 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/SumFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/SumFunction.php new file mode 100644 index 0000000..588dce9 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/SumFunction.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\AggregateExpression; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | |||
11 | /** | ||
12 | * "SUM" "(" ["DISTINCT"] StringPrimary ")" | ||
13 | */ | ||
14 | final class SumFunction extends FunctionNode | ||
15 | { | ||
16 | private AggregateExpression $aggregateExpression; | ||
17 | |||
18 | public function getSql(SqlWalker $sqlWalker): string | ||
19 | { | ||
20 | return $this->aggregateExpression->dispatch($sqlWalker); | ||
21 | } | ||
22 | |||
23 | public function parse(Parser $parser): void | ||
24 | { | ||
25 | $this->aggregateExpression = $parser->AggregateExpression(); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/TrimFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/TrimFunction.php new file mode 100644 index 0000000..e0a3e99 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/TrimFunction.php | |||
@@ -0,0 +1,119 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\DBAL\Platforms\TrimMode; | ||
8 | use Doctrine\ORM\Query\AST\Node; | ||
9 | use Doctrine\ORM\Query\Parser; | ||
10 | use Doctrine\ORM\Query\SqlWalker; | ||
11 | use Doctrine\ORM\Query\TokenType; | ||
12 | |||
13 | use function assert; | ||
14 | use function strcasecmp; | ||
15 | |||
16 | /** | ||
17 | * "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" | ||
18 | * | ||
19 | * @link www.doctrine-project.org | ||
20 | */ | ||
21 | class TrimFunction extends FunctionNode | ||
22 | { | ||
23 | public bool $leading = false; | ||
24 | public bool $trailing = false; | ||
25 | public bool $both = false; | ||
26 | public string|false $trimChar = false; | ||
27 | public Node $stringPrimary; | ||
28 | |||
29 | public function getSql(SqlWalker $sqlWalker): string | ||
30 | { | ||
31 | $stringPrimary = $sqlWalker->walkStringPrimary($this->stringPrimary); | ||
32 | $platform = $sqlWalker->getConnection()->getDatabasePlatform(); | ||
33 | $trimMode = $this->getTrimMode(); | ||
34 | |||
35 | if ($this->trimChar !== false) { | ||
36 | return $platform->getTrimExpression( | ||
37 | $stringPrimary, | ||
38 | $trimMode, | ||
39 | $platform->quoteStringLiteral($this->trimChar), | ||
40 | ); | ||
41 | } | ||
42 | |||
43 | return $platform->getTrimExpression($stringPrimary, $trimMode); | ||
44 | } | ||
45 | |||
46 | public function parse(Parser $parser): void | ||
47 | { | ||
48 | $lexer = $parser->getLexer(); | ||
49 | |||
50 | $parser->match(TokenType::T_IDENTIFIER); | ||
51 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
52 | |||
53 | $this->parseTrimMode($parser); | ||
54 | |||
55 | if ($lexer->isNextToken(TokenType::T_STRING)) { | ||
56 | $parser->match(TokenType::T_STRING); | ||
57 | |||
58 | assert($lexer->token !== null); | ||
59 | $this->trimChar = $lexer->token->value; | ||
60 | } | ||
61 | |||
62 | if ($this->leading || $this->trailing || $this->both || ($this->trimChar !== false)) { | ||
63 | $parser->match(TokenType::T_FROM); | ||
64 | } | ||
65 | |||
66 | $this->stringPrimary = $parser->StringPrimary(); | ||
67 | |||
68 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
69 | } | ||
70 | |||
71 | /** @psalm-return TrimMode::* */ | ||
72 | private function getTrimMode(): TrimMode|int | ||
73 | { | ||
74 | if ($this->leading) { | ||
75 | return TrimMode::LEADING; | ||
76 | } | ||
77 | |||
78 | if ($this->trailing) { | ||
79 | return TrimMode::TRAILING; | ||
80 | } | ||
81 | |||
82 | if ($this->both) { | ||
83 | return TrimMode::BOTH; | ||
84 | } | ||
85 | |||
86 | return TrimMode::UNSPECIFIED; | ||
87 | } | ||
88 | |||
89 | private function parseTrimMode(Parser $parser): void | ||
90 | { | ||
91 | $lexer = $parser->getLexer(); | ||
92 | assert($lexer->lookahead !== null); | ||
93 | $value = $lexer->lookahead->value; | ||
94 | |||
95 | if (strcasecmp('leading', $value) === 0) { | ||
96 | $parser->match(TokenType::T_LEADING); | ||
97 | |||
98 | $this->leading = true; | ||
99 | |||
100 | return; | ||
101 | } | ||
102 | |||
103 | if (strcasecmp('trailing', $value) === 0) { | ||
104 | $parser->match(TokenType::T_TRAILING); | ||
105 | |||
106 | $this->trailing = true; | ||
107 | |||
108 | return; | ||
109 | } | ||
110 | |||
111 | if (strcasecmp('both', $value) === 0) { | ||
112 | $parser->match(TokenType::T_BOTH); | ||
113 | |||
114 | $this->both = true; | ||
115 | |||
116 | return; | ||
117 | } | ||
118 | } | ||
119 | } | ||
diff --git a/vendor/doctrine/orm/src/Query/AST/Functions/UpperFunction.php b/vendor/doctrine/orm/src/Query/AST/Functions/UpperFunction.php new file mode 100644 index 0000000..1ecef66 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/AST/Functions/UpperFunction.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query\AST\Functions; | ||
6 | |||
7 | use Doctrine\ORM\Query\AST\Node; | ||
8 | use Doctrine\ORM\Query\Parser; | ||
9 | use Doctrine\ORM\Query\SqlWalker; | ||
10 | use Doctrine\ORM\Query\TokenType; | ||
11 | |||
12 | use function sprintf; | ||
13 | |||
14 | /** | ||
15 | * "UPPER" "(" StringPrimary ")" | ||
16 | * | ||
17 | * @link www.doctrine-project.org | ||
18 | */ | ||
19 | class UpperFunction extends FunctionNode | ||
20 | { | ||
21 | public Node $stringPrimary; | ||
22 | |||
23 | public function getSql(SqlWalker $sqlWalker): string | ||
24 | { | ||
25 | return sprintf( | ||
26 | 'UPPER(%s)', | ||
27 | $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | public function parse(Parser $parser): void | ||
32 | { | ||
33 | $parser->match(TokenType::T_IDENTIFIER); | ||
34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); | ||
35 | |||
36 | $this->stringPrimary = $parser->StringPrimary(); | ||
37 | |||
38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); | ||
39 | } | ||
40 | } | ||