Skip to content

feat: add symfony-xml fixer to convert Symfony services.xml and routes.xml to YAML#1090

Merged
Soner (shyim) merged 5 commits into
mainfrom
claude/trusting-johnson-x7virx
Jun 11, 2026
Merged

feat: add symfony-xml fixer to convert Symfony services.xml and routes.xml to YAML#1090
Soner (shyim) merged 5 commits into
mainfrom
claude/trusting-johnson-x7virx

Conversation

@shyim

@shyim Soner (shyim) commented Jun 10, 2026

Copy link
Copy Markdown
Member

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

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
@github-code-quality

github-code-quality Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Go

Go / code-coverage/go-test

The overall coverage in the branch is 54%. The coverage in the branch is 50%.

Show a code coverage summary of the most impacted files.
File f3a6da0 2978ff9 +/-
internal/extens...on/validator.go 38% 40% +2%
internal/verifier/phpstan.go 17% 20% +3%
internal/verifier/tool.go 60% 90% +30%
internal/symfony/convert.go 0% 84% +84%
internal/symfon...convert_file.go 0% 89% +89%
internal/verifi.../symfony_xml.go 0% 89% +89%
internal/symfon...utes_convert.go 0% 91% +91%
internal/symfony/phpize.go 0% 94% +94%
internal/symfon.../servicesxml.go 0% 96% +96%
internal/symfony/routesxml.go 0% 100% +100%

Updated June 11, 2026 09:19 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/symfony/convert.go Outdated
Comment thread internal/symfony/convert.go Outdated
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
@shyim Soner (shyim) changed the title Add services-xml fixer to convert Symfony services.xml to services.yaml Add symfony-xml fixer to convert Symfony services.xml and routes.xml to YAML Jun 11, 2026
@shyim Soner (shyim) changed the title Add symfony-xml fixer to convert Symfony services.xml and routes.xml to YAML feat: add symfony-xml fixer to convert Symfony services.xml and routes.xml to YAML Jun 11, 2026
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
@shyim Soner (shyim) merged commit d2522e6 into main Jun 11, 2026
5 checks passed
@shyim Soner (shyim) deleted the claude/trusting-johnson-x7virx branch June 11, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants