From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/doctrine/orm/src/Query/Expr/Andx.php | 32 ++++++++ vendor/doctrine/orm/src/Query/Expr/Base.php | 96 +++++++++++++++++++++++ vendor/doctrine/orm/src/Query/Expr/Comparison.php | 47 +++++++++++ vendor/doctrine/orm/src/Query/Expr/Composite.php | 50 ++++++++++++ vendor/doctrine/orm/src/Query/Expr/From.php | 48 ++++++++++++ vendor/doctrine/orm/src/Query/Expr/Func.php | 48 ++++++++++++ vendor/doctrine/orm/src/Query/Expr/GroupBy.php | 25 ++++++ vendor/doctrine/orm/src/Query/Expr/Join.php | 77 ++++++++++++++++++ vendor/doctrine/orm/src/Query/Expr/Literal.php | 25 ++++++ vendor/doctrine/orm/src/Query/Expr/Math.php | 59 ++++++++++++++ vendor/doctrine/orm/src/Query/Expr/OrderBy.php | 60 ++++++++++++++ vendor/doctrine/orm/src/Query/Expr/Orx.php | 32 ++++++++ vendor/doctrine/orm/src/Query/Expr/Select.php | 28 +++++++ 13 files changed, 627 insertions(+) create mode 100644 vendor/doctrine/orm/src/Query/Expr/Andx.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Base.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Comparison.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Composite.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/From.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Func.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/GroupBy.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Join.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Literal.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Math.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/OrderBy.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Orx.php create mode 100644 vendor/doctrine/orm/src/Query/Expr/Select.php (limited to 'vendor/doctrine/orm/src/Query/Expr') diff --git a/vendor/doctrine/orm/src/Query/Expr/Andx.php b/vendor/doctrine/orm/src/Query/Expr/Andx.php new file mode 100644 index 0000000..a20bcef --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Andx.php @@ -0,0 +1,32 @@ + */ + protected array $parts = []; + + /** @psalm-return list */ + public function getParts(): array + { + return $this->parts; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Base.php b/vendor/doctrine/orm/src/Query/Expr/Base.php new file mode 100644 index 0000000..e0f2572 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Base.php @@ -0,0 +1,96 @@ + */ + protected array $allowedClasses = []; + + /** @var list */ + protected array $parts = []; + + public function __construct(mixed $args = []) + { + if (is_array($args) && array_key_exists(0, $args) && is_array($args[0])) { + $args = $args[0]; + } + + $this->addMultiple($args); + } + + /** + * @param string[]|object[]|string|object $args + * @psalm-param list|string|object $args + * + * @return $this + */ + public function addMultiple(array|string|object $args = []): static + { + foreach ((array) $args as $arg) { + $this->add($arg); + } + + return $this; + } + + /** + * @return $this + * + * @throws InvalidArgumentException + */ + public function add(mixed $arg): static + { + if ($arg !== null && (! $arg instanceof self || $arg->count() > 0)) { + // If we decide to keep Expr\Base instances, we can use this check + if (! is_string($arg) && ! in_array($arg::class, $this->allowedClasses, true)) { + throw new InvalidArgumentException(sprintf( + "Expression of type '%s' not allowed in this context.", + get_debug_type($arg), + )); + } + + $this->parts[] = $arg; + } + + return $this; + } + + /** @psalm-return 0|positive-int */ + public function count(): int + { + return count($this->parts); + } + + public function __toString(): string + { + if ($this->count() === 1) { + return (string) $this->parts[0]; + } + + return $this->preSeparator . implode($this->separator, $this->parts) . $this->postSeparator; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Comparison.php b/vendor/doctrine/orm/src/Query/Expr/Comparison.php new file mode 100644 index 0000000..ec8ef21 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Comparison.php @@ -0,0 +1,47 @@ +'; + final public const LT = '<'; + final public const LTE = '<='; + final public const GT = '>'; + final public const GTE = '>='; + + /** Creates a comparison expression with the given arguments. */ + public function __construct(protected mixed $leftExpr, protected string $operator, protected mixed $rightExpr) + { + } + + public function getLeftExpr(): mixed + { + return $this->leftExpr; + } + + public function getOperator(): string + { + return $this->operator; + } + + public function getRightExpr(): mixed + { + return $this->rightExpr; + } + + public function __toString(): string + { + return $this->leftExpr . ' ' . $this->operator . ' ' . $this->rightExpr; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Composite.php b/vendor/doctrine/orm/src/Query/Expr/Composite.php new file mode 100644 index 0000000..f3007a7 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Composite.php @@ -0,0 +1,50 @@ +count() === 1) { + return (string) $this->parts[0]; + } + + $components = []; + + foreach ($this->parts as $part) { + $components[] = $this->processQueryPart($part); + } + + return implode($this->separator, $components); + } + + private function processQueryPart(string|Stringable $part): string + { + $queryPart = (string) $part; + + if (is_object($part) && $part instanceof self && $part->count() > 1) { + return $this->preSeparator . $queryPart . $this->postSeparator; + } + + // Fixes DDC-1237: User may have added a where item containing nested expression (with "OR" or "AND") + if (preg_match('/\s(OR|AND)\s/i', $queryPart)) { + return $this->preSeparator . $queryPart . $this->postSeparator; + } + + return $queryPart; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/From.php b/vendor/doctrine/orm/src/Query/Expr/From.php new file mode 100644 index 0000000..21af078 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/From.php @@ -0,0 +1,48 @@ +from; + } + + public function getAlias(): string + { + return $this->alias; + } + + public function getIndexBy(): string|null + { + return $this->indexBy; + } + + public function __toString(): string + { + return $this->from . ' ' . $this->alias . + ($this->indexBy ? ' INDEX BY ' . $this->indexBy : ''); + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Func.php b/vendor/doctrine/orm/src/Query/Expr/Func.php new file mode 100644 index 0000000..cd9e8e0 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Func.php @@ -0,0 +1,48 @@ +|mixed $arguments + */ + public function __construct( + protected string $name, + mixed $arguments, + ) { + $this->arguments = (array) $arguments; + } + + public function getName(): string + { + return $this->name; + } + + /** @psalm-return list */ + public function getArguments(): array + { + return $this->arguments; + } + + public function __toString(): string + { + return $this->name . '(' . implode(', ', $this->arguments) . ')'; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/GroupBy.php b/vendor/doctrine/orm/src/Query/Expr/GroupBy.php new file mode 100644 index 0000000..fa4625a --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/GroupBy.php @@ -0,0 +1,25 @@ + */ + protected array $parts = []; + + /** @psalm-return list */ + public function getParts(): array + { + return $this->parts; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Join.php b/vendor/doctrine/orm/src/Query/Expr/Join.php new file mode 100644 index 0000000..c3b6dc9 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Join.php @@ -0,0 +1,77 @@ +joinType; + } + + public function getJoin(): string + { + return $this->join; + } + + public function getAlias(): string|null + { + return $this->alias; + } + + /** @psalm-return self::ON|self::WITH|null */ + public function getConditionType(): string|null + { + return $this->conditionType; + } + + public function getCondition(): string|Comparison|Composite|Func|null + { + return $this->condition; + } + + public function getIndexBy(): string|null + { + return $this->indexBy; + } + + public function __toString(): string + { + return strtoupper($this->joinType) . ' JOIN ' . $this->join + . ($this->alias ? ' ' . $this->alias : '') + . ($this->indexBy ? ' INDEX BY ' . $this->indexBy : '') + . ($this->condition ? ' ' . strtoupper($this->conditionType) . ' ' . $this->condition : ''); + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Literal.php b/vendor/doctrine/orm/src/Query/Expr/Literal.php new file mode 100644 index 0000000..0c13030 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Literal.php @@ -0,0 +1,25 @@ + */ + protected array $parts = []; + + /** @psalm-return list */ + public function getParts(): array + { + return $this->parts; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Math.php b/vendor/doctrine/orm/src/Query/Expr/Math.php new file mode 100644 index 0000000..05e0b39 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Math.php @@ -0,0 +1,59 @@ +leftExpr; + } + + public function getOperator(): string + { + return $this->operator; + } + + public function getRightExpr(): mixed + { + return $this->rightExpr; + } + + public function __toString(): string + { + // Adjusting Left Expression + $leftExpr = (string) $this->leftExpr; + + if ($this->leftExpr instanceof Math) { + $leftExpr = '(' . $leftExpr . ')'; + } + + // Adjusting Right Expression + $rightExpr = (string) $this->rightExpr; + + if ($this->rightExpr instanceof Math) { + $rightExpr = '(' . $rightExpr . ')'; + } + + return $leftExpr . ' ' . $this->operator . ' ' . $rightExpr; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/OrderBy.php b/vendor/doctrine/orm/src/Query/Expr/OrderBy.php new file mode 100644 index 0000000..ac9e160 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/OrderBy.php @@ -0,0 +1,60 @@ + */ + protected array $parts = []; + + public function __construct( + string|null $sort = null, + string|null $order = null, + ) { + if ($sort) { + $this->add($sort, $order); + } + } + + public function add(string $sort, string|null $order = null): void + { + $order = ! $order ? 'ASC' : $order; + $this->parts[] = $sort . ' ' . $order; + } + + /** @psalm-return 0|positive-int */ + public function count(): int + { + return count($this->parts); + } + + /** @psalm-return list */ + public function getParts(): array + { + return $this->parts; + } + + public function __toString(): string + { + return $this->preSeparator . implode($this->separator, $this->parts) . $this->postSeparator; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Orx.php b/vendor/doctrine/orm/src/Query/Expr/Orx.php new file mode 100644 index 0000000..2ae2332 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Orx.php @@ -0,0 +1,32 @@ + */ + protected array $parts = []; + + /** @psalm-return list */ + public function getParts(): array + { + return $this->parts; + } +} diff --git a/vendor/doctrine/orm/src/Query/Expr/Select.php b/vendor/doctrine/orm/src/Query/Expr/Select.php new file mode 100644 index 0000000..91b0b60 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Expr/Select.php @@ -0,0 +1,28 @@ + */ + protected array $parts = []; + + /** @psalm-return list */ + public function getParts(): array + { + return $this->parts; + } +} -- cgit v1.2.3