From c722388a8b7deb8f63c2c84c5c726a2e47bf3d4f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 10 Jul 2025 08:20:22 +0200 Subject: [PATCH] fix BC layer for Expression constraint from options array --- .../Component/Validator/Constraints/Expression.php | 1 + .../Validator/Tests/Constraints/ExpressionTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Symfony/Component/Validator/Constraints/Expression.php b/src/Symfony/Component/Validator/Constraints/Expression.php index 783108b430282..a04df9fd3e33d 100644 --- a/src/Symfony/Component/Validator/Constraints/Expression.php +++ b/src/Symfony/Component/Validator/Constraints/Expression.php @@ -64,6 +64,7 @@ public function __construct( trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class); $options = array_merge($expression, $options ?? []); + $expression = null; } else { if (\is_array($options)) { trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php index 89db330b99c55..f702d9fa4527a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php @@ -41,6 +41,18 @@ public function testAttributes() self::assertSame('some attached data', $cConstraint->payload); self::assertFalse($cConstraint->negate); } + + /** + * @group legacy + */ + public function testInitializeWithOptionsArray() + { + $constraint = new Expression([ + 'expression' => '!this.getParent().get("field2").getData()', + ]); + + $this->assertSame('!this.getParent().get("field2").getData()', $constraint->expression); + } } class ExpressionDummy pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy