8000 [Validator] Remove deprecated code paths · symfony/symfony@65a0e1c · GitHub
[go: up one dir, main page]

Skip to content

Commit 65a0e1c

Browse files
[Validator] Remove deprecated code paths
1 parent 9e248b8 commit 65a0e1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+10
-644
lines changed

UPGRADE-7.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ Validator
127127
* Add methods `getConstraint()`, `getCause()` and `__toString()` to `ConstraintViolationInterface`
128128
* Add method `__toString()` to `ConstraintViolationListInterface`
129129
* Add method `disableTranslation()` to `ConstraintViolationBuilderInterface`
130+
* Remove static property `$errorNames` from all constraints, use const `ERROR_NAMES` instead
131+
* Remove `VALIDATION_MODE_LOOSE` from `Email` constraint, use `VALIDATION_MODE_HTML5` instead
132+
* Remove constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead
130133

131134
VarDumper
132135
---------

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

Lines changed: 0 additions & 5 deletions
< 10000 td data-grid-cell-id="diff-580bed00c9b884da104fb61d62ee451c36ef1ec4936c5a55b68aa4bd182c701b-43-41-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">43
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ class UniqueEntity extends Constraint
3939
public $errorPath;
4040
public $ignoreNull = true;
4141

42-
/**
-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
44-
*/
45-
protected static $errorNames = self::ERROR_NAMES;
46-
4742
/**
4843
* @param array|string $fields The combination of fields that must contain unique values or a set of options
4944
* @param bool|array|string $ignoreNull The combination of fields that ignore null values

src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class Form extends Constraint
2626
self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR',
2727
];
2828

29-
/**
30-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
31-
*/
32-
protected static $errorNames = self::ERROR_NAMES;
33-
3429
public function getTargets(): string|array
3530
{
3631
return self::CLASS_CONSTRAINT;

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ CHANGELOG
77
* Add methods `getConstraint()`, `getCause()` and `__toString()` to `ConstraintViolationInterface`
88
* Add method `__toString()` to `ConstraintViolationListInterface`
99
* Add method `disableTranslation()` to `ConstraintViolationBuilderInterface`
10+
* Remove static property `$errorNames` from all constraints, use const `ERROR_NAMES` instead
11+
* Remove `VALIDATION_MODE_LOOSE` from `Email` constraint, use `VALIDATION_MODE_HTML5` instead
12+
* Remove constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead
1013

1114
6.4
1215
---

src/Symfony/Component/Validator/Constraint.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ abstract class Constraint
4949
*/
5050
protected const ERROR_NAMES = [];
5151

52-
/**
53-
* @deprecated since Symfony 6.1, use protected const ERROR_NAMES instead
54-
*/
55-
protected static $errorNames = [];
56-
5752
/**
5853
* Domain-specific data attached to a constraint.
5954
*
@@ -79,13 +74,7 @@ public static function getErrorName(string $errorCode): string
7974
return static::ERROR_NAMES[$errorCode];
8075
}
8176

82-
if (!isset(static::$errorNames[$errorCode])) {
83-
throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, static::class));
84-
}
85-
86-
trigger_deprecation('symfony/validator', '6.1', 'The "%s::$errorNames" property is deprecated, use protected const ERROR_NAMES instead.', static::class);
87-
88-
return static::$errorNames[$errorCode];
77+
throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, static::class));
8978
}
9079

9180
/**

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class AtLeastOneOf extends Composite
2626
self::AT_LEAST_ONE_OF_ERROR => 'AT_LEAST_ONE_OF_ERROR',
2727
];
2828

29-
/**
30-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
31-
*/
32-
protected static $errorNames = self::ERROR_NAMES;
33-
3429
public $constraints = [];
3530
public $message = 'This value should satisfy at least one of the following constraints:';
3631
public $messageCollection = 'Each element of this collection should satisfy its own set of constraints.';

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ class Bic extends Constraint
4141
self::INVALID_CASE_ERROR => 'INVALID_CASE_ERROR',
4242
];
4343

44-
/**
45-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
46-
*/
47-
protected static $errorNames = self::ERROR_NAMES;
48-
4944
public $message = 'This is not a valid Business Identifier Code (BIC).';
5045
public $ibanMessage = 'This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.';
5146
public $iban;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ class Blank extends Constraint
2828
self::NOT_BLANK_ERROR => 'NOT_BLANK_ERROR',
2929
];
3030

