Skip to content

DateTimeNormalizer complains when $data is already a DateTimeInterface #61190

@nesl247

Description

@nesl247

Symfony version(s) affected

7.2.3

Description

When trying to denormalize an array of data that may contain DateTimeInterface, the DateTimeNormalizer is called because it supportsNormalization for the desired type. But if the input is already the desired type, there is nothing for it to do. It should not throw an error.

How to reproduce

Will respond tomorrow with a reproducer. Filing this before I forget.

Possible Solution

No response

Additional Context

if (!\is_string($data) || '' === trim($data)) {
throw NotNormalizableValueException::createForUnexpectedDataType('The data is either not an string, an empty string, or null; you should pass a string that can be parsed with the passed format or a valid DateTime string.', $data, ['string'], $context['deserialization_path'] ?? null, true);
}
is the cause.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy