formatMessage(), $code, $previous); } /** * Formats the constraint violation list as a human-readable message. * * @return string * The formatted message. */ private function formatMessage(): string { $lines = [ sprintf('There were validation errors in %s:', $this->data->getName()), ]; /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */ foreach ($this->violations as $violation) { $lines[] = sprintf('- %s: %s', $violation->getPropertyPath(), $violation->getMessage()); } return implode("\n", $lines); } }