31-
/**
32-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
33-
*/
34-
protected static $errorNames = self::ERROR_NAMES;
35-
3631
public $message = 'This value should be blank.';
3732

3833
public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ class CardScheme extends Constraint
4646
self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
4747
];
4848

49-
/**
50-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
51-
*/
52-
protected static $errorNames = self::ERROR_NAMES;
53-
5449
public $message = 'Unsupported card type or invalid card number.';
5550
public $schemes;
5651

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class Choice extends Constraint
3232
self::TOO_MANY_ERROR => 'TOO_MANY_ERROR',
3333
];
3434

35-
/**
36-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
37-
*/
38-
protected static $errorNames = self::ERROR_NAMES;
39-
4035
public $choices;
4136
public $callback;
4237
public $multiple = false;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class Cidr extends Constraint
4040
Ip::V6 => 128,
4141
];
4242

43-
/**
44-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
45-
*/
46-
protected static $errorNames = self::ERROR_NAMES;
47-
4843
public $version = Ip::ALL;
4944

5045
public $message = 'This value is not a valid CIDR notation.';

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class Collection extends Composite
3030
self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR',
3131
];
3232

33-
/**
34-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
35-
*/
36-
protected static $errorNames = self::ERROR_NAMES;
37-
3833
public $fields = [];
3934
public $allowExtraFields = false;
4035
public $allowMissingFields = false;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ class Count extends Constraint
3535
self::NOT_DIVISIBLE_BY_ERROR => 'NOT_DIVISIBLE_BY_ERROR',
3636
];
3737

38-
/**
39-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
40-
*/
41-
protected static $errorNames = self::ERROR_NAMES;
42-
4338
public $minMessage = 'This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.';
4439
public $maxMessage = 'This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.';
4540
public $exactMessage = 'This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements.';

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class Country extends Constraint
3030
self::NO_SUCH_COUNTRY_ERROR => 'NO_SUCH_COUNTRY_ERROR',
3131
];
3232

33-
/**
34-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
35-
*/
36-
protected static $errorNames = self::ERROR_NAMES;
37-
3833
public $message = 'This value is not a valid country.';
3934
public $alpha3 = false;
4035

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ class CssColor extends Constraint
4141
self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
4242
];
4343

44-
/**
45-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
46-
*/
47-
protected static $errorNames = self::ERROR_NAMES;
48-
4944
/**
5045
* @var string[]
5146
*/

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ class Currency extends Constraint
3131
self::NO_SUCH_CURRENCY_ERROR => 'NO_SUCH_CURRENCY_ERROR',
3232
];
3333

34-
/**
35-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
36-
*/
37-
protected static $errorNames = self::ERROR_NAMES;
38-
3934
public $message = 'This value is not a valid currency.';
4035

4136
public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class Date extends Constraint
3030
self::INVALID_DATE_ERROR => 'INVALID_DATE_ERROR',
3131
];
3232

33-
/**
34-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
35-
*/
36-
protected static $errorNames = self::ERROR_NAMES;
37-
3833
public $message = 'This value is not a valid date.';
3934

4035
public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class DateTime extends Constraint
3232
self::INVALID_TIME_ERROR => 'INVALID_TIME_ERROR',
3333
];
3434

35-
/**
36-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
37-
*/
38-
protected static $errorNames = self::ERROR_NAMES;
39-
4035
public $format = 'Y-m-d H:i:s';
4136
public $message = 'This value is not a valid datetime.';
4237

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,5 @@ class DivisibleBy extends AbstractComparison
2626
self::NOT_DIVISIBLE_BY => 'NOT_DIVISIBLE_BY',
2727
];
2828

29-
/**
30-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
31-
*/
32-
protected static $errorNames = self::ERROR_NAMES;
33-
3429
public $message = 'This value should be a multiple of {{ compared_value }}.';
3530
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,19 @@ class Email extends Constraint
2828
public const VALIDATION_MODE_HTML5_ALLOW_NO_TLD = 'html5-allow-no-tld';
2929
public const VALIDATION_MODE_HTML5 = 'html5';
3030
public const VALIDATION_MODE_STRICT = 'strict';
31-
/**
32-
* @deprecated since Symfony 6.2, use VALIDATION_MODE_HTML5 instead
33-
*/
34-
public const VALIDATION_MODE_LOOSE = 'loose';
3531

