-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection][FrameworkBundle] lint:container
incorrectly marks service closures as not callable
#40773
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
Comments
The reason for this issue is that in Yaml/XmlDumper, we have code like: if ($value instanceof ServiceClosureArgument) {
$value = $value->getValues()[0];
} That is: we unwrap the service. The deeper reason for this is that we don't have a way to dump service closures as yaml nor xml. When using the command, in dev, the xml file is loaded and 💥 For thoughts :) |
What I understood during my investigation is during values processing here... symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php Line 86 in bb1e1e5
... the value is resolved, and it returns only the Reference , created during services register (Kernel.php in @derrabus example).
The reason tests are passing seems to be because the if ('callable' === $type && \is_object($value) && ($value instanceof Reference || $value instanceof Definition)) {
return;
} But the solution of @nicolas-grekas seems a better explanation! |
Thanks for the analysis.
This is something we could fix for 5.3. But that would basically mean that the linter remains broken in Symfony 4 perpetually. 😕
Yes, that would silence the error. Side note: But that change would basically mean that any reference or inlined definition would pass a |
We could skip using the xml in 5.2. That would make the command slower 🤷♂️ |
@alexandre-daubois the code you linked does not replace the ServiceClosureArgument. It process the value inside it, but keeps the argument itself. |
@nicolas-grekas the other solution is to add a XML syntax to represent a ServiceClosureArgument, so that we can dump the compiled container properly |
This is apparently a duplicate of #39259. Let's close this one then. |
Symfony version(s) affected: 5.2.6
Description
Under some circumstances, the
lint:container
command incorrectly fails on service closures being passed to a parameter declared ascallable
. This caused doctrine/DoctrineMigrationsBundle#413 and currently breaks the CI of the Symfony demo app.How to reproduce
https://github.com/derrabus/di-sca-reproducer
Run the
lint:container
command and you'll get the following error.However, run the
test
command and you'll see that the service definition is constructed successfully.The text was updated successfully, but these errors were encountered: