Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions UPGRADE-7.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ Uid
Validator
---------

* Deprecate handling associative arrays in `GroupSequence`

*Before*

```php
$groupSequence = GroupSequence(['value' => ['group 1', 'group 2']]);
```

*After*

```php
$groupSequence = GroupSequence(['group 1', 'group 2']);
```
* Deprecate configuring constraint options implicitly with the XML format

*Before*
Expand Down
13 changes: 13 additions & 0 deletions src/Symfony/Component/Validator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ CHANGELOG
7.4
---

* Deprecate handling associative arrays in `GroupSequence`

Before:

```php
$groupSequence = GroupSequence(['value' => ['group 1', 'group 2']]);
```

After:

```php
$groupSequence = GroupSequence(['group 1', 'group 2']);
```
* Deprecate configuring constraint options implicitly with the XML format

Before:
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Validator/Constraints/GroupSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class GroupSequence
#[HasNamedArguments]
public function __construct(array $groups)
{
if (!array_is_list($groups)) {
trigger_deprecation('symfony/validator', '7.4', 'Support for passing an array of options to "%s()" is deprecated.', __METHOD__);
}

$this->groups = $groups['value'] ?? $groups;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Validator\Tests\Constraints;

use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints\GroupSequence;

Expand All @@ -26,8 +28,12 @@ public function testCreate()
$this->assertSame(['Group 1', 'Group 2'], $sequence->groups);
}

#[Group('legacy')]
#[IgnoreDeprecations]
public function testCreateDoctrineStyle()
{
$this->expectUserDeprecationMessage('Since symfony/validator 7.4: Support for passing an array of options to "Symfony\Component\Validator\Constraints\GroupSequence::__construct()" is deprecated.');

$sequence = new GroupSequence(['value' => ['Group 1', 'Group 2']]);

$this->assertSame(['Group 1', 'Group 2'], $sequence->groups);
Expand Down
Loading