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
feature #61063 [Validator] remove support for generic constraint option handling (xabbuh)
This PR was merged into the 8.0 branch.
Discussion
----------
[Validator] remove support for generic constraint option handling
| Q | A
| ------------- | ---
| Branch? | 8.0
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues |
| License | MIT
opening the PR already even if some polishing needs to be done (and not all tests pass yet) to avoid someone else wasting their time on this topic
Commits
-------
09299fc remove support for generic constraint option handling
Copy file name to clipboardExpand all lines: UPGRADE-8.0.md
+112-1Lines changed: 112 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -489,7 +489,118 @@ Uid
489
489
Validator
490
490
---------
491
491
492
-
* Remove `Bic::INVALID_BANK_CODE_ERROR` constant. This error code was not used in the Bic constraint validator anymore.
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
+
class CustomConstraint extends Constraint
516
+
{
517
+
public function __construct(
518
+
public $option1 = null,
519
+
public $option2 = null,
520
+
?array $groups = null,
521
+
mixed $payload = null,
522
+
) {
523
+
parent::__construct(null, $groups, $payload);
524
+
}
525
+
}
526
+
```
527
+
528
+
* Remove the `getRequiredOptions()` method from the base `Constraint` class. Use mandatory constructor arguments instead.
529
+
530
+
Before:
531
+
532
+
```php
533
+
class CustomConstraint extends Constraint
534
+
{
535
+
public $option1;
536
+
public $option2;
537
+
538
+
public function __construct(?array $options = null)
539
+
{
540
+
parent::__construct($options);
541
+
}
542
+
543
+
public function getRequiredOptions()
544
+
{
545
+
return ['option1'];
546
+
}
547
+
}
548
+
```
549
+
550
+
After:
551
+
552
+
```php
553
+
class CustomConstraint extends Constraint
554
+
{
555
+
public function __construct(
556
+
public $option1,
557
+
public $option2 = null,
558
+
?array $groups = null,
559
+
mixed $payload = null,
560
+
) {
561
+
parent::__construct(null, $groups, $payload);
562
+
}
563
+
}
564
+
```
565
+
* Remove the `normalizeOptions()` and `getDefaultOption()` methods of the base `Constraint` class without replacements.
566
+
Overriding them in child constraint does not have any effects.
567
+
* Remove support for passing an array of options to the `Composite` constraint class. Initialize the properties referenced with `getNestedConstraints()`
568
+
in child classes before calling the constructor of `Composite`.
569
+
570
+
Before:
571
+
572
+
```php
573
+
class CustomCompositeConstraint extends Composite
574
+
{
575
+
public array $constraints = [];
576
+
577
+
public function __construct(?array $options = null)
578
+
{
579
+
parent::__construct($options);
580
+
}
581
+
582
+
protected function getCompositeOption(): string
583
+
{
584
+
return 'constraints';
585
+
}
586
+
}
587
+
```
588
+
589
+
After:
590
+
591
+
```php
592
+
class CustomCompositeConstraint extends Composite
593
+
{
594
+
public function __construct(
595
+
public array $constraints,
596
+
?array $groups = null,
597
+
mixed $payload = null,
598
+
) {
599
+
parent::__construct(null, $groups, $payload);
600
+
}
601
+
}
602
+
```
603
+
* Remove `Bic::INVALID_BANK_CODE_ERROR` constant. This error code was not used in the Bic constraint validator anymore
0 commit comments