Skip to content

Serializer attributes are missing the repeatable flag #50786

Closed
@devjerry0

Description

@devjerry0

Symfony version(s) affected

5.4.25

Description

PHP 8.2
Sf: 5.4.25

Since #[Groups] and other attributes can be repeated in a target class, I'd suggest adding the flag to avoid false positives in static code analyzers.

https://www.php.net/manual/en/language.attributes.classes.php :

By default an attribute can only be used once per declaration. If the attribute should be repeatable on declarations it must be specified as part of the bitmask to the #[Attribute] declaration.

How to reproduce

Use the Groups or any other repeatable attribute more than once in a class.

The code is simply missing the attribute

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]

Possible Solution

Add a repeatable flag to repeatable attributes.

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
class Groups

Additional Context

This showed up when executing phpstan on the max level
Minor thing, but it saves one from ignoring a bunch of valid errors.

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