Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Config] Add array-shapes to generated config builders#61879
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
545e364 to5c3ee4fCompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
alexandre-daubois commentedSep 29, 2025
Comments addressed in07aa0c8. I used |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
aaca381 toa21a772Comparealexandre-daubois commentedSep 29, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
New review addressed in0bf17d2 (comments refactoring, nullable prototyped arrays et al) |
a21a772 to0bf17d2Compare0bf17d2 toa79297aComparenicolas-grekas commentedSep 29, 2025
Thank you@alexandre-daubois. |
b68f0e6 intosymfony:7.4Uh oh!
There was an error while loading.Please reload this page.
…ig-builders from config files (nicolas-grekas)This PR was merged into the 7.4 branch.Discussion----------[DependencyInjection] Handle returning arrays and config-builders from config files| Q | A| ------------- | ---| Branch? | 7.4| Bug fix? | no| New feature? | yes| Deprecations? | no| Issues | -| License | MITAnother step on the path explored in#58771This allows returning PHP arrays or config-builders from config files.Several styles are supported, some examples below.What this does *not* support is config trees under the `import`, `parameters` or `services` namespaces (that's for another PR).Arrays:```phpreturn [ 'framework' => [...],];``````phpreturn static function () { yield 'framework' => [...];];```Config builders (best DX together with#61879):```phpreturn new FrameworkConfig([...]);``````phpreturn static function () { return new FrameworkConfig([...]);];``````php// $env is always available in config filesif ('dev' === $env) { return new FrameworkConfig([...]);}``````phpreturn static function (string $env) { if ('dev' === $env) { yield new FrameworkConfig([...]); }};```Commits-------ff3fbd7 [DependencyInjection] Handle returning arrays and config-builders from config files
A subset of#58771
Note that only constructors get the array-shape as that's what we're going to need first to achieve what we target in#58771. We could also add array shapes to the generated fluent methods. I left that as an exercise to a future contributor ;)