[Validator] Fixed ConstraintViolationList::__toString() to not include dots in the output if the root is empty

This commit is contained in:
Bernhard Schussek 2012-01-28 15:32:24 +01:00
parent 1678a3dbdf
commit 1dd302cbea
1 changed files with 6 additions and 2 deletions

View File

@ -29,9 +29,13 @@ class ConstraintViolationList implements \IteratorAggregate, \Countable, \ArrayA
foreach ($this->violations as $violation) {
$root = $violation->getRoot();
$class = is_object($root) ? get_class($root) : $root;
$class = (string) (is_object($root) ? get_class($root) : $root);
$propertyPath = (string) $violation->getPropertyPath();
if ('' !== $propertyPath && '[' !== $propertyPath{0} && '' !== $class) {
$class .= '.';
}
$string .= <<<EOF
{$class}.{$violation->getPropertyPath()}:
{$class}{$propertyPath}:
{$violation->getMessage()}
EOF;