Skip to content

[DependencyInjection] Fallback to default value when autowiring undefined parameters for optional arguments #50022

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
merged 1 commit into from
Apr 19, 2023

Conversation

radar3301
Copy link
Contributor

@radar3301 radar3301 commented Apr 14, 2023

Q A
Branch? 6.2 / 6.3
Bug fix? yes
New feature? yes
Deprecations? no
Tickets Fix #50020
License MIT
Related PR #50023

Allows autowiring of undefined nullable parameters, similar to existing behavior for non-parameter values. See related issue for more detail.

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.2" but it seems your PR description refers to branch "6.2 / 6.3".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@radar3301 radar3301 changed the title Patch 1 [DI][Autowiring] Allow undefined nullable parameters (6.2) Apr 14, 2023
@radar3301 radar3301 changed the title [DI][Autowiring] Allow undefined nullable parameters (6.2) [DependencyInjection] [Autowiring] Allow undefined nullable parameters (6.2) Apr 14, 2023
@radar3301 radar3301 closed this Apr 14, 2023
@radar3301 radar3301 deleted the patch-1 branch April 14, 2023 20:55
@radar3301
Copy link
Contributor Author

radar3301 commented Apr 14, 2023

Grr... Tried renaming local patch to https://github.com/radar3301/symfony/tree/autowire-undefined-nullable-6.2

@radar3301 radar3301 restored the patch-1 branch April 14, 2023 20:57
@radar3301 radar3301 reopened this Apr 14, 2023
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Can you add a test case please?

@nicolas-grekas nicolas-grekas changed the title [DependencyInjection] [Autowiring] Allow undefined nullable parameters (6.2) [DependencyInjection] Fallback to null when autowiring undefined parameters for nullable arguments Apr 17, 2023
@radar3301
Copy link
Contributor Author

radar3301 commented Apr 17, 2023

Can you add a test case please?

I don't understand any of the test suite stuff...

I'm not even sure that the existing AutowirePassTest::testAutowireAttribute() even passes.
I don't see an AutowireAttribute class defined in Symfony/Component/DependencyInjection/Tests/Compiler, nor does a use alias exist for it.
I'm not even sure how $this->assertCount(9, $definition->getArguments()); on a non-existent class passes...

@radar3301
Copy link
Contributor Author

radar3301 commented Apr 17, 2023

non-existent AutowireAttribute class

Nevermind, I found it...

Test cases submitted.

@nicolas-grekas nicolas-grekas changed the title [DependencyInjection] Fallback to null when autowiring undefined parameters for nullable arguments [DependencyInjection] Fallback to default value when autowiring undefined parameters for optional arguments Apr 19, 2023
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM (I made some tweaks to the patch)

@carsonbot carsonbot changed the title [DependencyInjection] Fallback to default value when autowiring undefined parameters for optional arguments Fallback to default value when autowiring undefined parameters for optional arguments Apr 19, 2023
@carsonbot carsonbot changed the title Fallback to default value when autowiring undefined parameters for optional arguments [DependencyInjection] Fallback to default value when autowiring undefined parameters for optional arguments Apr 19, 2023
@nicolas-grekas
Copy link
Member

Thank you @radar3301.

@nicolas-grekas nicolas-grekas merged commit 20ee89c into symfony:6.2 Apr 19, 2023
@fabpot fabpot mentioned this pull request Apr 28, 2023
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.

3 participants