Skip to content

Commit 5815a82

Browse files
committed
flip excluded properties with keys with Doctrine-style constraint config
1 parent ac67b6a commit 5815a82

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public function __construct(array|string|null $exclude = null, ?array $options =
2929
{
3030
if (\is_array($exclude) && !array_is_list($exclude)) {
3131
$options = array_merge($exclude, $options ?? []);
32+
33+
if (isset($options['exclude'])) {
34+
$options['exclude'] = array_flip((array) $options['exclude']);
35+
}
3236
} else {
3337
$this->exclude = array_flip((array) $exclude);
3438
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ public function testCascadeAttribute()
2727
self::assertTrue($loader->loadClassMetadata($metadata));
2828
self::assertSame(CascadingStrategy::CASCADE, $metadata->getCascadingStrategy());
2929
}
30+
31+
public function testExcludeProperties()
32+
{
33+
$constraint = new Cascade(['foo', 'bar']);
34+
35+
self::assertSame(['foo' => 0, 'bar' => 1], $constraint->exclude);
36+
}
37+
38+
public function testExcludePropertiesDoctrineStyle()
39+
{
40+
$constraint = new Cascade(['exclude' => ['foo', 'bar']]);
41+
42+
self::assertSame(['foo' => 0, 'bar' => 1], $constraint->exclude);
43+
}
3044
}
3145

3246
#[Cascade]

0 commit comments

Comments
 (0)
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