-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
ServiceClosureArgument is not recognized by lint:container #39259
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
@nicolas-grekas , need your help with this. I investigated the issue a bit and it looks strange. First, there is already an The problem is that at the time the container builder is used in At the same time in the dumped container it's a closure, which is correct: |
that's what need to be investigated. I don't see any valid reason for it to be a Reference object here. |
I found the issue.
Here's my idea. To add a static method final class ServiceClosureArgument
{
// ...
public static function wrapServiceInAClosure($service): \Closure
{
return function () use ($service) {
return $service;
};
}
} <call method="setDefinition">
<argument>Doctrine\Migrations\Provider\SchemaProvider</argument>
<argument type="service">
<service class="Closure">
<factory class="Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument"
method="wrapServiceInAClosure"/>
<argument type="service" id="HappyInc\Doctrine\SchemaConfigurator\CompositeSchemaProvider"/>
</service>
</argument>
</call> |
yeah, I think the issue is that we don't have a XML syntax to create a ServiceClosureArgument right now. they can only be created from PHP config. That's what we should fix instead IMO, rather than adding a factory method |
@vudaltsov Nice find. I'm curious to know if there has been any progress with an upstream fix for this? |
Notice: the same issue also occurs with Workaround for now:
|
… (rosier) This PR was merged into the main branch. Discussion ---------- [CI] Lint the container loaded from source instead of xml Workaround for doctrine/DoctrineMigrationsBundle#413 and symfony/symfony#39259 Commits ------- c5172ff Lint the container loaded from source instead of xml
Will be fixed by #41176 |
…s (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] fix dumping service-closure-arguments | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39259 | License | MIT | Doc PR | - 5.3 uses service closures a bit more, so that this is required to make the `lint:container` command work. Commits ------- 1aa9a24 [DependencyInjection] fix dumping service-closure-arguments
… (rosier) This PR was merged into the main branch. Discussion ---------- [CI] Lint the container loaded from source instead of xml Workaround for doctrine/DoctrineMigrationsBundle#413 and symfony/symfony#39259 Commits ------- c5172ff Lint the container loaded from source instead of xml
… (rosier) This PR was merged into the main branch. Discussion ---------- [CI] Lint the container loaded from source instead of xml Workaround for doctrine/DoctrineMigrationsBundle#413 and symfony/symfony#39259 Commits ------- c5172ff Lint the container loaded from source instead of xml
Symfony version(s) affected: 5.2, 5.1, probably earlier versions too
Description
When service is injected via
ServiceClosureArgument
like in DoctrineMigrationsExtension,lint:container
throws an error:How to reproduce
https://github.com/vudaltsov/symfony-lint-container-reproducer
UPDATE
Since
doctrine/doctrine-migrations-bundle
v3.1.0 container lint fails without any custom service configuration.The text was updated successfully, but these errors were encountered: