namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Intl\Intl;
-use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
return;
}
- if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
+ if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
$languages = Intl::getLanguageBundle()->getLanguageNames();
if (!isset($languages[$value])) {
- if ($this->context instanceof ExecutionContextInterface) {
- $this->context->buildViolation($constraint->message)
- ->setParameter('{{ value }}', $this->formatValue($value))
- ->setCode(Language::NO_SUCH_LANGUAGE_ERROR)
- ->addViolation();
- } else {
- $this->buildViolation($constraint->message)
- ->setParameter('{{ value }}', $this->formatValue($value))
- ->setCode(Language::NO_SUCH_LANGUAGE_ERROR)
- ->addViolation();
- }
+ $this->context->buildViolation($constraint->message)
+ ->setParameter('{{ value }}', $this->formatValue($value))
+ ->setCode(Language::NO_SUCH_LANGUAGE_ERROR)
+ ->addViolation();
}
}
}