3632
public const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310';
3733

3834
public const VALIDATION_MODES = [
3935
self::VALIDATION_MODE_HTML5_ALLOW_NO_TLD,
4036
self::VALIDATION_MODE_HTML5,
4137
self::VALIDATION_MODE_STRICT,
42-
self::VALIDATION_MODE_LOOSE,
4338
];
4439

4540
protected const ERROR_NAMES = [
4641
self::INVALID_FORMAT_ERROR => 'STRICT_CHECK_FAILED_ERROR',
4742
];
4843

49-
/**
50-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
51-
*/
52-
protected static $errorNames = self::ERROR_NAMES;
53-
5444
public $message = 'This value is not a valid email address.';
5545
public $mode;
5646
public $normalizer;
@@ -73,10 +63,6 @@ public function __construct(
7363
$this->mode = $mode ?? $this->mode;
7464
$this->normalizer = $normalizer ?? $this->normalizer;
7565

76-
if (self::VALIDATION_MODE_LOOSE === $this->mode) {
77-
trigger_deprecation('symfony/validator', '6.2', 'The "%s" mode is deprecated. It will be removed in 7.0 and the default mode will be changed to "%s".', self::VALIDATION_MODE_LOOSE, self::VALIDATION_MODE_HTML5);
78-
}
79-
8066
if (self::VALIDATION_MODE_STRICT === $this->mode && !class_exists(StrictEmailValidator::class)) {
8167
throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode. Try running "composer require egulias/email-validator".', __CLASS__));
8268
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,20 @@ class EmailValidator extends ConstraintValidator
2828
{
2929
private const PATTERN_HTML5_ALLOW_NO_TLD = '/^[a-zA-Z0-9.!#$%&\'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/';
3030
private const PATTERN_HTML5 = '/^[a-zA-Z0-9.!#$%&\'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/';
31-
private const PATTERN_LOOSE = '/^.+\@\S+\.\S+$/';
3231

3332
private const EMAIL_PATTERNS = [
34-
Email::VALIDATION_MODE_LOOSE => self::PATTERN_LOOSE,
3533
Email::VALIDATION_MODE_HTML5 => self::PATTERN_HTML5,
3634
Email::VALIDATION_MODE_HTML5_ALLOW_NO_TLD => self::PATTERN_HTML5_ALLOW_NO_TLD,
3735
];
3836

3937
private string $defaultMode;
4038

41-
public function __construct(string $defaultMode = Email::VALIDATION_MODE_LOOSE)
39+
public function __construct(string $defaultMode = Email::VALIDATION_MODE_HTML5)
4240
{
4341
if (!\in_array($defaultMode, Email::VALIDATION_MODES, true)) {
4442
throw new InvalidArgumentException('The "defaultMode" parameter value is not valid.');
4543
}
4644

47-
if (Email::VALIDATION_MODE_LOOSE === $defaultMode) {
48-
trigger_deprecation('symfony/validator', '6.2', 'The "%s" mode is deprecated. It will be removed in 7.0 and the default mode will be changed to "%s".', Email::VALIDATION_MODE_LOOSE, Email::VALIDATION_MODE_HTML5);
49-
}
50-
5145
$this->defaultMode = $defaultMode;
5246
}
5347

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,5 @@ class EqualTo extends AbstractComparison
2727
self::NOT_EQUAL_ERROR => 'NOT_EQUAL_ERROR',
2828
];
2929

30-
/**
31-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
32-
*/
33-
protected static $errorNames = self::ERROR_NAMES;
34-
3530
public $message = 'This value should be equal to {{ compared_value }}.';
3631
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class Expression extends Constraint
3232
self::EXPRESSION_FAILED_ERROR => 'EXPRESSION_FAILED_ERROR',
3333
];
3434

35-
/**
36-
* @deprecated since Symfony 6.1, use const ERROR_NAMES instead
37-
*/
38-
protected static $errorNames = self::ERROR_NAMES;
39-
4035
public $message = 'This value is not valid.';
4136
public $expression;
4237
public $values = [];

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

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0