Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 4847db7

Browse files
committed
Prepare to PHP 7.2
1 parent 92035a4 commit 4847db7

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

bin/update_hostname_validator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ function getNewValidTlds($string)
177177
function getPunycodeDecoder()
178178
{
179179
if (function_exists('idn_to_utf8')) {
180-
return 'idn_to_utf8';
180+
return function($domain) {
181+
return idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46);
182+
};
181183
}
182184

183185
$hostnameValidator = new Hostname();

src/EmailAddress.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public function isValid($value)
530530
protected function idnToAscii($email)
531531
{
532532
if (extension_loaded('intl')) {
533-
return (idn_to_ascii($email) ?: $email);
533+
return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
534534
}
535535
return $email;
536536
}
@@ -553,7 +553,7 @@ protected function idnToUtf8($email)
553553
// the source string in those cases.
554554
// But not when the source string is long enough.
555555
// Thus we default to source string ourselves.
556-
return idn_to_utf8($email) ?: $email;
556+
return idn_to_utf8($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email;
557557
}
558558
return $email;
559559
}

src/File/Upload.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Zend\Validator\File;
1111

12+
use Countable;
1213
use Zend\Validator\AbstractValidator;
1314
use Zend\Validator\Exception;
1415

@@ -109,7 +110,7 @@ public function getFiles($file = null)
109110
*/
110111
public function setFiles($files = [])
111112
{
112-
if (count($files) === 0) {
113+
if ((is_array($files) || $files instanceof Countable) && count($files) === 0) {
113114
$this->options['files'] = $_FILES;
114115
} else {
115116
$this->options['files'] = $files;

0 commit comments

Comments
 (0)