Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request zendframework#3484 branch 'hotfix/array-to-string-…
Browse files Browse the repository at this point in the history
…conversion'
  • Loading branch information
Maks3w committed Jan 21, 2013
2 parents d0321dd + 05c1703 commit a219656
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Validator/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected function createMessage($messageKey, $value)
) {
$value = get_class($value) . ' object';
} elseif (is_array($value)) {
$value = '[' . implode(', ', $value) . ']';
$value = var_export($value, 1);
} else {
$value = (string) $value;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ZendTest/Validator/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace ZendTest\Validator;

use ReflectionMethod;
use Zend\I18n\Translator\Translator;
use Zend\Validator\AbstractValidator;

Expand Down Expand Up @@ -227,6 +228,17 @@ public function testDefaultTranslatorMethods()
$this->assertTrue(AbstractValidator::hasDefaultTranslator());
}

public function testMessageCreationWithNestedArrayValueDoesNotRaiseNotice()
{
$r = new ReflectionMethod($this->validator, 'createMessage');
$r->setAccessible(true);

$message = $r->invoke($this->validator, 'fooMessage', array('foo' => array('bar' => 'baz')));
$this->assertContains('foo', $message);
$this->assertContains('bar', $message);
$this->assertContains('baz', $message);
}

/**
* Ignores a raised PHP error when in effect, but throws a flag to indicate an error occurred
*
Expand Down

0 comments on commit a219656

Please sign in to comment.