Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03797a1

Browse files
minor #31680 [Validator] Remove fallback dependency checks (ro0NL)
This PR was merged into the 5.0-dev branch. Discussion ---------- [Validator] Remove fallback dependency checks | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> See #28644 Commits ------- aa84cfd [Validator] Remove fallback dependency checks
2 parents 52756a5 + aa84cfd commit 03797a1

14 files changed

+8
-52
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class Bic extends Constraint
4848
public function __construct($options = null)
4949
{
5050
if (!class_exists(Countries::class)) {
51-
// throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".');
52-
@trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
51+
throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".');
5352
}
5453

5554
if (isset($options['iban']) && isset($options['ibanPropertyPath'])) {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,7 @@ public function validate($value, Constraint $constraint)
104104
return;
105105
}
106106

107-
// @deprecated since Symfony 4.2, will throw in 5.0
108-
if (class_exists(Countries::class)) {
109-
$validCountryCode = Countries::exists(substr($canonicalize, 4, 2));
110-
} else {
111-
$validCountryCode = ctype_alpha(substr($canonicalize, 4, 2));
112-
// throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".');
113-
}
114-
115-
if (!$validCountryCode) {
107+
if (!Countries::exists(substr($canonicalize, 4, 2))) {
116108
$this->context->buildViolation($constraint->message)
117109
->setParameter('{{ value }}', $this->formatValue($value))
118110
->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class Country extends Constraint
3434
public function __construct($options = null)
3535
{
3636
if (!class_exists(Countries::class)) {
37-
// throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".');
38-
@trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
37+
throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".');
3938
}
4039

4140
parent::__construct($options);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Intl\Countries;
1515
use Symfony\Component\Validator\Constraint;
1616
use Symfony\Component\Validator\ConstraintValidator;
17-
use Symfony\Component\Validator\Exception\LogicException;
1817
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1918
use Symfony\Component\Validator\Exception\UnexpectedValueException;
2019

@@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint)
4241
throw new UnexpectedValueException($value, 'string');
4342
}
4443

45-
if (!class_exists(Countries::class)) {
46-
throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".');
47-
}
48-
4944
$value = (string) $value;
5045

5146
if (!Countries::exists($value)) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class Currency extends Constraint
3535
public function __construct($options = null)
3636
{
3737
if (!class_exists(Currencies::class)) {
38-
// throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".');
39-
@trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
38+
throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".');
4039
}
4140

4241
parent::__construct($options);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Intl\Currencies;
1515
use Symfony\Component\Validator\Constraint;
1616
use Symfony\Component\Validator\ConstraintValidator;
17-
use Symfony\Component\Validator\Exception\LogicException;
1817
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1918
use Symfony\Component\Validator\Exception\UnexpectedValueException;
2019

@@ -43,10 +42,6 @@ public function validate($value, Constraint $constraint)
4342
throw new UnexpectedValueException($value, 'string');
4443
}
4544

46-
if (!class_exists(Currencies::class)) {
47-
throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".');
48-
}
49-
5045
$value = (string) $value;
5146

5247
if (!Currencies::exists($value)) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ public function __construct($options = null)
9797
parent::__construct($options);
9898

9999
if ((self::VALIDATION_MODE_STRICT === $this->mode || true === $this->strict) && !class_exists(StrictEmailValidator::class)) {
100-
// throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__));
101-
@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);
100+
throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__));
102101
}
103102

104103
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
1616
use Symfony\Component\Validator\Constraint;
1717
use Symfony\Component\Validator\ConstraintValidator;
18-
use Symfony\Component\Validator\Exception\LogicException;
1918
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
2019
use Symfony\Component\Validator\Exception\UnexpectedValueException;
2120

@@ -104,10 +103,6 @@ public function validate($value, Constraint $constraint)
104103
}
105104

106105
if (Email::VALIDATION_MODE_STRICT === $constraint->mode) {
107-
if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
108-
throw new LogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0');
109-
}
110-
111106
$strictValidator = new \Egulias\EmailValidator\EmailValidator();
112107

113108
if (interface_exists(EmailValidation::class) && !$strictValidator->isValid($value, new NoRFCWarningsValidation())) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class Expression extends Constraint
3737
public function __construct($options = null)
3838
{
3939
if (!class_exists(ExpressionLanguage::class)) {
40-
// throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__));
41-
@trigger_error(sprintf('Using the "%s" constraint without the "symfony/expression-language" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
40+
throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__));
4241
}
4342

4443
parent::__construct($options);

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1515
use Symfony\Component\Validator\Constraint;
1616
use Symfony\Component\Validator\ConstraintValidator;
17-
use Symfony\Component\Validator\Exception\LogicException;
1817
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1918

2019
/**
@@ -54,9 +53,6 @@ public function validate($value, Constraint $constraint)
5453
private function getExpressionLanguage()
5554
{
5655
if (null === $this->expressionLanguage) {
57-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
58-
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
59-
}
6056
$this->expressionLanguage = new ExpressionLanguage();
6157
}
6258

0 commit comments

Comments
 (0)