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

Appearance settings

[Validator] Unable to solve "uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead." deprecation #52828

Copy link
Copy link
Closed
@ostrolucky

Description

@ostrolucky
Issue body actions

Symfony version(s) affected

6.4.0

Description

We have entities where all the validation constraints have been converted to attributes, however symfony validator still complains about using validation constraints through annotations. This is because logic for detecting these is oversimplified and it throws deprecation whenever it detects any attributes

if ($reflection instanceof \ReflectionClass && $annotations = $this->reader->getClassAnnotations($reflection)) {
trigger_deprecation('symfony/validator', '6.4', 'Class "%s" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.', $reflection->getName());
}

Situation is made worse by being unable to disable annotations while having attributes on. Following config

framework:
    validation:
        enable_annotations: false
        enable_attributes: true

produces compilation error The "enable_annotations" and "enable_attributes" options at path "framework.validation" must not be both set. Only the "enable_attributes" option must be used.

How to reproduce

Run validation in SF fullstack on following object

/** @\ApiPlatform\Core\Annotation\ApiResource()) */
#[\Doctrine\ORM\MappingORM\Entity]
class ThirdParty {}

Possible Solution

Allow turning off enable_annotations while having enable_attributes on, or improve deprecation detection so it complains only if it finds annotation Constraint

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.