comparison vendor/symfony/validator/Constraints/UrlValidator.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
50 50
51 if (null === $value || '' === $value) { 51 if (null === $value || '' === $value) {
52 return; 52 return;
53 } 53 }
54 54
55 if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { 55 if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
56 throw new UnexpectedTypeException($value, 'string'); 56 throw new UnexpectedTypeException($value, 'string');
57 } 57 }
58 58
59 $value = (string) $value; 59 $value = (string) $value;
60 if ('' === $value) { 60 if ('' === $value) {
77 if (true === $constraint->checkDNS) { 77 if (true === $constraint->checkDNS) {
78 $constraint->checkDNS = Url::CHECK_DNS_TYPE_ANY; 78 $constraint->checkDNS = Url::CHECK_DNS_TYPE_ANY;
79 @trigger_error(sprintf('Use of the boolean TRUE for the "checkDNS" option in %s is deprecated. Use Url::CHECK_DNS_TYPE_ANY instead.', Url::class), E_USER_DEPRECATED); 79 @trigger_error(sprintf('Use of the boolean TRUE for the "checkDNS" option in %s is deprecated. Use Url::CHECK_DNS_TYPE_ANY instead.', Url::class), E_USER_DEPRECATED);
80 } 80 }
81 81
82 if (!in_array($constraint->checkDNS, array( 82 if (!\in_array($constraint->checkDNS, [
83 Url::CHECK_DNS_TYPE_ANY, 83 Url::CHECK_DNS_TYPE_ANY,
84 Url::CHECK_DNS_TYPE_A, 84 Url::CHECK_DNS_TYPE_A,
85 Url::CHECK_DNS_TYPE_A6, 85 Url::CHECK_DNS_TYPE_A6,
86 Url::CHECK_DNS_TYPE_AAAA, 86 Url::CHECK_DNS_TYPE_AAAA,
87 Url::CHECK_DNS_TYPE_CNAME, 87 Url::CHECK_DNS_TYPE_CNAME,
90 Url::CHECK_DNS_TYPE_NS, 90 Url::CHECK_DNS_TYPE_NS,
91 Url::CHECK_DNS_TYPE_PTR, 91 Url::CHECK_DNS_TYPE_PTR,
92 Url::CHECK_DNS_TYPE_SOA, 92 Url::CHECK_DNS_TYPE_SOA,
93 Url::CHECK_DNS_TYPE_SRV, 93 Url::CHECK_DNS_TYPE_SRV,
94 Url::CHECK_DNS_TYPE_TXT, 94 Url::CHECK_DNS_TYPE_TXT,
95 ), true)) { 95 ], true)) {
96 throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint %s', get_class($constraint)), array('checkDNS')); 96 throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint %s', \get_class($constraint)), ['checkDNS']);
97 } 97 }
98 98
99 $host = parse_url($value, PHP_URL_HOST); 99 $host = parse_url($value, PHP_URL_HOST);
100 100
101 if (!is_string($host) || !checkdnsrr($host, $constraint->checkDNS)) { 101 if (!\is_string($host) || !checkdnsrr($host, $constraint->checkDNS)) {
102 $this->context->buildViolation($constraint->dnsMessage) 102 $this->context->buildViolation($constraint->dnsMessage)
103 ->setParameter('{{ value }}', $this->formatValue($host)) 103 ->setParameter('{{ value }}', $this->formatValue($host))
104 ->setCode(Url::INVALID_URL_ERROR) 104 ->setCode(Url::INVALID_URL_ERROR)
105 ->addViolation(); 105 ->addViolation();
106 } 106 }