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 --- .../collections/src/Expr/CompositeExpression.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 vendor/doctrine/collections/src/Expr/CompositeExpression.php (limited to 'vendor/doctrine/collections/src/Expr/CompositeExpression.php') diff --git a/vendor/doctrine/collections/src/Expr/CompositeExpression.php b/vendor/doctrine/collections/src/Expr/CompositeExpression.php new file mode 100644 index 0000000..b7b4544 --- /dev/null +++ b/vendor/doctrine/collections/src/Expr/CompositeExpression.php @@ -0,0 +1,70 @@ + */ + private array $expressions = []; + + /** + * @param Expression[] $expressions + * + * @throws RuntimeException + */ + public function __construct(private readonly string $type, array $expressions) + { + foreach ($expressions as $expr) { + if ($expr instanceof Value) { + throw new RuntimeException('Values are not supported expressions as children of and/or expressions.'); + } + + if (! ($expr instanceof Expression)) { + throw new RuntimeException('No expression given to CompositeExpression.'); + } + + $this->expressions[] = $expr; + } + + if ($type === self::TYPE_NOT && count($this->expressions) !== 1) { + throw new RuntimeException('Not expression only allows one expression as child.'); + } + } + + /** + * Returns the list of expressions nested in this composite. + * + * @return list + */ + public function getExpressionList() + { + return $this->expressions; + } + + /** @return string */ + public function getType() + { + return $this->type; + } + + /** + * {@inheritDoc} + */ + public function visit(ExpressionVisitor $visitor) + { + return $visitor->walkCompositeExpression($this); + } +} -- cgit v1.2.3