diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index f04124d9bc..9841f30ee2 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -261,6 +261,7 @@ TwigBundle Validator --------- + * The `checkMX` and `checkHost` properties of the Email constraint are deprecated * The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead * The `ValidatorBuilderInterface` has been deprecated and `ValidatorBuilder` made final * Deprecated validating instances of `\DateTimeInterface` in `DateTimeValidator`, `DateValidator` and `TimeValidator`. Use `Type` instead or remove the constraint if the underlying model is type hinted to `\DateTimeInterface` already. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 80403f038d..3093f28b2a 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -238,6 +238,7 @@ TwigBundle Validator -------- + * The `checkMX` and `checkHost` properties of the Email constraint were removed * The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead. * Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead. * Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint. diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index b98b00a905..686c9ad1e7 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -28,7 +28,15 @@ class Email extends Constraint public const VALIDATION_MODE_LOOSE = 'loose'; const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310'; + + /** + * @deprecated since Symfony 4.2. + */ const MX_CHECK_FAILED_ERROR = 'bf447c1c-0266-4e10-9c6c-573df282e413'; + + /** + * @deprecated since Symfony 4.2. + */ const HOST_CHECK_FAILED_ERROR = '7da53a8b-56f3-4288-bb3e-ee9ede4ef9a1'; protected static $errorNames = array( @@ -49,11 +57,19 @@ class Email extends Constraint ); public $message = 'This value is not a valid email address.'; + + /** + * @deprecated since Symfony 4.2. + */ public $checkMX = false; + + /** + * @deprecated since Symfony 4.2. + */ public $checkHost = false; /** - * @deprecated since Symfony 4.1. Set mode to "strict" instead. + * @deprecated since Symfony 4.1, set mode to "strict" instead. */ public $strict; public $mode; @@ -64,6 +80,14 @@ class Email extends Constraint @trigger_error(sprintf('The "strict" property is deprecated since Symfony 4.1. Use "mode"=>"%s" instead.', self::VALIDATION_MODE_STRICT), E_USER_DEPRECATED); } + if (\is_array($options) && array_key_exists('checkMX', $options)) { + @trigger_error('The "checkMX" property is deprecated since Symfony 4.2.', E_USER_DEPRECATED); + } + + if (\is_array($options) && array_key_exists('checkHost', $options)) { + @trigger_error('The "checkHost" property is deprecated since Symfony 4.2.', E_USER_DEPRECATED); + } + if (\is_array($options) && array_key_exists('mode', $options) && !\in_array($options['mode'], self::$validationModes, true)) { throw new \InvalidArgumentException('The "mode" parameter value is not valid.'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index e8e9cfc0db..5f3353bc5f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -317,6 +317,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase /** * @dataProvider getDnsChecks * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts + * @group legacy */ public function testDnsChecks($type, $violation) { @@ -353,6 +354,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase /** * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts + * @group legacy */ public function testHostnameIsProperlyParsed() { @@ -368,6 +370,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase /** * @dataProvider provideCheckTypes + * @group legacy */ public function testEmptyHostIsNotValid($checkType, $violation) {