You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADE-8.0.md
+125Lines changed: 125 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -489,6 +489,131 @@ Uid
489
489
Validator
490
490
---------
491
491
492
+
* Remove the `getRequiredOptions()` and `getDefaultOption()` methods from the `All`, `AtLeastOneOf`, `CardScheme`, `Collection`,
493
+
`CssColor`, `Expression`, `Regex`, `Sequentially`, `Type`, and `When` constraints
494
+
* Remove support for evaluating options in the base `Constraint` class. Initialize properties in the constructor of the concrete constraint
495
+
class instead.
496
+
497
+
Before:
498
+
499
+
```php
500
+
class CustomConstraint extends Constraint
501
+
{
502
+
public $option1;
503
+
public $option2;
504
+
505
+
public function __construct(?array $options = null)
506
+
{
507
+
parent::__construct($options);
508
+
}
509
+
}
510
+
```
511
+
512
+
After:
513
+
514
+
```php
515
+
use Symfony\Component\Validator\Attribute\HasNamedArguments;
516
+
517
+
class CustomConstraint extends Constraint
518
+
{
519
+
public $option1;
520
+
public $option2;
521
+
522
+
#[HasNamedArguments]
523
+
public function __construct($option1 = null, $option2 = null, ?array $groups = null, mixed $payload = null)
524
+
{
525
+
parent::__construct(null, $groups, $payload);
526
+
527
+
$this->option1 = $option1;
528
+
$this->option2 = $option2;
529
+
}
530
+
}
531
+
```
532
+
533
+
* Remove the `getRequiredOptions()` method from the base `Constraint` class. Use mandatory constructor arguments instead.
534
+
535
+
Before:
536
+
537
+
```php
538
+
class CustomConstraint extends Constraint
539
+
{
540
+
public $option1;
541
+
public $option2;
542
+
543
+
public function __construct(?array $options = null)
544
+
{
545
+
parent::__construct($options);
546
+
}
547
+
548
+
public function getRequiredOptions()
549
+
{
550
+
return ['option1'];
551
+
}
552
+
}
553
+
```
554
+
555
+
After:
556
+
557
+
```php
558
+
use Symfony\Component\Validator\Attribute\HasNamedArguments;
559
+
560
+
class CustomConstraint extends Constraint
561
+
{
562
+
public $option1;
563
+
public $option2;
564
+
565
+
#[HasNamedArguments]
566
+
public function __construct($option1, $option2 = null, ?array $groups = null, mixed $payload = null)
567
+
{
568
+
parent::__construct(null, $groups, $payload);
569
+
570
+
$this->option1 = $option1;
571
+
$this->option2 = $option2;
572
+
}
573
+
}
574
+
```
575
+
* Remove the `normalizeOptions()` and `getDefaultOption()` methods of the base `Constraint` class without replacements.
576
+
Overriding them in child constraint does not have any effects.
577
+
* Remove support for passing an array of options to the `Composite` constraint class. Initialize the properties referenced with `getNestedConstraints()`
578
+
in child classes before calling the constructor of `Composite`.
579
+
580
+
Before:
581
+
582
+
```php
583
+
class CustomCompositeConstraint extends Composite
584
+
{
585
+
public array $constraints = [];
586
+
587
+
public function __construct(?array $options = null)
588
+
{
589
+
parent::__construct($options);
590
+
}
591
+
592
+
protected function getCompositeOption(): string
593
+
{
594
+
return 'constraints';
595
+
}
596
+
}
597
+
```
598
+
599
+
After:
600
+
601
+
```php
602
+
use Symfony\Component\Validator\Attribute\HasNamedArguments;
603
+
604
+
class CustomCompositeConstraint extends Composite
605
+
{
606
+
public array $constraints = [];
607
+
608
+
#[HasNamedArguments]
609
+
public function __construct(array $constraints, ?array $groups = null, mixed $payload = null)
610
+
{
611
+
$this->constraints = $constraints;
612
+
613
+
parent::__construct(null, $groups, $payload);
614
+
}
615
+
}
616
+
```
492
617
* Remove `Bic::INVALID_BANK_CODE_ERROR` constant. This error code was not used in the Bic constraint validator anymore.
0 commit comments