diff --git a/UPGRADE-7.0.md b/UPGRADE-7.0.md index 4c294b66bffc8..89f997db27806 100644 --- a/UPGRADE-7.0.md +++ b/UPGRADE-7.0.md @@ -127,6 +127,9 @@ Validator * Add methods `getConstraint()`, `getCause()` and `__toString()` to `ConstraintViolationInterface` * Add method `__toString()` to `ConstraintViolationListInterface` * Add method `disableTranslation()` to `ConstraintViolationBuilderInterface` + * Remove static property `$errorNames` from all constraints, use const `ERROR_NAMES` instead + * Remove `VALIDATION_MODE_LOOSE` from `Email` constraint, use `VALIDATION_MODE_HTML5` instead + * Remove constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead VarDumper --------- diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php index 2dd5c7125aa2d..14d7b39d162ed 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php @@ -39,11 +39,6 @@ class UniqueEntity extends Constraint public $errorPath; public $ignoreNull = true; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - /** * @param array|string $fields The combination of fields that must contain unique values or a set of options * @param bool|array|string $ignoreNull The combination of fields that ignore null values diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php index 6dec01be224e6..8be25c0b8bd8a 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php @@ -26,11 +26,6 @@ class Form extends Constraint self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public function getTargets(): string|array { return self::CLASS_CONSTRAINT; diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 0f0879cdfbed3..836caf31aba1a 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -7,6 +7,9 @@ CHANGELOG * Add methods `getConstraint()`, `getCause()` and `__toString()` to `ConstraintViolationInterface` * Add method `__toString()` to `ConstraintViolationListInterface` * Add method `disableTranslation()` to `ConstraintViolationBuilderInterface` + * Remove static property `$errorNames` from all constraints, use const `ERROR_NAMES` instead + * Remove `VALIDATION_MODE_LOOSE` from `Email` constraint, use `VALIDATION_MODE_HTML5` instead + * Remove constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead 6.4 --- diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index d53bbb196fa49..8156c99196bf0 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -49,11 +49,6 @@ abstract class Constraint */ protected const ERROR_NAMES = []; - /** - * @deprecated since Symfony 6.1, use protected const ERROR_NAMES instead - */ - protected static $errorNames = []; - /** * Domain-specific data attached to a constraint. * @@ -79,13 +74,7 @@ public static function getErrorName(string $errorCode): string return static::ERROR_NAMES[$errorCode]; } - if (!isset(static::$errorNames[$errorCode])) { - throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, static::class)); - } - - trigger_deprecation('symfony/validator', '6.1', 'The "%s::$errorNames" property is deprecated, use protected const ERROR_NAMES instead.', static::class); - - return static::$errorNames[$errorCode]; + throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, static::class)); } /** diff --git a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php b/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php index 33ed343af7aee..48469d877ef7a 100644 --- a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php +++ b/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php @@ -26,11 +26,6 @@ class AtLeastOneOf extends Composite self::AT_LEAST_ONE_OF_ERROR => 'AT_LEAST_ONE_OF_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $constraints = []; public $message = 'This value should satisfy at least one of the following constraints:'; public $messageCollection = 'Each element of this collection should satisfy its own set of constraints.'; diff --git a/src/Symfony/Component/Validator/Constraints/Bic.php b/src/Symfony/Component/Validator/Constraints/Bic.php index 855ab348db8da..d976dd0a38d89 100644 --- a/src/Symfony/Component/Validator/Constraints/Bic.php +++ b/src/Symfony/Component/Validator/Constraints/Bic.php @@ -41,11 +41,6 @@ class Bic extends Constraint self::INVALID_CASE_ERROR => 'INVALID_CASE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This is not a valid Business Identifier Code (BIC).'; public $ibanMessage = 'This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.'; public $iban; diff --git a/src/Symfony/Component/Validator/Constraints/Blank.php b/src/Symfony/Component/Validator/Constraints/Blank.php index bd28e68bc81f5..a7e612a295899 100644 --- a/src/Symfony/Component/Validator/Constraints/Blank.php +++ b/src/Symfony/Component/Validator/Constraints/Blank.php @@ -28,11 +28,6 @@ class Blank extends Constraint self::NOT_BLANK_ERROR => 'NOT_BLANK_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be blank.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/CardScheme.php b/src/Symfony/Component/Validator/Constraints/CardScheme.php index 067024769aea7..76dbcb9d86f2c 100644 --- a/src/Symfony/Component/Validator/Constraints/CardScheme.php +++ b/src/Symfony/Component/Validator/Constraints/CardScheme.php @@ -46,11 +46,6 @@ class CardScheme extends Constraint self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'Unsupported card type or invalid card number.'; public $schemes; diff --git a/src/Symfony/Component/Validator/Constraints/Choice.php b/src/Symfony/Component/Validator/Constraints/Choice.php index 5544688d0baf6..83cb78b76dff7 100644 --- a/src/Symfony/Component/Validator/Constraints/Choice.php +++ b/src/Symfony/Component/Validator/Constraints/Choice.php @@ -32,11 +32,6 @@ class Choice extends Constraint self::TOO_MANY_ERROR => 'TOO_MANY_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $choices; public $callback; public $multiple = false; diff --git a/src/Symfony/Component/Validator/Constraints/Cidr.php b/src/Symfony/Component/Validator/Constraints/Cidr.php index 03002a7b50aa3..0a721a45ce644 100644 --- a/src/Symfony/Component/Validator/Constraints/Cidr.php +++ b/src/Symfony/Component/Validator/Constraints/Cidr.php @@ -40,11 +40,6 @@ class Cidr extends Constraint Ip::V6 => 128, ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $version = Ip::ALL; public $message = 'This value is not a valid CIDR notation.'; diff --git a/src/Symfony/Component/Validator/Constraints/Collection.php b/src/Symfony/Component/Validator/Constraints/Collection.php index ee50fca169840..a857c2aa43fb0 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -30,11 +30,6 @@ class Collection extends Composite self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $fields = []; public $allowExtraFields = false; public $allowMissingFields = false; diff --git a/src/Symfony/Component/Validator/Constraints/Count.php b/src/Symfony/Component/Validator/Constraints/Count.php index ea5d4182865d3..89985c398f2d0 100644 --- a/src/Symfony/Component/Validator/Constraints/Count.php +++ b/src/Symfony/Component/Validator/Constraints/Count.php @@ -35,11 +35,6 @@ class Count extends Constraint self::NOT_DIVISIBLE_BY_ERROR => 'NOT_DIVISIBLE_BY_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $minMessage = 'This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.'; public $maxMessage = 'This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.'; public $exactMessage = 'This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements.'; diff --git a/src/Symfony/Component/Validator/Constraints/Country.php b/src/Symfony/Component/Validator/Constraints/Country.php index 03df0206bbedb..0ca6fa47da197 100644 --- a/src/Symfony/Component/Validator/Constraints/Country.php +++ b/src/Symfony/Component/Validator/Constraints/Country.php @@ -30,11 +30,6 @@ class Country extends Constraint self::NO_SUCH_COUNTRY_ERROR => 'NO_SUCH_COUNTRY_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid country.'; public $alpha3 = false; diff --git a/src/Symfony/Component/Validator/Constraints/CssColor.php b/src/Symfony/Component/Validator/Constraints/CssColor.php index d1e2e27834304..56f4e1b16b440 100644 --- a/src/Symfony/Component/Validator/Constraints/CssColor.php +++ b/src/Symfony/Component/Validator/Constraints/CssColor.php @@ -41,11 +41,6 @@ class CssColor extends Constraint self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - /** * @var string[] */ diff --git a/src/Symfony/Component/Validator/Constraints/Currency.php b/src/Symfony/Component/Validator/Constraints/Currency.php index 5713d803e8cd7..5e4d81567cc6b 100644 --- a/src/Symfony/Component/Validator/Constraints/Currency.php +++ b/src/Symfony/Component/Validator/Constraints/Currency.php @@ -31,11 +31,6 @@ class Currency extends Constraint self::NO_SUCH_CURRENCY_ERROR => 'NO_SUCH_CURRENCY_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid currency.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/Date.php b/src/Symfony/Component/Validator/Constraints/Date.php index 1ca3bee11f359..e836df8fd0429 100644 --- a/src/Symfony/Component/Validator/Constraints/Date.php +++ b/src/Symfony/Component/Validator/Constraints/Date.php @@ -30,11 +30,6 @@ class Date extends Constraint self::INVALID_DATE_ERROR => 'INVALID_DATE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid date.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/DateTime.php b/src/Symfony/Component/Validator/Constraints/DateTime.php index f187f8b266850..d8f97c69624ae 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTime.php +++ b/src/Symfony/Component/Validator/Constraints/DateTime.php @@ -32,11 +32,6 @@ class DateTime extends Constraint self::INVALID_TIME_ERROR => 'INVALID_TIME_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $format = 'Y-m-d H:i:s'; public $message = 'This value is not a valid datetime.'; diff --git a/src/Symfony/Component/Validator/Constraints/DivisibleBy.php b/src/Symfony/Component/Validator/Constraints/DivisibleBy.php index 90164aab286b6..941b7e07c0e43 100644 --- a/src/Symfony/Component/Validator/Constraints/DivisibleBy.php +++ b/src/Symfony/Component/Validator/Constraints/DivisibleBy.php @@ -26,10 +26,5 @@ class DivisibleBy extends AbstractComparison self::NOT_DIVISIBLE_BY => 'NOT_DIVISIBLE_BY', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be a multiple of {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index 46928894f3b83..a505d56dc3fcf 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -28,10 +28,6 @@ class Email extends Constraint public const VALIDATION_MODE_HTML5_ALLOW_NO_TLD = 'html5-allow-no-tld'; public const VALIDATION_MODE_HTML5 = 'html5'; public const VALIDATION_MODE_STRICT = 'strict'; - /** - * @deprecated since Symfony 6.2, use VALIDATION_MODE_HTML5 instead - */ - public const VALIDATION_MODE_LOOSE = 'loose'; public const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310'; @@ -39,18 +35,12 @@ class Email extends Constraint self::VALIDATION_MODE_HTML5_ALLOW_NO_TLD, self::VALIDATION_MODE_HTML5, self::VALIDATION_MODE_STRICT, - self::VALIDATION_MODE_LOOSE, ]; protected const ERROR_NAMES = [ self::INVALID_FORMAT_ERROR => 'STRICT_CHECK_FAILED_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid email address.'; public $mode; public $normalizer; @@ -73,10 +63,6 @@ public function __construct( $this->mode = $mode ?? $this->mode; $this->normalizer = $normalizer ?? $this->normalizer; - if (self::VALIDATION_MODE_LOOSE === $this->mode) { - 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); - } - if (self::VALIDATION_MODE_STRICT === $this->mode && !class_exists(StrictEmailValidator::class)) { 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__)); } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 8c0ff7730855b..72765dfbf7f06 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -28,26 +28,20 @@ class EmailValidator extends ConstraintValidator { 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])?)*$/'; 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])?)+$/'; - private const PATTERN_LOOSE = '/^.+\@\S+\.\S+$/'; private const EMAIL_PATTERNS = [ - Email::VALIDATION_MODE_LOOSE => self::PATTERN_LOOSE, Email::VALIDATION_MODE_HTML5 => self::PATTERN_HTML5, Email::VALIDATION_MODE_HTML5_ALLOW_NO_TLD => self::PATTERN_HTML5_ALLOW_NO_TLD, ]; private string $defaultMode; - public function __construct(string $defaultMode = Email::VALIDATION_MODE_LOOSE) + public function __construct(string $defaultMode = Email::VALIDATION_MODE_HTML5) { if (!\in_array($defaultMode, Email::VALIDATION_MODES, true)) { throw new InvalidArgumentException('The "defaultMode" parameter value is not valid.'); } - if (Email::VALIDATION_MODE_LOOSE === $defaultMode) { - 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); - } - $this->defaultMode = $defaultMode; } diff --git a/src/Symfony/Component/Validator/Constraints/EqualTo.php b/src/Symfony/Component/Validator/Constraints/EqualTo.php index 03769ce8a84a8..a6c4d1d107400 100644 --- a/src/Symfony/Component/Validator/Constraints/EqualTo.php +++ b/src/Symfony/Component/Validator/Constraints/EqualTo.php @@ -27,10 +27,5 @@ class EqualTo extends AbstractComparison self::NOT_EQUAL_ERROR => 'NOT_EQUAL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be equal to {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/Expression.php b/src/Symfony/Component/Validator/Constraints/Expression.php index cdf3e50067d5f..19218e7d86717 100644 --- a/src/Symfony/Component/Validator/Constraints/Expression.php +++ b/src/Symfony/Component/Validator/Constraints/Expression.php @@ -32,11 +32,6 @@ class Expression extends Constraint self::EXPRESSION_FAILED_ERROR => 'EXPRESSION_FAILED_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not valid.'; public $expression; public $values = []; diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php b/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php deleted file mode 100644 index bbbb5ebe26157..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; - -trigger_deprecation('symfony/validator', '6.1', 'The "%s" constraint is deprecated since symfony 6.1, use "ExpressionSyntax" instead.', ExpressionLanguageSyntax::class); - -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Andrey Sevastianov - * - * @deprecated since symfony 6.1, use ExpressionSyntax instead - */ -#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] -class ExpressionLanguageSyntax extends Constraint -{ - public const EXPRESSION_LANGUAGE_SYNTAX_ERROR = '1766a3f3-ff03-40eb-b053-ab7aa23d988a'; - - protected const ERROR_NAMES = [ - self::EXPRESSION_LANGUAGE_SYNTAX_ERROR => 'EXPRESSION_LANGUAGE_SYNTAX_ERROR', - ]; - - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - - public $message = 'This value should be a valid expression.'; - public $service; - public $allowedVariables; - - public function __construct(array $options = null, string $message = null, string $service = null, array $allowedVariables = null, array $groups = null, mixed $payload = null) - { - parent::__construct($options, $groups, $payload); - - $this->message = $message ?? $this->message; - $this->service = $service ?? $this->service; - $this->allowedVariables = $allowedVariables ?? $this->allowedVariables; - } - - public function validatedBy(): string - { - return $this->service ?? static::class.'Validator'; - } -} diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php deleted file mode 100644 index d7e9c046bb893..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Constraints; - -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\ExpressionLanguage\SyntaxError; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Validator\Exception\UnexpectedValueException; - -trigger_deprecation('symfony/validator', '6.1', 'The "%s" constraint is deprecated since symfony 6.1, use "ExpressionSyntaxValidator" instead.', ExpressionLanguageSyntaxValidator::class); - -/** - * @author Andrey Sevastianov - * - * @deprecated since symfony 6.1, use ExpressionSyntaxValidator instead - */ -class ExpressionLanguageSyntaxValidator extends ConstraintValidator -{ - private ?ExpressionLanguage $expressionLanguage; - - public function __construct(ExpressionLanguage $expressionLanguage = null) - { - if (!class_exists(ExpressionLanguage::class)) { - throw new \LogicException(sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', self::class)); - } - - $this->expressionLanguage = $expressionLanguage; - } - - public function validate(mixed $expression, Constraint $constraint): void - { - if (!$constraint instanceof ExpressionLanguageSyntax) { - throw new UnexpectedTypeException($constraint, ExpressionLanguageSyntax::class); - } - - if (!\is_string($expression)) { - throw new UnexpectedValueException($expression, 'string'); - } - - $this->expressionLanguage ??= new ExpressionLanguage(); - - try { - $this->expressionLanguage->lint($expression, $constraint->allowedVariables); - } catch (SyntaxError $exception) { - $this->context->buildViolation($constraint->message) - ->setParameter('{{ syntax_error }}', $this->formatValue($exception->getMessage())) - ->setInvalidValue((string) $expression) - ->setCode(ExpressionLanguageSyntax::EXPRESSION_LANGUAGE_SYNTAX_ERROR) - ->addViolation(); - } - } -} diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index ed145ff381f69..367ed10c8c50a 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -44,11 +44,6 @@ class File extends Constraint self::FILENAME_TOO_LONG => 'FILENAME_TOO_LONG', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $binaryFormat; public $mimeTypes = []; public ?int $filenameMaxLength = null; diff --git a/src/Symfony/Component/Validator/Constraints/GreaterThan.php b/src/Symfony/Component/Validator/Constraints/GreaterThan.php index ce56f1ac1c814..160aa2a623ebf 100644 --- a/src/Symfony/Component/Validator/Constraints/GreaterThan.php +++ b/src/Symfony/Component/Validator/Constraints/GreaterThan.php @@ -27,10 +27,5 @@ class GreaterThan extends AbstractComparison self::TOO_LOW_ERROR => 'TOO_LOW_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be greater than {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php b/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php index c962f7964f4ba..b4bed95a1ac2a 100644 --- a/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php +++ b/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php @@ -27,10 +27,5 @@ class GreaterThanOrEqual extends AbstractComparison self::TOO_LOW_ERROR => 'TOO_LOW_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be greater than or equal to {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/Hostname.php b/src/Symfony/Component/Validator/Constraints/Hostname.php index cbf33cd8d0279..c0463b33508f8 100644 --- a/src/Symfony/Component/Validator/Constraints/Hostname.php +++ b/src/Symfony/Component/Validator/Constraints/Hostname.php @@ -28,11 +28,6 @@ class Hostname extends Constraint self::INVALID_HOSTNAME_ERROR => 'INVALID_HOSTNAME_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid hostname.'; public $requireTld = true; diff --git a/src/Symfony/Component/Validator/Constraints/Iban.php b/src/Symfony/Component/Validator/Constraints/Iban.php index 684df2e561e5b..2fefd504cb499 100644 --- a/src/Symfony/Component/Validator/Constraints/Iban.php +++ b/src/Symfony/Component/Validator/Constraints/Iban.php @@ -38,11 +38,6 @@ class Iban extends Constraint self::NOT_SUPPORTED_COUNTRY_CODE_ERROR => 'NOT_SUPPORTED_COUNTRY_CODE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This is not a valid International Bank Account Number (IBAN).'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/IdenticalTo.php b/src/Symfony/Component/Validator/Constraints/IdenticalTo.php index 50ec5e1297a15..982617aa3d1a8 100644 --- a/src/Symfony/Component/Validator/Constraints/IdenticalTo.php +++ b/src/Symfony/Component/Validator/Constraints/IdenticalTo.php @@ -27,10 +27,5 @@ class IdenticalTo extends AbstractComparison self::NOT_IDENTICAL_ERROR => 'NOT_IDENTICAL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be identical to {{ compared_value_type }} {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/Image.php b/src/Symfony/Component/Validator/Constraints/Image.php index c61b408367aa3..ed2d4fa60a4fd 100644 --- a/src/Symfony/Component/Validator/Constraints/Image.php +++ b/src/Symfony/Component/Validator/Constraints/Image.php @@ -58,11 +58,6 @@ class Image extends File self::CORRUPTED_IMAGE_ERROR => 'CORRUPTED_IMAGE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $mimeTypes = 'image/*'; public $minWidth; public $maxWidth; diff --git a/src/Symfony/Component/Validator/Constraints/Ip.php b/src/Symfony/Component/Validator/Constraints/Ip.php index 94c4ca4847663..050f31ef3b129 100644 --- a/src/Symfony/Component/Validator/Constraints/Ip.php +++ b/src/Symfony/Component/Validator/Constraints/Ip.php @@ -70,16 +70,6 @@ class Ip extends Constraint self::INVALID_IP_ERROR => 'INVALID_IP_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const VERSIONS instead - */ - protected static $versions = self::VERSIONS; - - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $version = self::V4; public $message = 'This is not a valid IP address.'; @@ -100,8 +90,8 @@ public function __construct( $this->message = $message ?? $this->message; $this->normalizer = $normalizer ?? $this->normalizer; - if (!\in_array($this->version, self::$versions)) { - throw new ConstraintDefinitionException(sprintf('The option "version" must be one of "%s".', implode('", "', self::$versions))); + if (!\in_array($this->version, static::VERSIONS, true)) { + throw new ConstraintDefinitionException(sprintf('The option "version" must be one of "%s".', implode('", "', static::VERSIONS))); } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { diff --git a/src/Symfony/Component/Validator/Constraints/IsFalse.php b/src/Symfony/Component/Validator/Constraints/IsFalse.php index 26042e2ee12bf..9e86383b741ef 100644 --- a/src/Symfony/Component/Validator/Constraints/IsFalse.php +++ b/src/Symfony/Component/Validator/Constraints/IsFalse.php @@ -28,11 +28,6 @@ class IsFalse extends Constraint self::NOT_FALSE_ERROR => 'NOT_FALSE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be false.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/IsNull.php b/src/Symfony/Component/Validator/Constraints/IsNull.php index 5084c268a1d78..b6d9eaa1a12dc 100644 --- a/src/Symfony/Component/Validator/Constraints/IsNull.php +++ b/src/Symfony/Component/Validator/Constraints/IsNull.php @@ -28,11 +28,6 @@ class IsNull extends Constraint self::NOT_NULL_ERROR => 'NOT_NULL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be null.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/IsTrue.php b/src/Symfony/Component/Validator/Constraints/IsTrue.php index 8ee9f729d04db..0f3e2f1895d41 100644 --- a/src/Symfony/Component/Validator/Constraints/IsTrue.php +++ b/src/Symfony/Component/Validator/Constraints/IsTrue.php @@ -28,11 +28,6 @@ class IsTrue extends Constraint self::NOT_TRUE_ERROR => 'NOT_TRUE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be true.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/Isbn.php b/src/Symfony/Component/Validator/Constraints/Isbn.php index 5b70c6fcbdc44..18a8e7758132a 100644 --- a/src/Symfony/Component/Validator/Constraints/Isbn.php +++ b/src/Symfony/Component/Validator/Constraints/Isbn.php @@ -41,11 +41,6 @@ class Isbn extends Constraint self::TYPE_NOT_RECOGNIZED_ERROR => 'TYPE_NOT_RECOGNIZED_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $isbn10Message = 'This value is not a valid ISBN-10.'; public $isbn13Message = 'This value is not a valid ISBN-13.'; public $bothIsbnMessage = 'This value is neither a valid ISBN-10 nor a valid ISBN-13.'; diff --git a/src/Symfony/Component/Validator/Constraints/Isin.php b/src/Symfony/Component/Validator/Constraints/Isin.php index 1522044befa87..90a7131583004 100644 --- a/src/Symfony/Component/Validator/Constraints/Isin.php +++ b/src/Symfony/Component/Validator/Constraints/Isin.php @@ -35,11 +35,6 @@ class Isin extends Constraint self::INVALID_CHECKSUM_ERROR => 'INVALID_CHECKSUM_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid International Securities Identification Number (ISIN).'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/Issn.php b/src/Symfony/Component/Validator/Constraints/Issn.php index a11f022e63e16..e591960e9819f 100644 --- a/src/Symfony/Component/Validator/Constraints/Issn.php +++ b/src/Symfony/Component/Validator/Constraints/Issn.php @@ -39,11 +39,6 @@ class Issn extends Constraint self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid ISSN.'; public $caseSensitive = false; public $requireHyphen = false; diff --git a/src/Symfony/Component/Validator/Constraints/Json.php b/src/Symfony/Component/Validator/Constraints/Json.php index f2826d28e39bc..6facc6dbab259 100644 --- a/src/Symfony/Component/Validator/Constraints/Json.php +++ b/src/Symfony/Component/Validator/Constraints/Json.php @@ -28,11 +28,6 @@ class Json extends Constraint self::INVALID_JSON_ERROR => 'INVALID_JSON_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be valid JSON.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/Language.php b/src/Symfony/Component/Validator/Constraints/Language.php index e3c2ce9629dde..b0d18289e57ff 100644 --- a/src/Symfony/Component/Validator/Constraints/Language.php +++ b/src/Symfony/Component/Validator/Constraints/Language.php @@ -30,11 +30,6 @@ class Language extends Constraint self::NO_SUCH_LANGUAGE_ERROR => 'NO_SUCH_LANGUAGE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid language.'; public $alpha3 = false; diff --git a/src/Symfony/Component/Validator/Constraints/Length.php b/src/Symfony/Component/Validator/Constraints/Length.php index 59360ace13fe1..4daf59e50ac5c 100644 --- a/src/Symfony/Component/Validator/Constraints/Length.php +++ b/src/Symfony/Component/Validator/Constraints/Length.php @@ -46,11 +46,6 @@ class Length extends Constraint self::COUNT_GRAPHEMES, ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $maxMessage = 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.'; public $minMessage = 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.'; public $exactMessage = 'This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.'; diff --git a/src/Symfony/Component/Validator/Constraints/LessThan.php b/src/Symfony/Component/Validator/Constraints/LessThan.php index cf4144d6d26d3..2770c9b159bc2 100644 --- a/src/Symfony/Component/Validator/Constraints/LessThan.php +++ b/src/Symfony/Component/Validator/Constraints/LessThan.php @@ -27,10 +27,5 @@ class LessThan extends AbstractComparison self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be less than {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php b/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php index 84e31abfc0213..e2f127f07ab05 100644 --- a/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php +++ b/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php @@ -27,10 +27,5 @@ class LessThanOrEqual extends AbstractComparison self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be less than or equal to {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/Locale.php b/src/Symfony/Component/Validator/Constraints/Locale.php index 30f0ffd6eb30e..946785b43b917 100644 --- a/src/Symfony/Component/Validator/Constraints/Locale.php +++ b/src/Symfony/Component/Validator/Constraints/Locale.php @@ -30,11 +30,6 @@ class Locale extends Constraint self::NO_SUCH_LOCALE_ERROR => 'NO_SUCH_LOCALE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid locale.'; public $canonicalize = true; diff --git a/src/Symfony/Component/Validator/Constraints/Luhn.php b/src/Symfony/Component/Validator/Constraints/Luhn.php index 198fb29baf29b..fb76ec9a04892 100644 --- a/src/Symfony/Component/Validator/Constraints/Luhn.php +++ b/src/Symfony/Component/Validator/Constraints/Luhn.php @@ -34,11 +34,6 @@ class Luhn extends Constraint self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'Invalid card number.'; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/NotBlank.php b/src/Symfony/Component/Validator/Constraints/NotBlank.php index 38637ad202603..02d6d5c79fcca 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlank.php @@ -30,11 +30,6 @@ class NotBlank extends Constraint self::IS_BLANK_ERROR => 'IS_BLANK_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should not be blank.'; public $allowNull = false; public $normalizer; diff --git a/src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php b/src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php index 3329d3c1abc0d..ae90925f78111 100644 --- a/src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php +++ b/src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php @@ -30,11 +30,6 @@ class NotCompromisedPassword extends Constraint self::COMPROMISED_PASSWORD_ERROR => 'COMPROMISED_PASSWORD_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This password has been leaked in a data breach, it must not be used. Please use another password.'; public $threshold = 1; public $skipOnError = false; diff --git a/src/Symfony/Component/Validator/Constraints/NotEqualTo.php b/src/Symfony/Component/Validator/Constraints/NotEqualTo.php index 9a5c07b21e2aa..8ddc2d334b1ba 100644 --- a/src/Symfony/Component/Validator/Constraints/NotEqualTo.php +++ b/src/Symfony/Component/Validator/Constraints/NotEqualTo.php @@ -27,10 +27,5 @@ class NotEqualTo extends AbstractComparison self::IS_EQUAL_ERROR => 'IS_EQUAL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should not be equal to {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/NotIdenticalTo.php b/src/Symfony/Component/Validator/Constraints/NotIdenticalTo.php index 206c106137322..80628135adf02 100644 --- a/src/Symfony/Component/Validator/Constraints/NotIdenticalTo.php +++ b/src/Symfony/Component/Validator/Constraints/NotIdenticalTo.php @@ -27,10 +27,5 @@ class NotIdenticalTo extends AbstractComparison self::IS_IDENTICAL_ERROR => 'IS_IDENTICAL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should not be identical to {{ compared_value_type }} {{ compared_value }}.'; } diff --git a/src/Symfony/Component/Validator/Constraints/NotNull.php b/src/Symfony/Component/Validator/Constraints/NotNull.php index 2fd4123cdfcae..8d4f2e211871a 100644 --- a/src/Symfony/Component/Validator/Constraints/NotNull.php +++ b/src/Symfony/Component/Validator/Constraints/NotNull.php @@ -28,11 +28,6 @@ class NotNull extends Constraint self::IS_NULL_ERROR => 'IS_NULL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should not be null.'; public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null) diff --git a/src/Symfony/Component/Validator/Constraints/Range.php b/src/Symfony/Component/Validator/Constraints/Range.php index c4ae8b7648ccc..da01a5488f2e6 100644 --- a/src/Symfony/Component/Validator/Constraints/Range.php +++ b/src/Symfony/Component/Validator/Constraints/Range.php @@ -38,11 +38,6 @@ class Range extends Constraint self::TOO_LOW_ERROR => 'TOO_LOW_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $notInRangeMessage = 'This value should be between {{ min }} and {{ max }}.'; public $minMessage = 'This value should be {{ limit }} or more.'; public $maxMessage = 'This value should be {{ limit }} or less.'; diff --git a/src/Symfony/Component/Validator/Constraints/Regex.php b/src/Symfony/Component/Validator/Constraints/Regex.php index 67dc8b37c67ff..9062819e12f2f 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -29,11 +29,6 @@ class Regex extends Constraint self::REGEX_FAILED_ERROR => 'REGEX_FAILED_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not valid.'; public $pattern; public $htmlPattern; diff --git a/src/Symfony/Component/Validator/Constraints/Time.php b/src/Symfony/Component/Validator/Constraints/Time.php index f281ae1ee85b3..994473dc150c1 100644 --- a/src/Symfony/Component/Validator/Constraints/Time.php +++ b/src/Symfony/Component/Validator/Constraints/Time.php @@ -30,11 +30,6 @@ class Time extends Constraint self::INVALID_TIME_ERROR => 'INVALID_TIME_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid time.'; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/Timezone.php b/src/Symfony/Component/Validator/Constraints/Timezone.php index 03bc19e7cc66a..1ba24be9cf271 100644 --- a/src/Symfony/Component/Validator/Constraints/Timezone.php +++ b/src/Symfony/Component/Validator/Constraints/Timezone.php @@ -41,11 +41,6 @@ class Timezone extends Constraint self::TIMEZONE_IDENTIFIER_INTL_ERROR => 'TIMEZONE_IDENTIFIER_INTL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public function __construct( int|array $zone = null, string $message = null, diff --git a/src/Symfony/Component/Validator/Constraints/Type.php b/src/Symfony/Component/Validator/Constraints/Type.php index 97a5ef939d3fb..cf61476c40e21 100644 --- a/src/Symfony/Component/Validator/Constraints/Type.php +++ b/src/Symfony/Component/Validator/Constraints/Type.php @@ -28,11 +28,6 @@ class Type extends Constraint self::INVALID_TYPE_ERROR => 'INVALID_TYPE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value should be of type {{ type }}.'; public $type; diff --git a/src/Symfony/Component/Validator/Constraints/Ulid.php b/src/Symfony/Component/Validator/Constraints/Ulid.php index ece08c721cd73..a1f2c086ebe5b 100644 --- a/src/Symfony/Component/Validator/Constraints/Ulid.php +++ b/src/Symfony/Component/Validator/Constraints/Ulid.php @@ -33,11 +33,6 @@ class Ulid extends Constraint self::TOO_LARGE_ERROR => 'TOO_LARGE_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This is not a valid ULID.'; public function __construct( diff --git a/src/Symfony/Component/Validator/Constraints/Unique.php b/src/Symfony/Component/Validator/Constraints/Unique.php index 6db31c0e41236..d85de6c749364 100644 --- a/src/Symfony/Component/Validator/Constraints/Unique.php +++ b/src/Symfony/Component/Validator/Constraints/Unique.php @@ -31,11 +31,6 @@ class Unique extends Constraint self::IS_NOT_UNIQUE => 'IS_NOT_UNIQUE', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This collection should contain only unique elements.'; public $normalizer; diff --git a/src/Symfony/Component/Validator/Constraints/Url.php b/src/Symfony/Component/Validator/Constraints/Url.php index e3bea2e1b3d67..5575e2c2bc7be 100644 --- a/src/Symfony/Component/Validator/Constraints/Url.php +++ b/src/Symfony/Component/Validator/Constraints/Url.php @@ -29,11 +29,6 @@ class Url extends Constraint self::INVALID_URL_ERROR => 'INVALID_URL_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - public $message = 'This value is not a valid URL.'; public $protocols = ['http', 'https']; public $relativeProtocol = false; diff --git a/src/Symfony/Component/Validator/Constraints/Uuid.php b/src/Symfony/Component/Validator/Constraints/Uuid.php index a96d2ceb936cb..f397143b1d627 100644 --- a/src/Symfony/Component/Validator/Constraints/Uuid.php +++ b/src/Symfony/Component/Validator/Constraints/Uuid.php @@ -40,11 +40,6 @@ class Uuid extends Constraint self::INVALID_VARIANT_ERROR => 'INVALID_VARIANT_ERROR', ]; - /** - * @deprecated since Symfony 6.1, use const ERROR_NAMES instead - */ - protected static $errorNames = self::ERROR_NAMES; - // Possible versions defined by RFC 4122 public const V1_MAC = 1; public const V2_DCE = 2; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 6bf8fec6c717a..d894236e104af 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\EmailValidator; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -22,8 +21,6 @@ */ class EmailValidatorTest extends ConstraintValidatorTestCase { - use ExpectDeprecationTrait; - protected function createValidator(): EmailValidator { return new EmailValidator(Email::VALIDATION_MODE_HTML5); @@ -82,30 +79,6 @@ public static function getValidEmails() ]; } - /** - * @group legacy - * - * @dataProvider getValidEmails - * @dataProvider getEmailsOnlyValidInLooseMode - */ - public function testValidInLooseModeEmails($email) - { - $this->validator->validate($email, new Email(['mode' => Email::VALIDATION_MODE_LOOSE])); - - $this->assertNoViolation(); - } - - public static function getEmailsOnlyValidInLooseMode() - { - return [ - ['example@example.co..uk'], - ['{}~!@!@£$%%^&*().!@£$%^&*()'], - ['example@example.co..uk'], - ['example@-example.com'], - [sprintf('example@%s.com', str_repeat('a', 64))], - ]; - } - /** * @dataProvider getValidEmailsWithWhitespaces */ @@ -124,29 +97,6 @@ public static function getValidEmailsWithWhitespaces() ]; } - /** - * @group legacy - * - * @dataProvider getValidEmailsWithWhitespaces - * @dataProvider getEmailsWithWhitespacesOnlyValidInLooseMode - */ - public function testValidNormalizedEmailsInLooseMode($email) - { - $this->validator->validate($email, new Email(['mode' => Email::VALIDATION_MODE_LOOSE, 'normalizer' => 'trim'])); - - $this->assertNoViolation(); - } - - public static function getEmailsWithWhitespacesOnlyValidInLooseMode() - { - return [ - ["\x09\x09example@example.co..uk\x09\x09"], - ["\x0A{}~!@!@£$%%^&*().!@£$%^&*()\x0A"], - ["\x0D\x0Dexample@example.co..uk\x0D\x0D"], - ["\x00example@-example.com"], - ]; - } - /** * @dataProvider getValidEmailsHtml5 */ @@ -293,20 +243,6 @@ public function testModeHtml5AllowNoTld() $this->assertNoViolation(); } - /** - * @group legacy - */ - public function testModeLoose() - { - $this->expectDeprecation('Since symfony/validator 6.2: The "loose" mode is deprecated. It will be removed in 7.0 and the default mode will be changed to "html5".'); - - $constraint = new Email(['mode' => Email::VALIDATION_MODE_LOOSE]); - - $this->validator->validate('example@example..com', $constraint); - - $this->assertNoViolation(); - } - public function testUnknownModesOnValidateTriggerException() { $this->expectException(\InvalidArgumentException::class); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php deleted file mode 100644 index 2fb8bf15500d0..0000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntax; -use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; - -/** - * @group legacy - */ -class ExpressionLanguageSyntaxTest extends TestCase -{ - public function testValidatedByStandardValidator() - { - $constraint = new ExpressionLanguageSyntax(); - - self::assertSame(ExpressionLanguageSyntaxValidator::class, $constraint->validatedBy()); - } - - /** - * @dataProvider provideServiceValidatedConstraints - */ - public function testValidatedByService(ExpressionLanguageSyntax $constraint) - { - self::assertSame('my_service', $constraint->validatedBy()); - } - - public static function provideServiceValidatedConstraints(): iterable - { - yield 'Doctrine style' => [new ExpressionLanguageSyntax(['service' => 'my_service'])]; - - yield 'named arguments' => [new ExpressionLanguageSyntax(service: 'my_service')]; - - $metadata = new ClassMetadata(ExpressionLanguageSyntaxDummy::class); - self::assertTrue((new AnnotationLoader())->loadClassMetadata($metadata)); - - yield 'attribute' => [$metadata->properties['b']->constraints[0]]; - } - - public function testAttributes() - { - $metadata = new ClassMetadata(ExpressionLanguageSyntaxDummy::class); - self::assertTrue((new AnnotationLoader())->loadClassMetadata($metadata)); - - [$aConstraint] = $metadata->properties['a']->getConstraints(); - self::assertNull($aConstraint->service); - self::assertNull($aConstraint->allowedVariables); - - [$bConstraint] = $metadata->properties['b']->getConstraints(); - self::assertSame('my_service', $bConstraint->service); - self::assertSame('myMessage', $bConstraint->message); - self::assertSame(['Default', 'ExpressionLanguageSyntaxDummy'], $bConstraint->groups); - - [$cConstraint] = $metadata->properties['c']->getConstraints(); - self::assertSame(['foo', 'bar'], $cConstraint->allowedVariables); - self::assertSame(['my_group'], $cConstraint->groups); - } -} - -class ExpressionLanguageSyntaxDummy -{ - #[ExpressionLanguageSyntax] - private $a; - - #[ExpressionLanguageSyntax(service: 'my_service', message: 'myMessage')] - private $b; - - #[ExpressionLanguageSyntax(allowedVariables: ['foo', 'bar'], groups: ['my_group'])] - private $c; -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php deleted file mode 100644 index f44e606a49f12..0000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntax; -use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator; -use Symfony\Component\Validator\ConstraintValidatorInterface; -use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; - -/** - * @group legacy - */ -class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase -{ - protected function createValidator(): ConstraintValidatorInterface - { - return new ExpressionLanguageSyntaxValidator(new ExpressionLanguage()); - } - - public function testExpressionValid() - { - $this->validator->validate('1 + 1', new ExpressionLanguageSyntax([ - 'message' => 'myMessage', - 'allowedVariables' => [], - ])); - - $this->assertNoViolation(); - } - - public function testExpressionWithoutNames() - { - $this->validator->validate('1 + 1', new ExpressionLanguageSyntax([ - 'message' => 'myMessage', - ])); - - $this->assertNoViolation(); - } - - public function testExpressionWithAllowedVariableName() - { - $this->validator->validate('a + 1', new ExpressionLanguageSyntax([ - 'message' => 'myMessage', - 'allowedVariables' => ['a'], - ])); - - $this->assertNoViolation(); - } - - public function testExpressionIsNotValid() - { - $this->validator->validate('a + 1', new ExpressionLanguageSyntax([ - 'message' => 'myMessage', - 'allowedVariables' => [], - ])); - - $this->buildViolation('myMessage') - ->setParameter('{{ syntax_error }}', '"Variable "a" is not valid around position 1 for expression `a + 1`."') - ->setInvalidValue('a + 1') - ->setCode(ExpressionLanguageSyntax::EXPRESSION_LANGUAGE_SYNTAX_ERROR) - ->assertRaised(); - } -} diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 8e8326d328e42..898e318ad242e 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -17,7 +17,6 @@ ], "require": { "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php83": "^1.27",