-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Do not generate unreachable configuration paths #58995
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
Open
bobvandevijver
wants to merge
4
commits into
symfony:6.4
Choose a base branch
from
bobvandevijver:generated-config-docblock
base: 6.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Config] Do not generate unreachable configuration paths #58995
bobvandevijver
wants to merge
4
commits into
symfony:6.4
from
bobvandevijver:generated-config-docblock
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
When the determined parameter type is `array`, only that type can be passed meaning that the `is_array` in unnecessary. The same holds for the generated docblock: as only an array can be passed, there is no need to define a template and psalm returns.
Tests need to be updated to reflect the new behavior. |
And new tests should probably be added covering the case being fixed for array parameters. |
Yeah, I am working on the updated tests 👍🏻 |
@stof Tests have been added, I added an new testcase which adds a configuration sample for the cases I hit. |
nicolas-grekas
approved these changes
Jun 27, 2025
...nt/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/TransportsConfig.php
Show resolved
Hide resolved
...ony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValuesConfig.php
Show resolved
Hide resolved
...nt/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/ErrorPagesConfig.php
Show resolved
Hide resolved
src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
d361dc7
to
098586c
Compare
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.
PHPStan was having issues correctly inferring the returned type of a configuration function.
Consider the following messages as example:
This came from the following generated config class:
When the determined parameter type is
array
, only that type can be passed meaning that theis_array
is unnecessary. The same holds for the generated docblock: as only an array can be passed, there is no need to define a template and psalm returns.With the changes in this PR this method is generated more cleanly:
A similar issue happens with functions that do accept more than an array value:
This is caused by the following generated method:
While the method seems fine, the
@template
definition is not correctly defined, see https://phpstan.org/r/09317897-4cc8-4f67-98ca-8b6da3671b31.With the changes in this PR the template is now strictly defined so it matches the function signature:
See https://phpstan.org/r/986db325-9869-4a6f-8587-6af06c0612d4 for the results.
While the second change might actually be enough to fix the errors, I prefer both fixes as it no longers generates code that can not be executed anyways.