diff --git a/UPGRADE-7.4.md b/UPGRADE-7.4.md index f3ad2e7d88918..e496e069e72ba 100644 --- a/UPGRADE-7.4.md +++ b/UPGRADE-7.4.md @@ -23,6 +23,11 @@ DependencyInjection * Add argument `$target` to `ContainerBuilder::registerAliasForArgument()` +DoctrineBridge +-------------- + + * Deprecate `UniqueEntity::getRequiredOptions()` and `UniqueEntity::getDefaultOption()` + FrameworkBundle --------------- @@ -48,6 +53,8 @@ Security Validator --------- + * Deprecate `getRequiredOptions()` and `getDefaultOption()` methods of the `All`, `AtLeastOneOf`, `CardScheme`, `Collection`, + `CssColor`, `Expression`, `Regex`, `Sequentially`, `Type`, and `When` constraints * Deprecate evaluating options in the base `Constraint` class. Initialize properties in the constructor of the concrete constraint class instead. diff --git a/src/Symfony/Bridge/Doctrine/CHANGELOG.md b/src/Symfony/Bridge/Doctrine/CHANGELOG.md index 961a0965d3431..3caa01a002787 100644 --- a/src/Symfony/Bridge/Doctrine/CHANGELOG.md +++ b/src/Symfony/Bridge/Doctrine/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.4 +--- + + * Deprecate `UniqueEntity::getRequiredOptions()` and `UniqueEntity::getDefaultOption()` + 7.3 --- diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php index b2c1b3b377552..26ab883ed6a0f 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php @@ -91,8 +91,15 @@ public function __construct( $this->identifierFieldNames = $identifierFieldNames ?? $this->identifierFieldNames; } + /** + * @deprecated since Symfony 7.4 + */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/doctrine-bridge', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['fields']; } @@ -109,8 +116,15 @@ public function getTargets(): string|array return self::CLASS_CONSTRAINT; } + /** + * @deprecated since Symfony 7.4 + */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/doctrine-bridge', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'fields'; } } diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 8d1fc55e6f3d8..dc7c083bcee8a 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -4,6 +4,8 @@ CHANGELOG 7.4 --- + * Deprecate `getRequiredOptions()` and `getDefaultOption()` methods of the `All`, `AtLeastOneOf`, `CardScheme`, `Collection`, + `CssColor`, `Expression`, `Regex`, `Sequentially`, `Type`, and `When` constraints * Deprecate evaluating options in the base `Constraint` class. Initialize properties in the constructor of the concrete constraint class instead. diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index 17d8cc3131b3c..5563500ebd795 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -140,9 +140,9 @@ public function __construct(mixed $options = null, ?array $groups = null, mixed protected function normalizeOptions(mixed $options): array { $normalizedOptions = []; - $defaultOption = $this->getDefaultOption(); + $defaultOption = $this->getDefaultOption(false); $invalidOptions = []; - $missingOptions = array_flip($this->getRequiredOptions()); + $missingOptions = array_flip($this->getRequiredOptions(false)); $knownOptions = get_class_vars(static::class); if (\is_array($options) && isset($options['value']) && !property_exists($this, 'value')) { @@ -255,11 +255,14 @@ public function addImplicitGroupName(string $group): void * Override this method to define a default option. * * @deprecated since Symfony 7.4 - * * @see __construct() */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return null; } @@ -271,11 +274,14 @@ public function getDefaultOption(): ?string * @return string[] * * @deprecated since Symfony 7.4 - * * @see __construct() */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return []; } diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparison.php b/src/Symfony/Component/Validator/Constraints/AbstractComparison.php index 523a812960a26..586a23ef47d9e 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparison.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparison.php @@ -68,6 +68,10 @@ public function __construct(mixed $value = null, ?string $propertyPath = null, ? */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'value'; } } diff --git a/src/Symfony/Component/Validator/Constraints/All.php b/src/Symfony/Component/Validator/Constraints/All.php index b1a477782a2a7..4b36ead8ca8e9 100644 --- a/src/Symfony/Component/Validator/Constraints/All.php +++ b/src/Symfony/Component/Validator/Constraints/All.php @@ -48,6 +48,10 @@ public function __construct(mixed $constraints = null, ?array $groups = null, mi */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'constraints'; } @@ -56,6 +60,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['constraints']; } diff --git a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php b/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php index c988726aef8df..dc6e73f1cac21 100644 --- a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php +++ b/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php @@ -62,6 +62,10 @@ public function __construct(mixed $constraints = null, ?array $groups = null, mi */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'constraints'; } @@ -70,6 +74,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['constraints']; } diff --git a/src/Symfony/Component/Validator/Constraints/Callback.php b/src/Symfony/Component/Validator/Constraints/Callback.php index 3afe2a1a563dd..f11f4c37f37ae 100644 --- a/src/Symfony/Component/Validator/Constraints/Callback.php +++ b/src/Symfony/Component/Validator/Constraints/Callback.php @@ -61,6 +61,10 @@ public function __construct(array|string|callable|null $callback = null, ?array */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'callback'; } diff --git a/src/Symfony/Component/Validator/Constraints/CardScheme.php b/src/Symfony/Component/Validator/Constraints/CardScheme.php index 7d2b76951ee22..75d137c63966b 100644 --- a/src/Symfony/Component/Validator/Constraints/CardScheme.php +++ b/src/Symfony/Component/Validator/Constraints/CardScheme.php @@ -78,6 +78,10 @@ public function __construct(array|string|null $schemes, ?string $message = null, */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'schemes'; } @@ -86,6 +90,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['schemes']; } } diff --git a/src/Symfony/Component/Validator/Constraints/Choice.php b/src/Symfony/Component/Validator/Constraints/Choice.php index 3849bbf17d30d..8bc380735d1c4 100644 --- a/src/Symfony/Component/Validator/Constraints/Choice.php +++ b/src/Symfony/Component/Validator/Constraints/Choice.php @@ -50,6 +50,10 @@ class Choice extends Constraint */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'choices'; } diff --git a/src/Symfony/Component/Validator/Constraints/Collection.php b/src/Symfony/Component/Validator/Constraints/Collection.php index c0fc237f047c2..91bcbfd753da2 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -83,6 +83,10 @@ protected function initializeNestedConstraints(): void */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['fields']; } diff --git a/src/Symfony/Component/Validator/Constraints/CssColor.php b/src/Symfony/Component/Validator/Constraints/CssColor.php index 1a8cfd0dad1db..1c23a6df62d40 100644 --- a/src/Symfony/Component/Validator/Constraints/CssColor.php +++ b/src/Symfony/Component/Validator/Constraints/CssColor.php @@ -103,6 +103,10 @@ public function __construct(array|string $formats = [], ?string $message = null, */ public function getDefaultOption(): string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'formats'; } @@ -111,6 +115,10 @@ public function getDefaultOption(): string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['formats']; } } diff --git a/src/Symfony/Component/Validator/Constraints/DateTime.php b/src/Symfony/Component/Validator/Constraints/DateTime.php index 96e7493ea6019..3cf906269e73f 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTime.php +++ b/src/Symfony/Component/Validator/Constraints/DateTime.php @@ -68,6 +68,10 @@ public function __construct(string|array|null $format = null, ?string $message = */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'format'; } } diff --git a/src/Symfony/Component/Validator/Constraints/Existence.php b/src/Symfony/Component/Validator/Constraints/Existence.php index a31d744464bda..a867f09e58307 100644 --- a/src/Symfony/Component/Validator/Constraints/Existence.php +++ b/src/Symfony/Component/Validator/Constraints/Existence.php @@ -36,6 +36,10 @@ public function __construct(mixed $constraints = null, ?array $groups = null, mi */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'constraints'; } diff --git a/src/Symfony/Component/Validator/Constraints/Expression.php b/src/Symfony/Component/Validator/Constraints/Expression.php index a04df9fd3e33d..7298b297f3d6c 100644 --- a/src/Symfony/Component/Validator/Constraints/Expression.php +++ b/src/Symfony/Component/Validator/Constraints/Expression.php @@ -86,6 +86,10 @@ public function __construct( */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'expression'; } @@ -94,6 +98,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['expression']; } diff --git a/src/Symfony/Component/Validator/Constraints/Isbn.php b/src/Symfony/Component/Validator/Constraints/Isbn.php index 471a39ca8d3f5..7e34cb53bd07c 100644 --- a/src/Symfony/Component/Validator/Constraints/Isbn.php +++ b/src/Symfony/Component/Validator/Constraints/Isbn.php @@ -89,6 +89,10 @@ public function __construct( */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'type'; } } diff --git a/src/Symfony/Component/Validator/Constraints/Regex.php b/src/Symfony/Component/Validator/Constraints/Regex.php index 0881ae0b35fc9..df1b386be9491 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -83,6 +83,10 @@ public function __construct( */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'pattern'; } @@ -91,6 +95,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['pattern']; } diff --git a/src/Symfony/Component/Validator/Constraints/Sequentially.php b/src/Symfony/Component/Validator/Constraints/Sequentially.php index f695204b1c06c..e72e58170c854 100644 --- a/src/Symfony/Component/Validator/Constraints/Sequentially.php +++ b/src/Symfony/Component/Validator/Constraints/Sequentially.php @@ -47,6 +47,10 @@ public function __construct(mixed $constraints = null, ?array $groups = null, mi */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'constraints'; } @@ -55,6 +59,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['constraints']; } diff --git a/src/Symfony/Component/Validator/Constraints/Timezone.php b/src/Symfony/Component/Validator/Constraints/Timezone.php index 66734faf45c9d..193b35eeb2cdd 100644 --- a/src/Symfony/Component/Validator/Constraints/Timezone.php +++ b/src/Symfony/Component/Validator/Constraints/Timezone.php @@ -96,6 +96,10 @@ public function __construct( */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'zone'; } } diff --git a/src/Symfony/Component/Validator/Constraints/Traverse.php b/src/Symfony/Component/Validator/Constraints/Traverse.php index fa63624f6bc94..63e8462c43ac0 100644 --- a/src/Symfony/Component/Validator/Constraints/Traverse.php +++ b/src/Symfony/Component/Validator/Constraints/Traverse.php @@ -51,6 +51,10 @@ public function __construct(bool|array|null $traverse = null, mixed $payload = n */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'traverse'; } diff --git a/src/Symfony/Component/Validator/Constraints/Type.php b/src/Symfony/Component/Validator/Constraints/Type.php index 1c8ded6aa6951..7e07a6fcb7f43 100644 --- a/src/Symfony/Component/Validator/Constraints/Type.php +++ b/src/Symfony/Component/Validator/Constraints/Type.php @@ -63,6 +63,10 @@ public function __construct(string|array|null $type, ?string $message = null, ?a */ public function getDefaultOption(): ?string { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return 'type'; } @@ -71,6 +75,10 @@ public function getDefaultOption(): ?string */ public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['type']; } } diff --git a/src/Symfony/Component/Validator/Constraints/When.php b/src/Symfony/Component/Validator/Constraints/When.php index cafdec08d101a..58293f3f3277a 100644 --- a/src/Symfony/Component/Validator/Constraints/When.php +++ b/src/Symfony/Component/Validator/Constraints/When.php @@ -31,12 +31,12 @@ class When extends Composite public array|Constraint $otherwise = []; /** - * @param string|Expression|array|\Closure(object): bool $expression The condition to evaluate, either as a closure or using the ExpressionLanguage syntax - * @param Constraint[]|Constraint|null $constraints One or multiple constraints that are applied if the expression returns true - * @param array|null $values The values of the custom variables used in the expression (defaults to []) - * @param string[]|null $groups - * @param array|null $options - * @param Constraint[]|Constraint $otherwise One or multiple constraints that are applied if the expression returns false + * @param string|Expression|array|\Closure(object): bool $expression The condition to evaluate, either as a closure or using the ExpressionLanguage syntax + * @param Constraint[]|Constraint|null $constraints One or multiple constraints that are applied if the expression returns true + * @param array|null $values The values of the custom variables used in the expression (defaults to []) + * @param string[]|null $groups + * @param array|null $options + * @param Constraint[]|Constraint $otherwise One or multiple constraints that are applied if the expression returns false */ #[HasNamedArguments] public function __construct(string|Expression|array|\Closure $expression, array|Constraint|null $constraints = null, ?array $values = null, ?array $groups = null, $payload = null, ?array $options = null, array|Constraint $otherwise = []) @@ -78,6 +78,10 @@ public function __construct(string|Expression|array|\Closure $expression, array| public function getRequiredOptions(): array { + if (0 === \func_num_args() || func_get_arg(0)) { + trigger_deprecation('symfony/validator', '7.4', 'The %s() method is deprecated.', __METHOD__); + } + return ['expression', 'constraints']; } 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