Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConstraintViolation.php

function ConstraintViolation::__toString

Overrides ConstraintViolationInterface::__toString

File

vendor/symfony/validator/ConstraintViolation.php, line 55

Class

ConstraintViolation
Default implementation of {@ConstraintViolationInterface}.

Namespace

Symfony\Component\Validator

Code

public function __toString() : string {
    if (\is_object($this->root)) {
        $class = 'Object(' . $this->root::class . ')';
    }
    elseif (\is_array($this->root)) {
        $class = 'Array';
    }
    else {
        $class = (string) $this->root;
    }
    $propertyPath = (string) $this->propertyPath;
    if ('' !== $propertyPath && '[' !== $propertyPath[0] && '' !== $class) {
        $class .= '.';
    }
    if (null !== ($code = $this->code) && '' !== $code) {
        $code = ' (code ' . $code . ')';
    }
    return $class . $propertyPath . ":\n    " . $this->getMessage() . $code;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal