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

Commit

Permalink
Merge branch 'feature/7263'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 25, 2015
4 parents ed4e6cb + f979380 + 2351779 + fa2c6ee commit 320207a
Show file tree
Hide file tree
Showing 7 changed files with 21,803 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/DateStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function isValid($value)
$absoluteValueDate = new DateTime($valueDate->format('Y-m-d H:i:s'), new DateTimeZone('UTC'));
$absoluteBaseDate = new DateTime($baseDate->format('Y-m-d H:i:s'), new DateTimeZone('UTC'));

$timeDiff = $absoluteValueDate->diff($absoluteBaseDate, true);
$timeDiff = $absoluteValueDate->diff($absoluteBaseDate, 1);
$diffParts = array_combine($unitKeys, explode('|', $timeDiff->format('%y|%m|%d|%h|%i|%s')));

if (5 === $partCounts["0"]) {
Expand Down
9 changes: 6 additions & 3 deletions src/EmailAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,12 @@ protected function validateHostnamePart()
*/
protected function splitEmailParts($value)
{
$value = is_string($value) ? $value : '';

// Split email address up and disallow '..'
if ((strpos($value, '..') !== false) or
(!preg_match('/^(.+)@([^@]+)$/', $value, $matches))) {
if (strpos($value, '..') !== false
|| ! preg_match('/^(.+)@([^@]+)$/', $value, $matches)
) {
return false;
}

Expand Down Expand Up @@ -526,7 +529,7 @@ public function isValid($value)
protected function idnToAscii($email)
{
if (extension_loaded('intl')) {
return idn_to_ascii($email);
return (idn_to_ascii($email) ?: $email);
}
return $email;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ protected function fmod($x, $y)
}

//find the maximum precision from both input params to give accurate results
$precision = strlen(substr($x, strpos($x, '.')+1)) + strlen(substr($y, strpos($y, '.')+1));
$xFloatSegment = substr($x, strpos($x, '.') + 1) ?: '';
$yFloatSegment = substr($y, strpos($y, '.') + 1) ?: '';
$precision = strlen($xFloatSegment) + strlen($yFloatSegment);

return round($x - $y * floor($x / $y), $precision);
}
Expand Down
17 changes: 15 additions & 2 deletions src/ValidatorPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

class ValidatorPluginManager extends AbstractPluginManager
{
/**
* Default aliases
*
* @var array
*/
protected $aliases = array(
'Zend\I18n\Validator\Float'=> 'Zend\I18n\Validator\IsFloat',
'Zend\I18n\Validator\Int' => 'Zend\I18n\Validator\IsInt',
);

/**
* Default set of validators
*
Expand Down Expand Up @@ -82,17 +92,20 @@ class ValidatorPluginManager extends AbstractPluginManager
'fileupload' => 'Zend\Validator\File\Upload',
'fileuploadfile' => 'Zend\Validator\File\UploadFile',
'filewordcount' => 'Zend\Validator\File\WordCount',
'float' => 'Zend\I18n\Validator\Float',
'float' => 'Zend\I18n\Validator\IsFloat',
'greaterthan' => 'Zend\Validator\GreaterThan',
'hex' => 'Zend\Validator\Hex',
'hostname' => 'Zend\Validator\Hostname',
'iban' => 'Zend\Validator\Iban',
'identical' => 'Zend\Validator\Identical',
'inarray' => 'Zend\Validator\InArray',
'int' => 'Zend\I18n\Validator\Int',
'int' => 'Zend\I18n\Validator\IsInt',
'ip' => 'Zend\Validator\Ip',
'isbn' => 'Zend\Validator\Isbn',
'isfloat' => 'Zend\I18n\Validator\IsFloat',
'isinstanceof' => 'Zend\Validator\IsInstanceOf',
'isint' => 'Zend\I18n\Validator\IsInt',
'ip' => 'Zend\Validator\Ip',
'lessthan' => 'Zend\Validator\LessThan',
'notempty' => 'Zend\Validator\NotEmpty',
'phonenumber' => 'Zend\I18n\Validator\PhoneNumber',
Expand Down
6 changes: 6 additions & 0 deletions test/File/IsCompressedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class IsCompressedTest extends \PHPUnit_Framework_TestCase
{
protected function getMagicMime()
{
// PHP 7 uses yet another version of libmagic, and thus a new magic
// database format.
if (version_compare(PHP_VERSION, '7.0', '>=')) {
return __DIR__ . '/_files/magic.7.mime';
}

// As of PHP >= 5.3.11 and >= 5.4.1 the magic database format has changed.
// http://doc.php.net/downloads/pdf/split/de/File-Information.pdf (page 11)
if (version_compare(PHP_VERSION, '5.4', '>=')
Expand Down
6 changes: 6 additions & 0 deletions test/File/IsImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class IsImageTest extends \PHPUnit_Framework_TestCase
{
protected function getMagicMime()
{
// PHP 7 uses yet another version of libmagic, and thus a new magic
// database format.
if (version_compare(PHP_VERSION, '7.0', '>=')) {
return __DIR__ . '/_files/magic.7.mime';
}

// As of PHP >= 5.3.11 and >= 5.4.1 the magic database format has changed.
// http://doc.php.net/downloads/pdf/split/de/File-Information.pdf (page 11)
if (version_compare(PHP_VERSION, '5.4', '>=')
Expand Down
Loading

0 comments on commit 320207a

Please sign in to comment.