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

Commit

Permalink
Merge branch 'hotfix/25' into develop
Browse files Browse the repository at this point in the history
Forward port #25
  • Loading branch information
weierophinney committed Sep 3, 2015
2 parents 8dedd74 + 8f12680 commit 893a7c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ All notable changes to this project will be documented in this file, in reverse
- [#35](https://github.com/zendframework/zend-validator/pull/35) modifies the
`NotEmpty` validator to no longer treat the float `0.0` as an empty value for
purposes of validation.
- [#25](https://github.com/zendframework/zend-validator/pull/25) fixes the
`Date` validator to check against `DateTimeImmutable` and not
`DateTimeInterface` (as PHP has restrictions currently on how the latter can
be used).

## 2.5.2 - 2015-07-16

Expand Down
5 changes: 2 additions & 3 deletions src/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Zend\Validator;

use DateTime;
use DateTimeInterface;
use DateTimeImmutable;
use Traversable;

/**
Expand Down Expand Up @@ -127,8 +127,7 @@ public function isValid($value)
*/
protected function convertToDateTime($param, $addErrors = true)
{
// @TODO: when minimum dependency will be PHP 5.5, we can only keep check against DateTimeInterface
if ($param instanceof DateTime || $param instanceof DateTimeInterface) {
if ($param instanceof DateTime || $param instanceof DateTimeImmutable) {
return $param;
}

Expand Down
4 changes: 0 additions & 4 deletions test/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ public function testBasic($input, $format, $result)

public function testDateTimeImmutable()
{
if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('`DateTimeImmutable` is only supported in PHP >=5.5.0');
}

$this->assertTrue($this->validator->isValid(new DateTimeImmutable()));
}

Expand Down

0 comments on commit 893a7c7

Please sign in to comment.