8000 [Serializer] `#[Ignore]` on method ignores properties with same name · Issue #46918 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Serializer] #[Ignore] on method ignores properties with same name #46918
Closed
@ostrolucky

Description

@ostrolucky

Symfony version(s) affected

6.2.2

Description

Serializer does not differentiate between properties and methods when applying #[Ignore] attributes/annotations

How to reproduce

class IgnoreDummy
{
    public $name;

    #[Ignore]
    public function getName()
    {
        return 'foo';
    }
}
public function testLoadIgnore()
{
    $classMetadata = new ClassMetadata(IgnoreDummy::class);
    $this->loader->loadClassMetadata($classMetadata);

    $this->assertFalse($classMetadata->getAttributesMetadata()['name']->isIgnored());
}

Possible Solution

Serializer metadata should group methods and public properties to separate "buckets"

Additional Context

No response

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

      0