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

[DependencyInjection] Fix service() as invokable factory in array-based PHP config#64311

Merged
nicolas-grekas merged 1 commit into
symfony:7.4symfony/symfony:7.4from
nicolas-grekas:fix-php-array-config-service-factorynicolas-grekas/symfony:fix-php-array-config-service-factoryCopy head branch name to clipboard
May 20, 2026
Merged

[DependencyInjection] Fix service() as invokable factory in array-based PHP config#64311
nicolas-grekas merged 1 commit into
symfony:7.4symfony/symfony:7.4from
nicolas-grekas:fix-php-array-config-service-factorynicolas-grekas/symfony:fix-php-array-config-service-factoryCopy head branch name to clipboard

Conversation

@nicolas-grekas
Copy link
Copy Markdown
Member

Q A
Branch? 7.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #64277
License MIT

ContainerConfigurator::processValue() turns ReferenceConfigurator instances into Reference objects when forwarding array-based PHP config to YamlFileLoader::parseCallable(), which only accepted strings and arrays as input and threw on a bare Reference. Since Reference is already part of parseCallable()'s return type and mirrors the post-processed form of '@id' strings, accept it as input and treat it as an invokable, like the '@id' branch does.

…ased PHP config

`ContainerConfigurator::processValue()` turns `ReferenceConfigurator`
instances into `Reference` objects when forwarding array-based PHP
config to `YamlFileLoader::parseCallable()`, which only accepted
strings and arrays as input and threw on a bare `Reference`. Since
`Reference` is already part of `parseCallable()`'s return type and
mirrors the post-processed form of `'@id'` strings, accept it as input
and treat it as an invokable, like the `'@id'` branch does.
@jmatthiesen81
Copy link
Copy Markdown

jmatthiesen81 commented May 20, 2026

Do you think YamlFileLoader is the right place for this fix? A YAML file can never produce a \Symfony\Component\DependencyInjection\Reference object, so this branch in parseCallable() would be dead code for any actual YAML-based configuration.

The real issue originates in PhpFileLoader, which calls ContainerConfigurator::processValue() to convert ReferenceConfigurator instances into Reference objects before delegating to YamlFileLoader::parseCallable(). The fix should therefore be applied closer to that conversion — for example in PhpFileLoader — so that YamlFileLoader and its parseCallable() method remain concerned only with YAML input and do not need to know about PHP-config internals.

@nicolas-grekas
Copy link
Copy Markdown
Member Author

YamlLoader is not only for yaml anymore with the php config format. We refactored it in 8.1 for this reason, but the code remains.

@nicolas-grekas nicolas-grekas merged commit cfb3c14 into symfony:7.4 May 20, 2026
13 of 14 checks passed
@nicolas-grekas nicolas-grekas deleted the fix-php-array-config-service-factory branch May 20, 2026 16:56
This was referenced May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

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