Skip to content

Commit 4798a3b

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Validator] Allow Sequence constraint to be applied onto class as an attribute Try making tests a bit less transient Fix CI on macos-11 [Serializer] Fix denormalizing custom class in UidNormalizer [Config] In XmlUtils, avoid converting from octal every string starting with a 0 Make RateLimiter resilient to timeShifting
2 parents 517c9b1 + 19b1fd3 commit 4798a3b

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

Constraints/Sequentially.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Maxime Steinhausser <[email protected]>
2222
*/
23-
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
23+
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
2424
class Sequentially extends Composite
2525
{
2626
public $constraints = [];

Tests/Fixtures/Annotation/Entity.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* @Symfony\Component\Validator\Tests\Fixtures\ConstraintA
2020
* @Assert\GroupSequence({"Foo", "Entity"})
2121
* @Assert\Callback({"Symfony\Component\Validator\Tests\Fixtures\CallbackClass", "callback"})
22+
* @Assert\Sequentially({
23+
* @Assert\Expression("this.getFirstName() != null")
24+
* })
2225
*/
2326
class Entity extends EntityParent implements EntityInterfaceB
2427
{

Tests/Fixtures/Attribute/Entity.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
Assert\GroupSequence(['Foo', 'Entity']),
2323
Assert\Callback([CallbackClass::class, 'callback']),
2424
]
25+
/**
26+
* @Assert\Sequentially({
27+
* @Assert\Expression("this.getFirstName() != null")
28+
* })
29+
*/
2530
class Entity extends EntityParent implements EntityInterfaceB
2631
{
2732
/**

Tests/Fixtures/NestedAttribute/Entity.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
ConstraintA,
2323
Assert\GroupSequence(['Foo', 'Entity']),
2424
Assert\Callback([CallbackClass::class, 'callback']),
25+
Assert\Sequentially([
26+
new Assert\Expression('this.getFirstName() != null')
27+
])
2528
]
2629
class Entity extends EntityParent implements EntityInterfaceB
2730
{

Tests/Mapping/Loader/AnnotationLoaderTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Validator\Constraints\Choice;
2020
use Symfony\Component\Validator\Constraints\Collection;
2121
use Symfony\Component\Validator\Constraints\Email;
22+
use Symfony\Component\Validator\Constraints\Expression;
2223
use Symfony\Component\Validator\Constraints\IsTrue;
2324
use Symfony\Component\Validator\Constraints\NotBlank;
2425
use Symfony\Component\Validator\Constraints\NotNull;
@@ -65,6 +66,9 @@ public function testLoadClassMetadata(string $namespace)
6566
$expected->setGroupSequence(['Foo', 'Entity']);
6667
$expected->addConstraint(new ConstraintA());
6768
$expected->addConstraint(new Callback(['Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback']));
69+
$expected->addConstraint(new Sequentially([
70+
new Expression('this.getFirstName() != null'),
71+
]));
6872
$expected->addConstraint(new Callback(['callback' => 'validateMe', 'payload' => 'foo']));
6973
$expected->addConstraint(new Callback('validateMeStatic'));
7074
$expected->addPropertyConstraint('firstName', new NotNull());
@@ -151,6 +155,9 @@ public function testLoadClassMetadataAndMerge(string $namespace)
151155
$expected->setGroupSequence(['Foo', 'Entity']);
152156
$expected->addConstraint(new ConstraintA());
153157
$expected->addConstraint(new Callback(['Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback']));
158+
$expected->addConstraint(new Sequentially([
159+
new Expression('this.getFirstName() != null'),
160+
]));
154161
$expected->addConstraint(new Callback(['callback' => 'validateMe', 'payload' => 'foo']));
155162
$expected->addConstraint(new Callback('validateMeStatic'));
156163
$expected->addPropertyConstraint('firstName', new NotNull());

0 commit comments

Comments
 (0)