8000 feature #28842 [Validator] Deprecate checkMX and checkHost on Email v… · symfony/symfony@9bec1fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 9bec1fc

Browse files
committed
feature #28842 [Validator] Deprecate checkMX and checkHost on Email validator (fabpot)
This PR was merged into the 4.2-dev branch. Discussion ---------- [Validator] Deprecate checkMX and checkHost on Email validator | Q | A | ------------- | --- | Branch? | master | Bug fix 8000 ? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | yes | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | fixes #27559 fixes #28665 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Commits ------- c6009a0 [Validator] deprecate checkMX and checkHost on Email validator
2 parents 8199809 + c6009a0 commit 9bec1fc

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

UPGRADE-4.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ TwigBundle
261261
Validator
262262
---------
263263

264+
* The `checkMX` and `checkHost` properties of the Email constraint are deprecated
264265
* The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead
265266
* The `ValidatorBuilderInterface` has been deprecated and `ValidatorBuilder` made final
266267
* 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.

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ TwigBundle
238238
Validator
239239
--------
240240

241+
* The `checkMX` and `checkHost` properties of the Email constraint were removed
241242
* The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead.
242243
* Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead.
243244
* Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint.

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ class Email extends Constraint
2828
public const VALIDATION_MODE_LOOSE = 'loose';
2929

3030
const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310';
31+
32+
/**
33+
* @deprecated since Symfony 4.2.
34+
*/
3135
const MX_CHECK_FAILED_ERROR = 'bf447c1c-0266-4e10-9c6c-573df282e413';
36+
37+
/**
38+
* @deprecated since Symfony 4.2.
39+
*/
3240
const HOST_CHECK_FAILED_ERROR = '7da53a8b-56f3-4288-bb3e-ee9ede4ef9a1';
3341

3442
protected static $errorNames = array(
@@ -49,11 +57,19 @@ class Email extends Constraint
4957
);
5058

5159
public $message = 'This value is not a valid email address.';
60+
61+
/**
62+
* @deprecated since Symfony 4.2.
63+
*/
5264
public $checkMX = false;
65+
66+
/**
67+
* @deprecated since Symfony 4.2.
68+
*/
5369
public $checkHost = false;
5470

5571
/**
56-
* @deprecated since Symfony 4.1. Set mode to "strict" instead.
72+
* @deprecated since Symfony 4.1, set mode to "strict" instead.
5773
*/
5874
public $strict;
5975
public $mode;
@@ -64,6 +80,14 @@ public function __construct($options = null)
6480
@trigger_error(sprintf('The "strict" property is deprecated since Symfony 4.1. Use "mode"=>"%s" instead.', self::VALIDATION_MODE_STRICT), E_USER_DEPRECATED);
6581
}
6682

83+
if (\is_array($options) && array_key_exists('checkMX', $options)) {
84+
@trigger_error('The "checkMX" property is deprecated since Symfony 4.2.', E_USER_DEPRECATED);
85+
}
86+
87+
if (\is_array($options) && array_key_exists('checkHost', $options)) {
88+
@trigger_error('The "checkHost" property is deprecated since Symfony 4.2.', E_USER_DEPRECATED);
89+
}
90+
6791
if (\is_array($options) && array_key_exists('mode', $options) && !\in_array($options['mode'], self::$validationModes, true)) {
6892
throw new \InvalidArgumentException('The "mode" parameter value is not valid.');
6993
}

src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ public function getInvalidEmailsForStrictChecks()
317317
/**
318318
* @dataProvider getDnsChecks
319319
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
320+
* @group legacy
320321
*/
321322
public function testDnsChecks($type, $violation)
322323
{
@@ -353,6 +354,7 @@ public function getDnsChecks()
353354

354355
/**
355356
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
357+
* @group legacy
356358
*/
357359
public function testHostnameIsProperlyParsed()
358360
{
@@ -368,6 +370,7 @@ public function testHostnameIsProperlyParsed()
368370

369371
/**
370372
* @dataProvider provideCheckTypes
373+
* @group legacy
371374
*/
372375
public function testEmptyHostIsNotValid($checkType, $violation)
373376
{

0 commit comments

Comments
 (0)
0