-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nicolas-grekas
merged 1 commit into
symfony:7.4
from
nicolas-grekas:generate-array-shapes
Sep 29, 2025
Merged
[Config] Add array-shapes to generated config builders #61879
nicolas-grekas
merged 1 commit into
symfony:7.4
from
nicolas-grekas:generate-array-shapes
Sep 29, 2025
Conversation
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
545e364 to
5c3ee4f
Compare
stof
reviewed
Sep 29, 2025
Member
|
Comments addressed in 07aa0c8. I used |
nicolas-grekas
commented
Sep 29, 2025
nicolas-grekas
commented
Sep 29, 2025
nicolas-grekas
commented
Sep 29, 2025
aaca381 to
a21a772
Compare
Member
|
New review addressed in 0bf17d2 (comments refactoring, nullable prototyped arrays et al) |
a21a772 to
0bf17d2
Compare
stof
approved these changes
Sep 29, 2025
0bf17d2 to
a79297a
Compare
Member
Author
|
Thank you @alexandre-daubois. |
nicolas-grekas
added a commit
that referenced
this pull request
Sep 29, 2025
…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 | MIT Another step on the path explored in #58771 This 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: ```php return [ 'framework' => [...], ]; ``` ```php return static function () { yield 'framework' => [...]; ]; ``` Config builders (best DX together with #61879): ```php return new FrameworkConfig([...]); ``` ```php return static function () { return new FrameworkConfig([...]); ]; ``` ```php // $env is always available in config files if ('dev' === $env) { return new FrameworkConfig([...]); } ``` ```php return static function (string $env) { if ('dev' === $env) { yield new FrameworkConfig([...]); } }; ``` Commits ------- ff3fbd7 [DependencyInjection] Handle returning arrays and config-builders from config files
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.
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 ;)