diff --git a/UPGRADE-6.1.md b/UPGRADE-6.1.md index 4800052c26206..70d78fd7cc97e 100644 --- a/UPGRADE-6.1.md +++ b/UPGRADE-6.1.md @@ -13,3 +13,8 @@ Serializer * Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead * Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead * Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead + +Validator +--------- + + * Deprecate `Constraint::$errorNames`, use `Constraint::ERROR_NAMES` instead diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php index ebfd5e62046d3..7d65c898ccb47 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php @@ -26,6 +26,10 @@ class UniqueEntity extends Constraint { public const NOT_UNIQUE_ERROR = '23bd9dbf-6b9b-41cd-a99e-4844bcf3077f'; + protected const ERROR_NAMES = [ + self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR', + ]; + public $message = 'This value is already used.'; public $service = 'doctrine.orm.validator.unique'; public $em = null; @@ -35,9 +39,10 @@ class UniqueEntity extends Constraint public $errorPath = null; public $ignoreNull = true; - protected static $errorNames = [ - self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR', - ]; + /** + * @deprecated since Symfony 6.1, use const ERROR_NAMES instead + */ + protected static $errorNames = self::ERROR_NAMES; /** * {@inheritdoc} diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php index 714ef312dcb7c..694281ddd1238 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php @@ -21,11 +21,16 @@ class Form extends Constraint public const NOT_SYNCHRONIZED_ERROR = '1dafa156-89e1-4736-b832-419c2e501fca'; public const NO_SUCH_FIELD_ERROR = '6e5212ed-a197-4339-99aa-5654798a4854'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::NOT_SYNCHRONIZED_ERROR => 'NOT_SYNCHRONIZED_ERROR', 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; + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 1a095ee6fe9ec..85baf4340c129 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.1 +--- + + * Deprecate `Constraint::$errorNames`, use `Constraint::ERROR_NAMES` instead + 6.0 --- diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index 46432f2f4c60a..ee1d68c78f50b 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -47,6 +47,11 @@ abstract class Constraint /** * Maps error codes to the names of their constants. */ + protected const ERROR_NAMES = []; + + /** + * @deprecated since Symfony 6.1, use protected const ERROR_NAMES instead + */ protected static $errorNames = []; /** @@ -70,10 +75,16 @@ abstract class Constraint */ public static function getErrorName(string $errorCode): string { + if (isset(static::ERROR_NAMES[$errorCode])) { + 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]; } diff --git a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php b/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php index 5eb67535e925c..33ed343af7aee 100644 --- a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php +++ b/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php @@ -22,10 +22,15 @@ class AtLeastOneOf extends Composite { public const AT_LEAST_ONE_OF_ERROR = 'f27e6d6c-261a-4056-b391-6673a623531c'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 7e871be9c50cd..36ec3436df34f 100644 --- a/src/Symfony/Component/Validator/Constraints/Bic.php +++ b/src/Symfony/Component/Validator/Constraints/Bic.php @@ -33,7 +33,7 @@ class Bic extends Constraint public const INVALID_CASE_ERROR = '11884038-3312-4ae5-9d04-699f782130c7'; public const INVALID_IBAN_COUNTRY_CODE_ERROR = '29a2c3bb-587b-4996-b6f5-53081364cea5'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_LENGTH_ERROR => 'INVALID_LENGTH_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', self::INVALID_BANK_CODE_ERROR => 'INVALID_BANK_CODE_ERROR', @@ -41,6 +41,11 @@ 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 d4d3209999191..bd28e68bc81f5 100644 --- a/src/Symfony/Component/Validator/Constraints/Blank.php +++ b/src/Symfony/Component/Validator/Constraints/Blank.php @@ -24,10 +24,15 @@ class Blank extends Constraint { public const NOT_BLANK_ERROR = '183ad2de-533d-4796-a439-6d3c3852b549'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 095019d4d4357..067024769aea7 100644 --- a/src/Symfony/Component/Validator/Constraints/CardScheme.php +++ b/src/Symfony/Component/Validator/Constraints/CardScheme.php @@ -41,11 +41,16 @@ class CardScheme extends Constraint public const NOT_NUMERIC_ERROR = 'a2ad9231-e827-485f-8a1e-ef4d9a6d5c2e'; public const INVALID_FORMAT_ERROR = 'a8faedbf-1c2f-4695-8d22-55783be8efed'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::NOT_NUMERIC_ERROR => 'NOT_NUMERIC_ERROR', 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 31691d4b90c14..282366603a8e9 100644 --- a/src/Symfony/Component/Validator/Constraints/Choice.php +++ b/src/Symfony/Component/Validator/Constraints/Choice.php @@ -26,12 +26,17 @@ class Choice extends Constraint public const TOO_FEW_ERROR = '11edd7eb-5872-4b6e-9f12-89923999fd0e'; public const TOO_MANY_ERROR = '9bd98e49-211c-433f-8630-fd1c2d0f08c3'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::NO_SUCH_CHOICE_ERROR => 'NO_SUCH_CHOICE_ERROR', self::TOO_FEW_ERROR => 'TOO_FEW_ERROR', 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 387c5996a053d..c40669e824dba 100644 --- a/src/Symfony/Component/Validator/Constraints/Cidr.php +++ b/src/Symfony/Component/Validator/Constraints/Cidr.php @@ -29,7 +29,7 @@ class Cidr extends Constraint public const INVALID_CIDR_ERROR = '5649e53a-5afb-47c5-a360-ffbab3be8567'; public const OUT_OF_RANGE_ERROR = 'b9f14a51-acbd-401a-a078-8c6b204ab32f'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_CIDR_ERROR => 'INVALID_CIDR_ERROR', self::OUT_OF_RANGE_ERROR => 'OUT_OF_RANGE_VIOLATION', ]; @@ -40,6 +40,11 @@ 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 42800e35c9df9..89515960324b8 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -25,11 +25,16 @@ class Collection extends Composite public const MISSING_FIELD_ERROR = '2fa2158c-2a7f-484b-98aa-975522539ff8'; public const NO_SUCH_FIELD_ERROR = '7703c766-b5d5-4cef-ace7-ae0dd82304e9'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::MISSING_FIELD_ERROR => 'MISSING_FIELD_ERROR', 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 f8ffc3750efa4..ea5d4182865d3 100644 --- a/src/Symfony/Component/Validator/Constraints/Count.php +++ b/src/Symfony/Component/Validator/Constraints/Count.php @@ -28,13 +28,18 @@ class Count extends Constraint public const NOT_EQUAL_COUNT_ERROR = '9fe5d43f-3784-4ece-a0e1-473fc02dadbc'; public const NOT_DIVISIBLE_BY_ERROR = DivisibleBy::NOT_DIVISIBLE_BY; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TOO_FEW_ERROR => 'TOO_FEW_ERROR', self::TOO_MANY_ERROR => 'TOO_MANY_ERROR', self::NOT_EQUAL_COUNT_ERROR => 'NOT_EQUAL_COUNT_ERROR', 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 5493da4e65cf5..03df0206bbedb 100644 --- a/src/Symfony/Component/Validator/Constraints/Country.php +++ b/src/Symfony/Component/Validator/Constraints/Country.php @@ -26,10 +26,15 @@ class Country extends Constraint { public const NO_SUCH_COUNTRY_ERROR = '8f900c12-61bd-455d-9398-996cd040f7f0'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 e1510dafe38f2..d1e2e27834304 100644 --- a/src/Symfony/Component/Validator/Constraints/CssColor.php +++ b/src/Symfony/Component/Validator/Constraints/CssColor.php @@ -37,10 +37,15 @@ class CssColor extends Constraint public const HSLA = 'hsla'; public const INVALID_FORMAT_ERROR = '454ab47b-aacf-4059-8f26-184b2dc9d48d'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 d143ee0e72fe3..5713d803e8cd7 100644 --- a/src/Symfony/Component/Validator/Constraints/Currency.php +++ b/src/Symfony/Component/Validator/Constraints/Currency.php @@ -27,10 +27,15 @@ class Currency extends Constraint { public const NO_SUCH_CURRENCY_ERROR = '69945ac1-2db4-405f-bec7-d2772f73df52'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 ed4014b40768b..1ca3bee11f359 100644 --- a/src/Symfony/Component/Validator/Constraints/Date.php +++ b/src/Symfony/Component/Validator/Constraints/Date.php @@ -25,11 +25,16 @@ class Date extends Constraint public const INVALID_FORMAT_ERROR = '69819696-02ac-4a99-9ff0-14e127c4d1bc'; public const INVALID_DATE_ERROR = '3c184ce5-b31d-4de7-8b76-326da7b2be93'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', 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 514717dada0e5..f187f8b266850 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTime.php +++ b/src/Symfony/Component/Validator/Constraints/DateTime.php @@ -26,12 +26,17 @@ class DateTime extends Constraint public const INVALID_DATE_ERROR = 'd52afa47-620d-4d99-9f08-f4d85b36e33c'; public const INVALID_TIME_ERROR = '5e797c9d-74f7-4098-baa3-94390c447b27'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', self::INVALID_DATE_ERROR => 'INVALID_DATE_ERROR', 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 d3f5cd713ad13..90164aab286b6 100644 --- a/src/Symfony/Component/Validator/Constraints/DivisibleBy.php +++ b/src/Symfony/Component/Validator/Constraints/DivisibleBy.php @@ -22,9 +22,14 @@ class DivisibleBy extends AbstractComparison { public const NOT_DIVISIBLE_BY = '6d99d6c3-1464-4ccf-bdc7-14d083cf455c'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 63968dc9ce358..a0b7a2e9c3f88 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -37,10 +37,15 @@ class Email extends Constraint self::VALIDATION_MODE_LOOSE, ]; - protected static $errorNames = [ + 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; diff --git a/src/Symfony/Component/Validator/Constraints/EqualTo.php b/src/Symfony/Component/Validator/Constraints/EqualTo.php index 09ab4f0f52d96..03769ce8a84a8 100644 --- a/src/Symfony/Component/Validator/Constraints/EqualTo.php +++ b/src/Symfony/Component/Validator/Constraints/EqualTo.php @@ -23,9 +23,14 @@ class EqualTo extends AbstractComparison { public const NOT_EQUAL_ERROR = '478618a7-95ba-473d-9101-cabd45e49115'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 6bddca317a960..19c4cb54d665b 100644 --- a/src/Symfony/Component/Validator/Constraints/Expression.php +++ b/src/Symfony/Component/Validator/Constraints/Expression.php @@ -28,10 +28,15 @@ class Expression extends Constraint { public const EXPRESSION_FAILED_ERROR = '6b3befbc-2f01-4ddf-be21-b57898905284'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 index f370cf01b352e..dda1e5be78cde 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php @@ -24,10 +24,15 @@ class ExpressionLanguageSyntax extends Constraint { public const EXPRESSION_LANGUAGE_SYNTAX_ERROR = '1766a3f3-ff03-40eb-b053-ab7aa23d988a'; - protected static $errorNames = [ + 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; diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index e81618e71e324..577f9ed3d6f61 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -33,7 +33,7 @@ class File extends Constraint public const TOO_LARGE_ERROR = 'df8637af-d466-48c6-a59d-e7126250a654'; public const INVALID_MIME_TYPE_ERROR = '744f00bc-4389-4c74-92de-9a43cde55534'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::NOT_FOUND_ERROR => 'NOT_FOUND_ERROR', self::NOT_READABLE_ERROR => 'NOT_READABLE_ERROR', self::EMPTY_ERROR => 'EMPTY_ERROR', @@ -41,6 +41,11 @@ class File extends Constraint self::INVALID_MIME_TYPE_ERROR => 'INVALID_MIME_TYPE_ERROR', ]; + /** + * @deprecated since Symfony 6.1, use const ERROR_NAMES instead + */ + protected static $errorNames = self::ERROR_NAMES; + public $binaryFormat; public $mimeTypes = []; public $notFoundMessage = 'The file could not be found.'; diff --git a/src/Symfony/Component/Validator/Constraints/GreaterThan.php b/src/Symfony/Component/Validator/Constraints/GreaterThan.php index 41648752a2f35..ce56f1ac1c814 100644 --- a/src/Symfony/Component/Validator/Constraints/GreaterThan.php +++ b/src/Symfony/Component/Validator/Constraints/GreaterThan.php @@ -23,9 +23,14 @@ class GreaterThan extends AbstractComparison { public const TOO_LOW_ERROR = '778b7ae0-84d3-481a-9dec-35fdb64b1d78'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 86ff44e8c3430..c962f7964f4ba 100644 --- a/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php +++ b/src/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php @@ -23,9 +23,14 @@ class GreaterThanOrEqual extends AbstractComparison { public const TOO_LOW_ERROR = 'ea4e51d1-3342-48bd-87f1-9e672cd90cad'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 3fe57f4ae6ea7..cbf33cd8d0279 100644 --- a/src/Symfony/Component/Validator/Constraints/Hostname.php +++ b/src/Symfony/Component/Validator/Constraints/Hostname.php @@ -24,10 +24,15 @@ class Hostname extends Constraint { public const INVALID_HOSTNAME_ERROR = '7057ffdb-0af4-4f7e-bd5e-e9acfa6d7a2d'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 06b07fc7211a5..684df2e561e5b 100644 --- a/src/Symfony/Component/Validator/Constraints/Iban.php +++ b/src/Symfony/Component/Validator/Constraints/Iban.php @@ -30,7 +30,7 @@ class Iban extends Constraint public const INVALID_FORMAT_ERROR = 'c8d318f1-2ecc-41ba-b983-df70d225cf5a'; public const NOT_SUPPORTED_COUNTRY_CODE_ERROR = 'e2c259f3-4b46-48e6-b72e-891658158ec8'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_COUNTRY_CODE_ERROR => 'INVALID_COUNTRY_CODE_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR', @@ -38,6 +38,11 @@ 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 b3d6b92cba7e6..50ec5e1297a15 100644 --- a/src/Symfony/Component/Validator/Constraints/IdenticalTo.php +++ b/src/Symfony/Component/Validator/Constraints/IdenticalTo.php @@ -23,9 +23,14 @@ class IdenticalTo extends AbstractComparison { public const NOT_IDENTICAL_ERROR = '2a8cc50f-58a2-4536-875e-060a2ce69ed5'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 3497ce4064ac9..8a0a2cef6f95a 100644 --- a/src/Symfony/Component/Validator/Constraints/Image.php +++ b/src/Symfony/Component/Validator/Constraints/Image.php @@ -37,7 +37,7 @@ class Image extends File // Include the mapping from the base class - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::NOT_FOUND_ERROR => 'NOT_FOUND_ERROR', self::NOT_READABLE_ERROR => 'NOT_READABLE_ERROR', self::EMPTY_ERROR => 'EMPTY_ERROR', @@ -58,6 +58,11 @@ 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 a58d9b2d74e43..69a73a700e770 100644 --- a/src/Symfony/Component/Validator/Constraints/Ip.php +++ b/src/Symfony/Component/Validator/Constraints/Ip.php @@ -48,7 +48,7 @@ class Ip extends Constraint public const INVALID_IP_ERROR = 'b1b427ae-9f6f-41b0-aa9b-84511fbb3c5b'; - protected static $versions = [ + protected const VERSIONS = [ self::V4, self::V6, self::ALL, @@ -66,10 +66,20 @@ class Ip extends Constraint self::ALL_ONLY_PUBLIC, ]; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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.'; diff --git a/src/Symfony/Component/Validator/Constraints/IsFalse.php b/src/Symfony/Component/Validator/Constraints/IsFalse.php index 0611426083f80..26042e2ee12bf 100644 --- a/src/Symfony/Component/Validator/Constraints/IsFalse.php +++ b/src/Symfony/Component/Validator/Constraints/IsFalse.php @@ -24,10 +24,15 @@ class IsFalse extends Constraint { public const NOT_FALSE_ERROR = 'd53a91b0-def3-426a-83d7-269da7ab4200'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 62023848bf6dd..5084c268a1d78 100644 --- a/src/Symfony/Component/Validator/Constraints/IsNull.php +++ b/src/Symfony/Component/Validator/Constraints/IsNull.php @@ -24,10 +24,15 @@ class IsNull extends Constraint { public const NOT_NULL_ERROR = '60d2f30b-8cfa-4372-b155-9656634de120'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 080cd61b1c8a3..8ee9f729d04db 100644 --- a/src/Symfony/Component/Validator/Constraints/IsTrue.php +++ b/src/Symfony/Component/Validator/Constraints/IsTrue.php @@ -24,10 +24,15 @@ class IsTrue extends Constraint { public const NOT_TRUE_ERROR = '2beabf1c-54c0-4882-a928-05249b26e23b'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 7375647937e7f..41110da1b4e02 100644 --- a/src/Symfony/Component/Validator/Constraints/Isbn.php +++ b/src/Symfony/Component/Validator/Constraints/Isbn.php @@ -33,7 +33,7 @@ class Isbn extends Constraint public const CHECKSUM_FAILED_ERROR = '2881c032-660f-46b6-8153-d352d9706640'; public const TYPE_NOT_RECOGNIZED_ERROR = 'fa54a457-f042-441f-89c4-066ee5bdd3e1'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', @@ -41,6 +41,11 @@ 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 99113ddc2744a..1522044befa87 100644 --- a/src/Symfony/Component/Validator/Constraints/Isin.php +++ b/src/Symfony/Component/Validator/Constraints/Isin.php @@ -29,12 +29,17 @@ class Isin extends Constraint public const INVALID_PATTERN_ERROR = '3d08ce0-ded9-a93d-9216-17ac21265b65e'; public const INVALID_CHECKSUM_ERROR = '32089b-0ee1-93ba-399e-aa232e62f2d29d'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_LENGTH_ERROR => 'INVALID_LENGTH_ERROR', self::INVALID_PATTERN_ERROR => 'INVALID_PATTERN_ERROR', 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 d0ccb44997f83..a11f022e63e16 100644 --- a/src/Symfony/Component/Validator/Constraints/Issn.php +++ b/src/Symfony/Component/Validator/Constraints/Issn.php @@ -30,7 +30,7 @@ class Issn extends Constraint public const INVALID_CASE_ERROR = '7b6dd393-7523-4a6c-b84d-72b91bba5e1a'; public const CHECKSUM_FAILED_ERROR = 'b0f92dbc-667c-48de-b526-ad9586d43e85'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', self::MISSING_HYPHEN_ERROR => 'MISSING_HYPHEN_ERROR', @@ -39,6 +39,11 @@ 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 7e79cd1ba8c9a..f2826d28e39bc 100644 --- a/src/Symfony/Component/Validator/Constraints/Json.php +++ b/src/Symfony/Component/Validator/Constraints/Json.php @@ -24,10 +24,15 @@ class Json extends Constraint { public const INVALID_JSON_ERROR = '0789c8ad-2d2b-49a4-8356-e2ce63998504'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 f8b622964fbb0..e3c2ce9629dde 100644 --- a/src/Symfony/Component/Validator/Constraints/Language.php +++ b/src/Symfony/Component/Validator/Constraints/Language.php @@ -26,10 +26,15 @@ class Language extends Constraint { public const NO_SUCH_LANGUAGE_ERROR = 'ee65fec4-9a20-4202-9f39-ca558cd7bdf7'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 65baba27d7f7b..a25bf520ea608 100644 --- a/src/Symfony/Component/Validator/Constraints/Length.php +++ b/src/Symfony/Component/Validator/Constraints/Length.php @@ -29,13 +29,18 @@ class Length extends Constraint public const NOT_EQUAL_LENGTH_ERROR = '4b6f5c76-22b4-409d-af16-fbe823ba9332'; public const INVALID_CHARACTERS_ERROR = '35e6a710-aa2e-4719-b58e-24b35749b767'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', self::NOT_EQUAL_LENGTH_ERROR => 'NOT_EQUAL_LENGTH_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', ]; + /** + * @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 acd6c9e66ffc7..cf4144d6d26d3 100644 --- a/src/Symfony/Component/Validator/Constraints/LessThan.php +++ b/src/Symfony/Component/Validator/Constraints/LessThan.php @@ -23,9 +23,14 @@ class LessThan extends AbstractComparison { public const TOO_HIGH_ERROR = '079d7420-2d13-460c-8756-de810eeb37d2'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 6f72845940704..84e31abfc0213 100644 --- a/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php +++ b/src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php @@ -23,9 +23,14 @@ class LessThanOrEqual extends AbstractComparison { public const TOO_HIGH_ERROR = '30fbb013-d015-4232-8b3b-8f3be97a7e14'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 af0d54b3b21cf..30f0ffd6eb30e 100644 --- a/src/Symfony/Component/Validator/Constraints/Locale.php +++ b/src/Symfony/Component/Validator/Constraints/Locale.php @@ -26,10 +26,15 @@ class Locale extends Constraint { public const NO_SUCH_LOCALE_ERROR = 'a0af4293-1f1a-4a1c-a328-979cba6182a2'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 da1b063b2f2a6..198fb29baf29b 100644 --- a/src/Symfony/Component/Validator/Constraints/Luhn.php +++ b/src/Symfony/Component/Validator/Constraints/Luhn.php @@ -29,11 +29,16 @@ class Luhn extends Constraint public const INVALID_CHARACTERS_ERROR = 'dfad6d23-1b74-4374-929b-5cbb56fc0d9e'; public const CHECKSUM_FAILED_ERROR = '4d760774-3f50-4cd5-a6d5-b10a3299d8d3'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', 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 277e22d60d3c0..38637ad202603 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlank.php @@ -26,10 +26,15 @@ class NotBlank extends Constraint { public const IS_BLANK_ERROR = 'c1051bb4-d103-4f74-8988-acbcafc7fdc3'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 3cde036fb9a7d..3329d3c1abc0d 100644 --- a/src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php +++ b/src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php @@ -26,7 +26,14 @@ class NotCompromisedPassword extends Constraint { public const COMPROMISED_PASSWORD_ERROR = 'd9bcdbfe-a9d6-4bfa-a8ff-da5fd93e0f6d'; - protected static $errorNames = [self::COMPROMISED_PASSWORD_ERROR => 'COMPROMISED_PASSWORD_ERROR']; + protected const ERROR_NAMES = [ + 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; diff --git a/src/Symfony/Component/Validator/Constraints/NotEqualTo.php b/src/Symfony/Component/Validator/Constraints/NotEqualTo.php index 4b2accdf75286..9a5c07b21e2aa 100644 --- a/src/Symfony/Component/Validator/Constraints/NotEqualTo.php +++ b/src/Symfony/Component/Validator/Constraints/NotEqualTo.php @@ -23,9 +23,14 @@ class NotEqualTo extends AbstractComparison { public const IS_EQUAL_ERROR = 'aa2e33da-25c8-4d76-8c6c-812f02ea89dd'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 82ee014eb6fb4..206c106137322 100644 --- a/src/Symfony/Component/Validator/Constraints/NotIdenticalTo.php +++ b/src/Symfony/Component/Validator/Constraints/NotIdenticalTo.php @@ -23,9 +23,14 @@ class NotIdenticalTo extends AbstractComparison { public const IS_IDENTICAL_ERROR = '4aaac518-0dda-4129-a6d9-e216b9b454a0'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 8deb3f0d06d14..2fd4123cdfcae 100644 --- a/src/Symfony/Component/Validator/Constraints/NotNull.php +++ b/src/Symfony/Component/Validator/Constraints/NotNull.php @@ -24,10 +24,15 @@ class NotNull extends Constraint { public const IS_NULL_ERROR = 'ad32d13f-c3d4-423b-909a-857b961eb720'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 49a0103f9c24f..ca5cba3c985ae 100644 --- a/src/Symfony/Component/Validator/Constraints/Range.php +++ b/src/Symfony/Component/Validator/Constraints/Range.php @@ -31,13 +31,18 @@ class Range extends Constraint public const TOO_HIGH_ERROR = '2d28afcb-e32e-45fb-a815-01c431a86a69'; public const TOO_LOW_ERROR = '76454e69-502c-46c5-9643-f447d837c4d5'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', self::NOT_IN_RANGE_ERROR => 'NOT_IN_RANGE_ERROR', self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR', 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 5709daaf58cc6..74381eaf71a7f 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -25,10 +25,15 @@ class Regex extends Constraint { public const REGEX_FAILED_ERROR = 'de1e3db3-5ed4-4941-aae4-59f3667cc3a3'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 b23fd3ddfbf2b..f281ae1ee85b3 100644 --- a/src/Symfony/Component/Validator/Constraints/Time.php +++ b/src/Symfony/Component/Validator/Constraints/Time.php @@ -25,11 +25,16 @@ class Time extends Constraint public const INVALID_FORMAT_ERROR = '9d27b2bb-f755-4fbf-b725-39b1edbdebdf'; public const INVALID_TIME_ERROR = '8532f9e1-84b2-4d67-8989-0818bc38533b'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', 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 2cc47985938bb..c9279a9cdb319 100644 --- a/src/Symfony/Component/Validator/Constraints/Timezone.php +++ b/src/Symfony/Component/Validator/Constraints/Timezone.php @@ -34,13 +34,18 @@ class Timezone extends Constraint public $intlCompatible = false; public $message = 'This value is not a valid timezone.'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TIMEZONE_IDENTIFIER_ERROR => 'TIMEZONE_IDENTIFIER_ERROR', self::TIMEZONE_IDENTIFIER_IN_ZONE_ERROR => 'TIMEZONE_IDENTIFIER_IN_ZONE_ERROR', self::TIMEZONE_IDENTIFIER_IN_COUNTRY_ERROR => 'TIMEZONE_IDENTIFIER_IN_COUNTRY_ERROR', 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 425f5dcc1e910..5d8aa1b21b707 100644 --- a/src/Symfony/Component/Validator/Constraints/Type.php +++ b/src/Symfony/Component/Validator/Constraints/Type.php @@ -24,10 +24,15 @@ class Type extends Constraint { public const INVALID_TYPE_ERROR = 'ba785a8c-82cb-4283-967c-3cf342181b40'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 fc4f810955abb..ece08c721cd73 100644 --- a/src/Symfony/Component/Validator/Constraints/Ulid.php +++ b/src/Symfony/Component/Validator/Constraints/Ulid.php @@ -26,13 +26,18 @@ class Ulid extends Constraint public const INVALID_CHARACTERS_ERROR = 'e4155739-5135-4258-9c81-ae7b44b5311e'; public const TOO_LARGE_ERROR = 'df8cfb9a-ce6d-4a69-ae5a-eea7ab6f278b'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', 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 a4349d83727dd..a18807e15239c 100644 --- a/src/Symfony/Component/Validator/Constraints/Unique.php +++ b/src/Symfony/Component/Validator/Constraints/Unique.php @@ -25,10 +25,15 @@ class Unique extends Constraint { public const IS_NOT_UNIQUE = '7911c98d-b845-4da0-94b7-a8dac36bc55a'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 0fadca99434a6..e3bea2e1b3d67 100644 --- a/src/Symfony/Component/Validator/Constraints/Url.php +++ b/src/Symfony/Component/Validator/Constraints/Url.php @@ -25,10 +25,15 @@ class Url extends Constraint { public const INVALID_URL_ERROR = '57c2f299-1154-4870-89bb-ef3b1f5ad229'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ 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 f143c6368da3b..b805e5e90cf74 100644 --- a/src/Symfony/Component/Validator/Constraints/Uuid.php +++ b/src/Symfony/Component/Validator/Constraints/Uuid.php @@ -30,7 +30,7 @@ class Uuid extends Constraint public const INVALID_VERSION_ERROR = '21ba13b4-b185-4882-ac6f-d147355987eb'; public const INVALID_VARIANT_ERROR = '164ef693-2b9d-46de-ad7f-836201f0c2db'; - protected static $errorNames = [ + protected const ERROR_NAMES = [ self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', @@ -39,6 +39,11 @@ 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/composer.json b/src/Symfony/Component/Validator/composer.json index e3d638c95e4e4..9ae5623300fc4 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php81": "^1.22",
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: