Skip to content

Failed to resolve type using symfony deserializer #41

@Bleksak

Description

@Bleksak
                $message = $this->serializer->deserialize(
                    $buffer,
                    SubmissionProducerMessage::class,
                    'json',
                );

Should be of type SubmissionProducerMessage, but instead it's of type mixed.

This is the definition of the deserialize method:

    /**
     * Deserializes data into the given type.
     *
     * @template TObject of object
     * @template TType of string|class-string<TObject>
     *
     * @param TType                $type
     * @param array<string, mixed> $context
     *
     * @phpstan-return ($type is class-string<TObject> ? TObject : mixed)
     *
     * @psalm-return (TType is class-string<TObject> ? TObject : mixed)
     *
     * @throws NotNormalizableValueException Occurs when a value cannot be denormalized
     * @throws UnexpectedValueException      Occurs when a value cannot be decoded
     * @throws ExceptionInterface            Occurs for all the other cases of serialization-related errors
     */
    public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions