feat: add symfony-xml fixer to convert Symfony services.xml and routes.xml to YAML#1090
Merged
Merged
Conversation
The extension validator already warns about deprecated services.xml files (Symfony deprecated the XML configuration format in 7.4 and removes it in 8.0) but pointed users to an external tool for the conversion. This adds a new internal/symfony package that parses Symfony services.xml files and emits the equivalent services.yaml, covering parameters, imports, service definitions (all argument types, tags, calls, factories, configurators, decoration, deprecation, properties, bindings), defaults, prototypes, instanceof conditionals, aliases, inline services and when@env blocks. The conversion refuses anything it cannot represent instead of silently dropping configuration, keeping the XML file untouched in that case. A new "services-xml" verifier tool runs the conversion during "shopware-cli extension fix" and "shopware-cli project fix" for platform plugins, including extra bundles and locally imported XML files (import resources are rewritten to the converted YAML files). The validation message now points to the built-in fixer. The generated YAML was verified to be semantically equivalent to the XML by loading both into Symfony 7.4 ContainerBuilders and comparing the resulting definitions, aliases and parameters. https://claude.ai/code/session_014UNSrY9MntZK4VAthDwrTk
Code Coverage OverviewLanguages: Go Go / code-coverage/go-testThe overall coverage in the branch is 54%. The coverage in the branch is 50%. Show a code coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f43031756
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
The conversion tests now discover golden fixture pairs from internal/symfony/testdata/convert (services.xml + expected.yaml per case) and the file conversion tests copy input trees from internal/symfony/testdata/files into a temporary directory and compare the result against the expected tree. The verifier tool tests use complete extension fixture trees from internal/verifier/testdata/services-xml instead of building them inline. Tiny inline snippets for error cases stay in the test code, since the asserted error message is the interesting part there. https://claude.ai/code/session_014UNSrY9MntZK4VAthDwrTk
The YAML "@?" syntax means ignore-on-invalid, which removes method calls and collection entries instead of passing null. Since the null strategy cannot be expressed in YAML, the converter now refuses references with on-invalid="null" instead of silently changing the behavior to ignore. decoration-on-invalid="null" is representable, but only as an actual YAML null value: the string "null" is rejected by the YAML loader. Emit a null node for it and reject unknown decoration-on-invalid values. Verified against Symfony 7.4 by loading the XML and the converted YAML into ContainerBuilders and comparing the decorated service definitions. https://claude.ai/code/session_014UNSrY9MntZK4VAthDwrTk
Symfony deprecated the XML configuration format for routing too, so the fixer now also converts Resources/config/routes.xml files of platform plugins. The conversion covers routes (path, controller, methods, schemes, host, locale, format, utf8, stateless, defaults including the typed bool/int/float/string/list/map values, requirements, options, condition and localized paths), imports (prefix, name_prefix, exclude, trailing_slash_on_root and localized prefixes) and when@env blocks. Since XML imports are anonymous while YAML needs mapping keys, import keys are derived from the resource path. Locally imported XML route files are converted recursively and explicit type="xml" attributes are rewritten to the YAML loader. Plain text route defaults stay strings in YAML, matching the XML loader semantics. The tool is renamed from services-xml to symfony-xml as it now handles both files, and extension validate warns about deprecated routes.xml files like it already did for services.xml. The conversion was verified against Symfony 7.4 by loading the XML and the converted YAML into RouteCollections and comparing all routes, including imported files, typed defaults and localized routes. https://claude.ai/code/session_014UNSrY9MntZK4VAthDwrTk
Symfony 7.4 ships JSON schemas for the services.yaml and routes.yaml formats. The converter now prepends the yaml-language-server directive referencing those schemas on the 7.4 branches of the Symfony GitHub repositories, so editors validate and autocomplete the converted files without requiring the schema to be present in a local vendor directory. The generated files were validated against both schemas and the comment is ignored by Symfony's YAML loaders. https://claude.ai/code/session_014UNSrY9MntZK4VAthDwrTk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extension validator already warns about deprecated services.xml
files (Symfony deprecated the XML configuration format in 7.4 and
removes it in 8.0) but pointed users to an external tool for the
conversion.
This adds a new internal/symfony package that parses Symfony
services.xml files and emits the equivalent services.yaml, covering
parameters, imports, service definitions (all argument types, tags,
calls, factories, configurators, decoration, deprecation, properties,
bindings), defaults, prototypes, instanceof conditionals, aliases,
inline services and when@env blocks. The conversion refuses anything it
cannot represent instead of silently dropping configuration, keeping
the XML file untouched in that case.
The fixer also converts Resources/config/routes.xml to routes.yaml,
since the routing XML format is covered by the same deprecation. This
includes routes (with typed defaults, requirements, options, condition
and localized paths), imports (prefix, name_prefix, exclude,
trailing_slash_on_root) and when@env blocks. Import keys are derived
from the resource path, as XML imports are anonymous while YAML needs
mapping keys.
A new "symfony-xml" verifier tool runs the conversions during
"shopware-cli extension fix" and "shopware-cli project fix" for
platform plugins, including extra bundles and locally imported XML
files (import resources are rewritten to the converted YAML files).
"extension validate" now warns about deprecated routes.xml files like
it already did for services.xml, and both messages point to the
built-in fixer.
The generated YAML was verified to be semantically equivalent to the
XML by loading both into Symfony 7.4 ContainerBuilders and
RouteCollections and comparing the resulting definitions, aliases,
parameters and routes.
https://claude.ai/code/session_014UNSrY9MntZK4VAthDwrTk