Skip to content

[Validator] Remove fallback dependency checks #31680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Bic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
10 changes: 1 addition & 9 deletions src/Symfony/Component/Validator/Constraints/BicValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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())) {
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down