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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CreditCard extends AbstractValidator
self::INVALID => "Invalid type given. String expected",
self::LENGTH => "The input contains an invalid amount of digits",
self::PREFIX => "The input is not from an allowed institute",
self::SERVICE => "The input seems to be an invalid credit card number.",
self::SERVICE => "The input seems to be an invalid credit card number",
self::SERVICEFAILURE => "An exception has been raised while validating the input",
);

Expand Down
2 changes: 1 addition & 1 deletion src/Explode.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Explode extends AbstractValidator
* @var array
*/
protected $messageTemplates = array(
self::INVALID => "Invalid type given.",
self::INVALID => "Invalid type given",
);

/**
Expand Down
5 changes: 2 additions & 3 deletions src/File/ExcludeMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ public function isValid($value, $file = null)

$mimefile = $this->getMagicFile();
if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) {
$this->finfo = finfo_open($const, $mimefile);
$this->finfo = finfo_open(FILEINFO_MIME_TYPE, $mimefile);
}

if (empty($this->finfo)) {
$this->finfo = finfo_open($const);
$this->finfo = finfo_open(FILEINFO_MIME_TYPE);
}

$this->type = null;
Expand Down
8 changes: 3 additions & 5 deletions src/File/MimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,8 @@ public function setMagicFile($file)
$file
));
} else {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
ErrorHandler::start(E_NOTICE|E_WARNING);
$this->finfo = finfo_open($const, $file);
$this->finfo = finfo_open(FILEINFO_MIME_TYPE, $file);
$error = ErrorHandler::stop();
if (empty($this->finfo)) {
$this->finfo = null;
Expand Down Expand Up @@ -376,16 +375,15 @@ public function isValid($value, $file = null)

$mimefile = $this->getMagicFile();
if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) {
ErrorHandler::start(E_NOTICE|E_WARNING);
$this->finfo = finfo_open($const, $mimefile);
$this->finfo = finfo_open(FILEINFO_MIME_TYPE, $mimefile);
ErrorHandler::stop();
}

if (empty($this->finfo)) {
ErrorHandler::start(E_NOTICE|E_WARNING);
$this->finfo = finfo_open($const);
$this->finfo = finfo_open(FILEINFO_MIME_TYPE);
ErrorHandler::stop();
}

Expand Down
4 changes: 2 additions & 2 deletions src/File/WordCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class WordCount extends AbstractValidator
* @var array Error message templates
*/
protected $messageTemplates = array(
self::TOO_MUCH => "Too many words, maximum '%max%' are allowed but '%count%' were counted.",
self::TOO_LESS => "Too less words, minimum '%min%' are expected but '%count%' were counted",
self::TOO_MUCH => "Too many words, maximum '%max%' are allowed but '%count%' were counted",
self::TOO_LESS => "Too few words, minimum '%min%' are expected but '%count%' were counted",
self::NOT_FOUND => "File is not readable or does not exist",
);

Expand Down
2 changes: 1 addition & 1 deletion src/InArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class InArray extends AbstractValidator
*/
public function getHaystack()
{
if ($this->haystack == null) {
if ($this->haystack === null) {
throw new Exception\RuntimeException('haystack option is mandatory');
}
return $this->haystack;
Expand Down
6 changes: 3 additions & 3 deletions test/InArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function testGetHaystack()
$this->assertEquals(array(1, 2, 3), $this->validator->getHaystack());
}

public function testSetEmptyHaystack()
public function testUnsetHaystackRaisesException()
{
$this->validator->setHaystack(array());
$validator = new InArray();
$this->setExpectedException(
'Zend\Validator\Exception\RuntimeException',
'haystack option is mandatory'
);
$this->validator->getHaystack();
$validator->getHaystack();
}

/**
Expand Down

0 comments on commit 7d277af

Please sign in to comment.