8000 lint:container command fails on named argument service · Issue #52768 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

lint:container command fails on named argument service #52768

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

Closed
simonberger opened this issue Nov 28, 2023 · 6 comments
Closed

lint:container command fails on named argument service #52768

simonberger opened this issue Nov 28, 2023 · 6 comments

Comments

@simonberger
Copy link
Contributor

Symfony version(s) affected

5.4.31

Description

I receive an error like:

[ERROR] Invalid definition for service "service.one": argument 1 of
"ServiceOne::__construct()" accepts                    
         "Psr\Log\LoggerInterface", "null" passed.           

When executing

bin/console lint:container

In debugging I noticed it comes from CheckTypeDeclarationsPass where ::checkTypeDeclarations expects a numbered list of arguments. I wonder why that just now fails as we have some more of these already, but anyway.

I checked the class in Symfony 6 and 7 and noticed @nicolas-grekas fixed that in PR #49944 which does sound like something different in general. Picking just the change of the for loop would fix the command for me.

How to reproduce

Create a service with named arguments (not sure if this itself is really enough)

Possible Solution

No response

Additional Context

No response

@xabbuh
Copy link
Member
xabbuh commented Nov 28, 2023

Can you create a small example application that allows to reproduce your issue?

@stof
Copy link
< 8000 /span>
Member
stof commented Nov 28, 2023

The fix done in https://github.com/symfony/symfony/pull/49944/files#diff-3fd13113f2559d9117d20f2727218989fbb6f762c20a0ae7edd372f6c32d4dcbR143 might indeed need to be backported to 5.4 (apparently, this was fixed in this PR because the PR itself was affected by the bug, without checking which branches were affected)

@simonberger
Copy link
Contributor Author

I'll probably need (too) deep understanding of the value processing to create an example application. I already tried to debug why it runs into this just for this service and does not raise the issue for others.
I hoped nicolas who fixed it in another context and newer release or someone else is able to relate to it.

@simonberger
Copy link
Contributor Author

It is a service with the following characteristics:

  • named argument definition
  • no autowiring. Enabling autowiring fixes it (skipping this function most likely).
  • Leaving an argument with a default value out. Passing all arguments also fixes the problem

With this I should be able to create an example application tomorrow if still necessary.

@simonberger
Copy link
Contributor Author

Here it is:
https://github.com/simonberger/symfony-gh52768-reproducer

composer install
bin/console lint:container

@xabbuh
Copy link
Member
xabbuh commented Nov 29, 2023

Thanks for the reproducer. 👍 Backporting the fix from #49944 indeed fixes this.

@fabpot fabpot closed this as completed Nov 29, 2023
fabpot added a commit that referenced this issue Nov 29, 2023
… are not set (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[DependencyInjection] don't check parameter values if they are not set

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #52768
| License       | MIT

Commits
-------

210b371 don't check parameter values if they are not set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0