-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Validator] Deprecate XML configuration format #61288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
high-deps failure seems related to #61101; how could it be fixed? |
d89cbc6 to
2efe806
Compare
|
As written in #60568 (comment) I don't think it's worth doing this for the Validator component. Maintaining the @javiereguiluz @OskarStark @wouterj Do you think getting rid of the XML format would make the life for Symfony docs that much easier that dropping support for it would be worth it? |
|
Writing XML config in the docs was a real pain until Copilot is a thing. Last time I checked, Copilot (and other tools) are extremely efficient for that. |
2efe806 to
54b1118
Compare
54b1118 to
a4c69d3
Compare
a4c69d3 to
6175263
Compare
|
I think this might be too early to do that deprecation in 7.4, as the suggested replacement API (#61528) will be shipped only in 7.4 as well. This would make it hard for bundles to migrate to the new API while keeping support for multiple Symfony versions. I suggest delaying that deprecation until some 8.x release (the maintenance cost of this XmlFileLoader is not an issue regarding maintaining it for 2 more years IMO, as it has basically not changed since years) |
…time constraint metadata (nicolas-grekas) This PR was merged into the 7.4 branch. Discussion ---------- [Validator] Allow using attributes to declare compile-time constraint metadata | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT Prerequisite for #61288 At the moment, validation attributes are read at runtime when `framework.validation.enable_attributes` is true. This means they don't fit for bundles nor can't they be warmed up. This PR fixes both issues by using a new `validator.attribute_metadata` resource tag, that's turned into a list of classes to parse for attributes at compile-time. For apps, the tag is added by autoconfiguration: any `Constraint`-derived attributes found on a class in the `src/` folder will trigger the rule to add the tag. For bundles (and for apps if they want to), the tag is added by explicit service configuration. In an "eat your own dog-food" spirit, this capability is used to declare the constraints of the `Form` class: instead of loading the `validation.xml` file, we now declare this service resource: ```php ->set('validator.form.attribute_metadata', Form::class) ->tag('container.excluded') ->tag('validator.attribute_metadata') ``` This reads the attributes added to the `Form` class: ```php #[AssertForm()] #[Traverse(false)] class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterface ``` Bundles can do the same and replace their XML files by attributes. As a next step, we could also deprecate runtime-discovery of attributes. This could be worth it if this discovery has a measurable performance impact. To be measured if one wants to dig this idea. Side note: I'm hoping this could allow removing the yaml and xml config formats one day. For serialization metadata also (PR coming). BUT, this doesn't (yet) cover the use case of overriding metadata defined by bundles. For that, apps still have to use xml or yaml in config/validation/. I have an idea to cover this, coming to a next PR if it works. (failures unrelated) Commits ------- 0197b50 [Validator] Allow using attributes to declare compile-time constraint metadata
6175263 to
0cefc56
Compare
|
Let me close for reasons explained in #61288 (comment). |
Split from #60568