Skip to content

Commit c722388

Browse files
committed
fix BC layer for Expression constraint from options array
1 parent 51ec885 commit c722388

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Symfony/Component/Validator/Constraints/Expression.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function __construct(
6464
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);
6565

6666
$options = array_merge($expression, $options ?? []);
67+
$expression = null;
6768
} else {
6869
if (\is_array($options)) {
6970
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);

src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public function testAttributes()
4141
self::assertSame('some attached data', $cConstraint->payload);
4242
self::assertFalse($cConstraint->negate);
4343
}
44+
45+
/**
46+
* @group legacy
47+
*/
48+
public function testInitializeWithOptionsArray()
49+
{
50+
$constraint = new Expression([
51+
'expression' => '!this.getParent().get("field2").getData()',
52+
]);
53+
54+
$this->assertSame('!this.getParent().get("field2").getData()', $constraint->expression);
55+
}
4456
}
4557

4658
class ExpressionDummy

0 commit comments

Comments
 (0)