From aa84cfdb7b1f6634a199ee482c002f7b4ed7d55a Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 10:14:45 +0200 Subject: [PATCH] [Validator] Remove fallback dependency checks --- src/Symfony/Component/Validator/Constraints/Bic.php | 3 +-- .../Component/Validator/Constraints/BicValidator.php | 10 +--------- .../Component/Validator/Constraints/Country.php | 3 +-- .../Validator/Constraints/CountryValidator.php | 5 ----- .../Component/Validator/Constraints/Currency.php | 3 +-- .../Validator/Constraints/CurrencyValidator.php | 5 ----- src/Symfony/Component/Validator/Constraints/Email.php | 3 +-- .../Component/Validator/Constraints/EmailValidator.php | 5 ----- .../Component/Validator/Constraints/Expression.php | 3 +-- .../Validator/Constraints/ExpressionValidator.php | 4 ---- .../Component/Validator/Constraints/Language.php | 3 +-- .../Validator/Constraints/LanguageValidator.php | 5 ----- src/Symfony/Component/Validator/Constraints/Locale.php | 3 +-- .../Validator/Constraints/LocaleValidator.php | 5 ----- 14 files changed, 8 insertions(+), 52 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/Bic.php b/src/Symfony/Component/Validator/Constraints/Bic.php index 8164bf6c2d961..0813728b4a96a 100644 --- a/src/Symfony/Component/Validator/Constraints/Bic.php +++ b/src/Symfony/Component/Validator/Constraints/Bic.php @@ -48,8 +48,7 @@ class Bic extends Constraint public function __construct($options = null) { if (!class_exists(Countries::class)) { - // throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".'); } if (isset($options['iban']) && isset($options['ibanPropertyPath'])) { diff --git a/src/Symfony/Component/Validator/Constraints/BicValidator.php b/src/Symfony/Component/Validator/Constraints/BicValidator.php index bc306d35e805e..3fd84e69f649d 100644 --- a/src/Symfony/Component/Validator/Constraints/BicValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BicValidator.php @@ -104,15 +104,7 @@ public function validate($value, Constraint $constraint) return; } - // @deprecated since Symfony 4.2, will throw in 5.0 - if (class_exists(Countries::class)) { - $validCountryCode = Countries::exists(substr($canonicalize, 4, 2)); - } else { - $validCountryCode = ctype_alpha(substr($canonicalize, 4, 2)); - // throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".'); - } - - if (!$validCountryCode) { + if (!Countries::exists(substr($canonicalize, 4, 2))) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(Bic::INVALID_COUNTRY_CODE_ERROR) diff --git a/src/Symfony/Component/Validator/Constraints/Country.php b/src/Symfony/Component/Validator/Constraints/Country.php index 9c8cd4ada2849..1eaaa985fc144 100644 --- a/src/Symfony/Component/Validator/Constraints/Country.php +++ b/src/Symfony/Component/Validator/Constraints/Country.php @@ -34,8 +34,7 @@ class Country extends Constraint public function __construct($options = null) { if (!class_exists(Countries::class)) { - // throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/CountryValidator.php b/src/Symfony/Component/Validator/Constraints/CountryValidator.php index 21dd62b034e19..ca2867f09495e 100644 --- a/src/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Countries; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Countries::class)) { - throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".'); - } - $value = (string) $value; if (!Countries::exists($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Currency.php b/src/Symfony/Component/Validator/Constraints/Currency.php index 580a5cb6161d8..2ee5ae37890fa 100644 --- a/src/Symfony/Component/Validator/Constraints/Currency.php +++ b/src/Symfony/Component/Validator/Constraints/Currency.php @@ -35,8 +35,7 @@ class Currency extends Constraint public function __construct($options = null) { if (!class_exists(Currencies::class)) { - // throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php index a6352c3263498..3108f51443430 100644 --- a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Currencies; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -43,10 +42,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Currencies::class)) { - throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".'); - } - $value = (string) $value; if (!Currencies::exists($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index bb3ea5ce020ca..e780d36c7528d 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -97,8 +97,7 @@ public function __construct($options = null) parent::__construct($options); if ((self::VALIDATION_MODE_STRICT === $this->mode || true === $this->strict) && !class_exists(StrictEmailValidator::class)) { - // throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__)); - @trigger_error(sprintf('Using the "%s" constraint in strict mode without the "egulias/email-validator" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__)); } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index b7306d2b0e174..c3a15a2354ae7 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -15,7 +15,6 @@ use Egulias\EmailValidator\Validation\NoRFCWarningsValidation; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -104,10 +103,6 @@ public function validate($value, Constraint $constraint) } if (Email::VALIDATION_MODE_STRICT === $constraint->mode) { - if (!class_exists('\Egulias\EmailValidator\EmailValidator')) { - throw new LogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0'); - } - $strictValidator = new \Egulias\EmailValidator\EmailValidator(); if (interface_exists(EmailValidation::class) && !$strictValidator->isValid($value, new NoRFCWarningsValidation())) { diff --git a/src/Symfony/Component/Validator/Constraints/Expression.php b/src/Symfony/Component/Validator/Constraints/Expression.php index 42e7248819f31..4c79ea0f22f99 100644 --- a/src/Symfony/Component/Validator/Constraints/Expression.php +++ b/src/Symfony/Component/Validator/Constraints/Expression.php @@ -37,8 +37,7 @@ class Expression extends Constraint public function __construct($options = null) { if (!class_exists(ExpressionLanguage::class)) { - // throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__)); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/expression-language" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__)); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index b72a83365b7b7..b5476910e1592 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -54,9 +53,6 @@ public function validate($value, Constraint $constraint) private function getExpressionLanguage() { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { - throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); - } $this->expressionLanguage = new ExpressionLanguage(); } diff --git a/src/Symfony/Component/Validator/Constraints/Language.php b/src/Symfony/Component/Validator/Constraints/Language.php index c8e242d187111..6b3ac769f9723 100644 --- a/src/Symfony/Component/Validator/Constraints/Language.php +++ b/src/Symfony/Component/Validator/Constraints/Language.php @@ -34,8 +34,7 @@ class Language extends Constraint public function __construct($options = null) { if (!class_exists(Languages::class)) { - // throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php index 4f9b118d8416c..96c36985a8953 100644 --- a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Languages; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Languages::class)) { - throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".'); - } - $value = (string) $value; if (!Languages::exists($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Locale.php b/src/Symfony/Component/Validator/Constraints/Locale.php index faff564d31746..b5b31986334aa 100644 --- a/src/Symfony/Component/Validator/Constraints/Locale.php +++ b/src/Symfony/Component/Validator/Constraints/Locale.php @@ -39,8 +39,7 @@ public function __construct($options = null) } if (!class_exists(Locales::class)) { - // throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index f965a0fcf21e8..760131279a4ff 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Locales; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Locales::class)) { - throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".'); - } - $inputValue = (string) $value; $value = $inputValue; if ($constraint->canonicalize) {