Repository: symfony/symfony
File: src/Symfony/Component/Validator/ConstraintValidator.php (PHP)

Code before:
     *
     * This method returns the equivalent PHP tokens for most scalar types
     * (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped
     * in double quotes ("). Objects, arrays and resources are formatted as
     * "object", "array" and "resource". If the $format bitmask contains
     * the PRETTY_DATE bit, then {@link \DateTime} objects will be formatted
     * with the {@link \IntlDateFormatter}. If it is not available, they will be
     * formatted as RFC-3339 dates ("Y-m-d H:i:s").
     *
     * Be careful when passing message parameters to a constraint violation
     * that (may) contain objects, arrays or resources. These parameters
     * should only be displayed for technical users. Non-technical users
     * won't know what an "object", "array" or "resource" is and will be
     * confused by the violation message.
     *
     * @param int $format A bitwise combination of the format constants in this class
     */
    protected function formatValue(mixed $value, int $format = 0): string
    {
        if (($format & self::PRETTY_DATE) && $value instanceof \DateTimeInterface) {
            if (class_exists(\IntlDateFormatter::class)) {
                $formatter = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, 'UTC');

                try {
                    return $formatter->format(new \DateTimeImmutable(
                        $value->format('Y-m-d H:i:s.u'),
                        new \DateTimeZone('UTC')
                    ));
                } catch (\Exception) {
                    // noop: fall back to the simple format below for unparsable dates (e.g. extreme years)
                }
            }

            return $value->format('Y-m-d H:i:s');
        }

        if ($value instanceof \UnitEnum) {
            return $value->name;
        }

        if (\is_object($value)) {
            if (($format & self::OBJECT_TO_STRING) && $value instanceof \Stringable) {
                return $value->__toString();
            }

            return 'object';
        }

        if (\is_array($value)) {
            return 'array';
        }

Review comment (suggestion):
```suggestion
                        ($value->format('y') > 0 ? '+' : '').$value->format('Y-m-d H:i:s.u'),
```

according to https://github.com/doctrine/dbal/issues/7307#issuecomment-3860586618 this should be enough to make it work



Code after:
    {
        return get_debug_type($value);
    }

    /**
     * Returns a string representation of the value.
     *
     * This method returns the equivalent PHP tokens for most scalar types
     * (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped
     * in double quotes ("). Objects, arrays and resources are formatted as
     * "object", "array" and "resource". If the $format bitmask contains
     * the PRETTY_DATE bit, then {@link \DateTime} objects will be formatted
     * with the {@link \IntlDateFormatter}. If it is not available, they will be
     * formatted as RFC-3339 dates ("Y-m-d H:i:s").
     *
     * Be careful when passing message parameters to a constraint violation
     * that (may) contain objects, arrays or resources. These parameters
     * should only be displayed for technical users. Non-technical users
     * won't know what an "object", "array" or "resource" is and will be
     * confused by the violation message.
     *
     * @param int $format A bitwise combination of the format constants in this class
     */
    protected function formatValue(mixed $value, int $format = 0): string
    {
        if (($format & self::PRETTY_DATE) && $value instanceof \DateTimeInterface) {
            if (class_exists(\IntlDateFormatter::class)) {
                $formatter = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, 'UTC');

                return $formatter->format(new \DateTimeImmutable(
                    ($value->format('y') > 0 ? '+' : '').$value->format('Y-m-d H:i:s.u'),
                    new \DateTimeZone('UTC')
                ));
            }

            return $value->format('Y-m-d H:i:s');
        }

        if ($value instanceof \UnitEnum) {
            return $value->name;
        }

        if (\is_object($value)) {
            if (($format & self::OBJECT_TO_STRING) && $value instanceof \Stringable) {
                return $value->__toString();
            }

            return 'object';
        }

        if (\is_array($value)) {