Open
Description
Symfony version(s) affected
7.3.1, 7.4
Description
Given a DTO with a canDoCleverThings
method, the serializer will normalize this to [ ..., doCleverThings => x ]
, even if that method has an Ignore
attribute, because the ObjectNormalizer supports canX
accessors, but the AttributeLoader does not, and therefor does not contribute the ignored flag.
This is different from isX
, hasX
or getX
which work consistently between the two.
How to reproduce
<?php
final readonly class MyData {
public function __construct(public int $data) {}
#[Ignore]
public function canDoCleverThings(): bool {
return false;
}
}
Possible Solution
I think adding a |can
to the accessorOrMutator regex in AttributeLoader::loadClassMetadata
should already solve that.
Additional Context
No response