Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot unserialize properties imported from other namespace in docblock #59650

Closed
@fritz-gerneth

Description

@fritz-gerneth

Symfony version(s) affected

7.2.x

Description

Trying to deserialize some DTO that receives an enum-array as parameter in the constructor. That enum is defined in a different namespace then the DTO. The type is annotated in the doc block.

How to reproduce

Setup

namespace App\AuthServer\Aggregate\AuthApp;use App\AuthServer\Entity\OAuth\Scope;class ClientCreated{    /**     * @param Scope[] $scopes     */    public function __construct(        public readonly array $scopes,    ) {}}
namespace App\AuthServer\Entity\OAuth;enum Scope: string{    case OPENID = 'openid';}

Call

$data = '{"scopes": ["openid"]}'serializer->deserialize($data, ClientCreated::class, 'json');

Different variations fail as well (e.g.list<Scope>).

Possible Solution

I traced this down to theStringTypeResolver /TypeContext:

Image

The use is not respected here, and therefore this returns the wrong full class ofApp\AuthServer\Aggregate\AuthApp\Scope

Additional Context

Using the FQCN in the docblock works:

class ClientCreated{    /**     * @param \App\AuthServer\Entity\OAuth\Scope[] $scopes     */    public function __construct(        public readonly array $scopes,    ) {}}

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp