-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Mixing constructor injection and setter injection breaks php dumper #28824
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
This should be already fixed in |
I get test failure on 61cf143
|
I meant 4.1@dev for the symfony/dependency-injection component |
Still the same problem in symfony/dependency-injection@faaa406
|
bisect lead me to symfony/dependency-injection@ef44ed4 which is the first bad commit. The comment in #28366 (comment) seems related as he also gets an undefined variable notice so #28366 is an hot candidate for having introduced this. Interesting fact: commit 6fec32c is broken but it's 2 parents 432487f + 8bc014c are both good - might there be some merge conflict? |
I have this issue too, though without any <?php
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the private 'feed.command_bus.prooph' shared autowired service.
$a = ($this->privates['Some\Class'] ?? $this->load('getSomeService.php'));
if (isset($this->privates['feed.command_bus.prooph'])) {
return $this->privates['feed.command_bus.prooph'];
}
$c = ($this->privates['Prooph\EventStore\ActionEventEmitterEventStore'] ?? $this->load('getActionEventEmitterEventStoreService.php'));
if (isset($this->privates['feed.command_bus.prooph'])) {
return $this->privates['feed.command_bus.prooph'];
}
$b = \Some\Class::create($c, $this->getEnv('foo'));
$e = ($this->privates['Some\Other\Class'] ?? $this->load('getSomeOtherService.php'));
if (isset($this->privates['feed.command_bus.prooph'])) {
return $this->privates['feed.command_bus.prooph'];
}
$f = ($this->privates['Another\Class'] ?? $this->load('getAnotherService.php'));
if (isset($this->privates['feed.command_bus.prooph'])) {
return $this->privates['feed.command_bus.prooph'];
}
$this->privates['feed.command_bus.prooph'] = $instance = \CommandBus\Factory::create(array(
'Some\\CommandA' => new CommandHandler($a),
'Some\\CommandB' => new CommandHandler($b),
'Some\\CommandC' => new CommandHandler($d),
'Some\\CommandD' => new CommandHandler($e),
'Some\\CommandE' => new CommandHandler($f),
'Some\\CommandF' => new CommandHandler($g),
);
$d = \Some\Other\Class::create($c, $this->getEnv('bar'));
$g = \Another\Class::create($c, $this->getEnv('baz'));
return $instance; A couple of things:
|
Can you please share the dumped container as xml with me please, eg using slack? |
@nicolas-grekas: Do you need anything else from me or is my unit test above enough? |
I need to check your unit test first, thanks. |
Any news on this? A second project of mine now also has a broken container 😢 |
I'm having a look early next week. |
Should be fixed in #29103 |
This PR was merged into the 3.4 branch. Discussion ---------- [DI] fix dumping inlined services | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28824 #29078 | License | MIT | Doc PR | - Same as #29103 but for 3.4. This PR dump inline services using the call-stack to sort the code for instantiating them. This makes easier to follow and matches the behavior one would expect (and has when using `ContainerBuiler` directly to create services.) Commits ------- a97606d [DI] fix dumping inlined services
(now merged up to master, should be easier to test) |
Symfony version(s) affected: 4.1 (since 4.1.5 - previous not affected)
Description
When having a "complex" service graph consisting a mixture of constructor injection and setter injection, the dumped function in the container will attempt to use a variable before initializing it.
The container will error out with something like:
How to reproduce
I tried to reduce the amount of involved services to the absolute minimum, this is how far I got it narrowed down.
The following unit test breaks the container dumper on my machine.
Reducing it more, like removing any of the
->addMethodCall()
declarations or any of the arguments ofmultiuse1
, will not exhibit the issue anymore.The text was updated successfully, but these errors were encountered: