Skip to content

Commit dfb3d28

Browse files
feature #61108 [DoctrineBridge][Validator] mark getRequiredOptions()/getDefaultOption() of UniqueEntity as deprecated (xabbuh)
This PR was merged into the 7.4 branch. Discussion ---------- [DoctrineBridge][Validator] mark getRequiredOptions()/getDefaultOption() of UniqueEntity as deprecated | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | | License | MIT Commits ------- ad1d373 mark getRequiredOptions()/getDefaultOption() of UniqueEntity as deprecated
2 parents 6ef731b + ad1d373 commit dfb3d28

23 files changed

+148
-10
lines changed

UPGRADE-7.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ DependencyInjection
2323

2424
* Add argument `$target` to `ContainerBuilder::registerAliasForArgument()`
2525

26+
DoctrineBridge
27+
--------------
28+
29+
* Deprecate `UniqueEntity::getRequiredOptions()` and `UniqueEntity::getDefaultOption()`
30+
2631
FrameworkBundle
2732
---------------
2833

@@ -48,6 +53,8 @@ Security
4853
Validator
4954
---------
5055

56+
* Deprecate `getRequiredOptions()` and `getDefaultOption()` methods of the `All`, `AtLeastOneOf`, `CardScheme`, `Collection`,
57+
`CssColor`, `Expression`, `Regex`, `Sequentially`, `Type`, and `When` constraints
5158
* Deprecate evaluating options in the base `Constraint` class. Initialize properties in the constructor of the concrete constraint
5259
class instead.
5360

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.4
5+
---
6+
7+
* Deprecate `UniqueEntity::getRequiredOptions()` and `UniqueEntity::getDefaultOption()`
8+
49
7.3
510
---
611

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ public function __construct(
9191
$this->identifierFieldNames = $identifierFieldNames ?? $this->identifierFieldNames;
9292
}
9393

94+
/**
95+
* @deprecated since Symfony 7.4
96+
*/
9497
public function getRequiredOptions(): array
9598
{
99+
if (0 === \func_num_args() || func_get_arg(0)) {
100+
trigger_deprecation('symfony/doctrine-bridge', '7.4', 'The %s() method is deprecated.', __METHOD__);
101+
}
102+
96103
return ['fields'];
97104
}
98105

@@ -109,8 +116,15 @@ public function getTargets(): string|array
109116
return self::CLASS_CONSTRAINT;
110117
}
111118

119+
/**
120+
* @deprecated since Symfony 7.4
121+
*/
112122
public function getDefaultOption(): ?string
113123
{
124+
if (0 === \func_num_args() || func_get_arg(0)) {
125+
trigger_deprecation('symfony/doctrine-bridge', '7.4', 'The %s() method is deprecated.', __METHOD__);
126+
}
127+
114128
return 'fields';
115129
}
116130
}

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
7.4
55
---
66

7+
* Deprecate `getRequiredOptions()` and `getDefaultOption()` methods of the `All`, `AtLeastOneOf`, `CardScheme`, `Collection`,
8+
`CssColor`, `Expression`, `Regex`, `Sequentially`, `Type`, and `When` constraints
79
* Deprecate evaluating options in the base `Constraint` class. Initialize properties in the constructor of the concrete constraint
810
class instead.
911

src/Symfony/Component/Validator/Constraint.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ public function __construct(mixed $options = null, ?array $groups = null, mixed
140140
protected function normalizeOptions(mixed $options): array
141141
{
142142
$normalizedOptions = [];
143-
$defaultOption = $this->getDefaultOption();
143+
$defaultOption = $this->getDefaultOption(false);
144144
$invalidOptions = [];
145-
$missingOptions = array_flip($this->getRequiredOptions());
145+
$missingOptions = array_flip($this->getRequiredOptions(false));
146146
$knownOptions = get_class_vars(static::class);
147147

148148
if (\is_array($options) && isset($options['value']) && !property_exists($this, 'value')) {
@@ -255,11 +255,14 @@ public function addImplicitGroupName(string $group): void
255255
* Override this method to define a default option.
256256
*
257257
* @deprecated since Symfony 7.4
258-
*
259258
* @see __construct()
260259
*/
261260
public function getDefaultOption(): ?string
262261
{
262+
if (0 === \func_num_args() || func_get_arg(0)) {
263+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
264+
}
265+
263266
return null;
264267
}
265268

@@ -271,11 +274,14 @@ public function getDefaultOption(): ?string
271274
* @return string[]
272275
*
273276
* @deprecated since Symfony 7.4
274-
*
275277
* @see __construct()
276278
*/
277279
public function getRequiredOptions(): array
278280
{
281+
if (0 === \func_num_args() || func_get_arg(0)) {
282+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
283+
}
284+
279285
return [];
280286
}
281287

src/Symfony/Component/Validator/Constraints/AbstractComparison.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function __construct(mixed $value = null, ?string $propertyPath = null, ?
6868
*/
6969
public function getDefaultOption(): ?string
7070
{
71+
if (0 === \func_num_args() || func_get_arg(0)) {
72+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
73+
}
74+
7175
return 'value';
7276
}
7377
}

src/Symfony/Component/Validator/Constraints/All.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function __construct(mixed $constraints = null, ?array $groups = null, mi
4848
*/
4949
public function getDefaultOption(): ?string
5050
{
51+
if (0 === \func_num_args() || func_get_arg(0)) {
52+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
53+
}
54+
5155
return 'constraints';
5256
}
5357

@@ -56,6 +60,10 @@ public function getDefaultOption(): ?string
5660
*/
5761
public function getRequiredOptions(): array
5862
{
63+
if (0 === \func_num_args() || func_get_arg(0)) {
64+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
65+
}
66+
5967
return ['constraints'];
6068
}
6169

src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function __construct(mixed $constraints = null, ?array $groups = null, mi
6262
*/
6363
public function getDefaultOption(): ?string
6464
{
65+
if (0 === \func_num_args() || func_get_arg(0)) {
66+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
67+
}
68+
6569
return 'constraints';
6670
}
6771

@@ -70,6 +74,10 @@ public function getDefaultOption(): ?string
7074
*/
7175
public function getRequiredOptions(): array
7276
{
77+
if (0 === \func_num_args() || func_get_arg(0)) {
78+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
79+
}
80+
7381
return ['constraints'];
7482
}
7583

src/Symfony/Component/Validator/Constraints/Callback.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public function __construct(array|string|callable|null $callback = null, ?array
6161
*/
6262
public function getDefaultOption(): ?string
6363
{
64+
if (0 === \func_num_args() || func_get_arg(0)) {
65+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
66+
}
67+
6468
return 'callback';
6569
}
6670

src/Symfony/Component/Validator/Constraints/CardScheme.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function __construct(array|string|null $schemes, ?string $message = null,
7878
*/
7979
public function getDefaultOption(): ?string
8080
{
81+
if (0 === \func_num_args() || func_get_arg(0)) {
82+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
83+
}
84+
8185
return 'schemes';
8286
}
8387

@@ -86,6 +90,10 @@ public function getDefaultOption(): ?string
8690
*/
8791
public function getRequiredOptions(): array
8892
{
93+
if (0 === \func_num_args() || func_get_arg(0)) {
94+
trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__);
95+
}
96+
8997
return ['schemes'];
9098
}
9199
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy