Skip to content

Commit 2ba67b6

Browse files
committed
flip excluded properties with keys with Doctrine-style constraint config
1 parent b0c45ec commit 2ba67b6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Constraints/Cascade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ 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+
$options['exclude'] = array_flip((array) ($options['exclude'] ?? []));
3233
} else {
3334
$this->exclude = array_flip((array) $exclude);
3435
}

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)