[Validator] Fixed ConstraintViolationList::__toString() to not include dots in the output if the root is empty
This commit is contained in:
parent
1678a3dbdf
commit
1dd302cbea
|
@ -29,9 +29,13 @@ class ConstraintViolationList implements \IteratorAggregate, \Countable, \ArrayA
|
||||||
|
|
||||||
foreach ($this->violations as $violation) {
|
foreach ($this->violations as $violation) {
|
||||||
$root = $violation->getRoot();
|
$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
|
$string .= <<<EOF
|
||||||
{$class}.{$violation->getPropertyPath()}:
|
{$class}{$propertyPath}:
|
||||||
{$violation->getMessage()}
|
{$violation->getMessage()}
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|
Reference in New Issue