Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #28366 [DI] Fix dumping some complex service graphs (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Fix dumping some complex service graphs | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28296 (and its duplicates #28355 & #28362 ~+ possibly #28304~) | License | MIT | Doc PR | - Commits ------- 769fd4b [DI] Fix dumping some complex service graphs
- Loading branch information
Showing
7 changed files
with
152 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Container; | ||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Exception\RuntimeException; | ||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; | ||
|
||
/** | ||
* This class has been auto-generated | ||
* by the Symfony Dependency Injection Component. | ||
* | ||
* @final since Symfony 3.3 | ||
*/ | ||
class ProjectServiceContainer extends Container | ||
{ | ||
private $parameters; | ||
private $targetDirs = array(); | ||
|
||
public function __construct() | ||
{ | ||
$this->services = array(); | ||
$this->methodMap = array( | ||
'bar' => 'getBarService', | ||
'foo' => 'getFooService', | ||
); | ||
|
||
$this->aliases = array(); | ||
} | ||
|
||
public function getRemovedIds() | ||
{ | ||
return array( | ||
'Psr\\Container\\ContainerInterface' => true, | ||
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, | ||
); | ||
} | ||
|
||
public function compile() | ||
{ | ||
throw new LogicException('You cannot compile a dumped container that was already compiled.'); | ||
} | ||
|
||
public function isCompiled() | ||
{ | ||
return true; | ||
} | ||
|
||
public function isFrozen() | ||
{ | ||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Gets the public 'bar' shared service. | ||
* | ||
* @return \c5 | ||
*/ | ||
protected function getBarService() | ||
{ | ||
$this->services['bar'] = $instance = new \c5(); | ||
|
||
$instance->p5 = new \c6(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->getFooService()) && false ?: '_'}); | ||
|
||
return $instance; | ||
} | ||
|
||
/** | ||
* Gets the public 'foo' shared service. | ||
* | ||
* @return \c1 | ||
*/ | ||
protected function getFooService() | ||
{ | ||
$a = ${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->getBarService()) && false ?: '_'}; | ||
|
||
if (isset($this->services['foo'])) { | ||
return $this->services['foo']; | ||
} | ||
|
||
$b = new \c2(); | ||
|
||
$this->services['foo'] = $instance = new \c1($a, $b); | ||
|
||
$c = new \c3(); | ||
|
||
$c->p3 = new \c4(); | ||
$b->p2 = $c; | ||
|
||
return $instance; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_deep_graph.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
services: | ||
foo: | ||
class: c1 | ||
public: true | ||
arguments: | ||
- '@bar' | ||
- !service | ||
class: c2 | ||
properties: | ||
p2: !service | ||
class: c3 | ||
properties: | ||
p3: !service | ||
class: c4 | ||
|
||
bar: | ||
class: c5 | ||
public: true | ||
properties: | ||
p5: !service | ||
class: c6 | ||
arguments: ['@foo'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters