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

Commit

Permalink
Prepare to PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Jun 23, 2017
1 parent 92035a4 commit 1a0717c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bin/update_hostname_validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ function getNewValidTlds($string)
function getPunycodeDecoder()
{
if (function_exists('idn_to_utf8')) {
return 'idn_to_utf8';
return function($domain) {
return idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46);
};
}

$hostnameValidator = new Hostname();
Expand Down
4 changes: 2 additions & 2 deletions src/EmailAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public function isValid($value)
protected function idnToAscii($email)
{
if (extension_loaded('intl')) {
return (idn_to_ascii($email) ?: $email);
return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
}
return $email;
}
Expand All @@ -553,7 +553,7 @@ protected function idnToUtf8($email)
// the source string in those cases.
// But not when the source string is long enough.
// Thus we default to source string ourselves.
return idn_to_utf8($email) ?: $email;
return idn_to_utf8($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email;
}
return $email;
}
Expand Down
3 changes: 2 additions & 1 deletion src/File/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Zend\Validator\File;

use Countable;
use Zend\Validator\AbstractValidator;
use Zend\Validator\Exception;

Expand Down Expand Up @@ -109,7 +110,7 @@ public function getFiles($file = null)
*/
public function setFiles($files = [])
{
if (count($files) === 0) {
if ((is_array($files) || $files instanceof Countable) && count($files) === 0) {
$this->options['files'] = $_FILES;
} else {
$this->options['files'] = $files;
Expand Down

0 comments on commit 1a0717c

Please sign in to comment.