From a820b42a2df7ded77026d5dd267eb93a65c6d8cd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 21 May 2017 12:28:38 +0200 Subject: [PATCH] improve strict option value deprecation --- UPGRADE-3.4.md | 8 ++++++++ UPGRADE-4.0.md | 3 +++ src/Symfony/Component/Validator/CHANGELOG.md | 6 ++++++ .../Component/Validator/Constraints/ChoiceValidator.php | 4 ++-- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 UPGRADE-3.4.md diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md new file mode 100644 index 0000000000..27a069cb18 --- /dev/null +++ b/UPGRADE-3.4.md @@ -0,0 +1,8 @@ +UPGRADE FROM 3.3 to 3.4 +======================= + +Validator +--------- + + * not setting the `strict` option of the `Choice` constraint to `true` is + deprecated and will throw an exception in Symfony 4.0 diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 4b040fd203..ecfd8b090e 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -507,6 +507,9 @@ TwigBridge Validator --------- + * The default value of the `strict` option of the `Choice` constraint was changed + to `true`. Using any other value will throw an exception. + * The `DateTimeValidator::PATTERN` constant was removed. * `Tests\Constraints\AbstractConstraintValidatorTest` has been removed in diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 7099496cfa..e0e132938d 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +3.4.0 +----- + + * not setting the `strict` option of the `Choice` constraint to `true` is + deprecated and will throw an exception in Symfony 4.0 + 3.3.0 ----- diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 6c81b3b4e0..ca114a4fef 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -58,8 +58,8 @@ class ChoiceValidator extends ConstraintValidator $choices = $constraint->choices; } - if (false === $constraint->strict) { - @trigger_error('Setting the strict option of the Choice constraint to false is deprecated since version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED); + if (true !== $constraint->strict) { + @trigger_error('Not setting the strict option of the Choice constraint to true is deprecated since version 3.4 and will throw an exception in 4.0.', E_USER_DEPRECATED); } if ($constraint->multiple) {