Skip to content

Commit 97ae3b8

Browse files
Merge branch '2.8' into 3.0
* 2.8: `@throws` annotations should go after `@return` Fix merge updated VERSION for 2.3.42 update CONTRIBUTORS for 2.3.42 updated CHANGELOG for 2.3.42 Revert "bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh)" Partial revert of previous PR [DependencyInjection] Skip deep reference check for 'service_container' Catch \Throwable [Serializer] Add missing @throws annotations Fix for #18843 force enabling the external XML entity loaders Removed UTC specification with timestamp Conflicts: CHANGELOG-2.3.md src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php src/Symfony/Component/Config/Loader/FileLoader.php src/Symfony/Component/DependencyInjection/Container.php src/Symfony/Component/DependencyInjection/ContainerBuilder.php src/Symfony/Component/Finder/Expression/Expression.php src/Symfony/Component/Finder/Finder.php src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
2 parents 015cb81 + 2d05009 commit 97ae3b8

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ private function hasReference($id, array $arguments, $deep = false, array &$visi
11661166
return true;
11671167
}
11681168

1169-
if ($deep && !isset($visited[$argumentId])) {
1169+
if ($deep && !isset($visited[$argumentId]) && 'service_container' !== $argumentId) {
11701170
$visited[$argumentId] = true;
11711171

11721172
$service = $this->container->getDefinition($argumentId);

Tests/Dumper/PhpDumperTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,15 @@ public function testDumpAutowireData()
254254

255255
$this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services24.php'), $dumper->dump());
256256
}
257+
258+
public function testInlinedDefinitionReferencingServiceContainer()
259+
{
260+
$container = new ContainerBuilder();
261+
$container->register('foo', 'stdClass')->addMethodCall('add', array(new Reference('service_container')))->setPublic(false);
262+
$container->register('bar', 'stdClass')->addArgument(new Reference('foo'));
263+
$container->compile();
264+
265+
$dumper = new PhpDumper($container);
266+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services13.php', $dumper->dump(), '->dump() dumps inline definitions which reference service_container');
267+
}
257268
}

Tests/Fixtures/php/services13.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\ContainerInterface;
4+
use Symfony\Component\DependencyInjection\Container;
5+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
6+
use Symfony\Component\DependencyInjection\Exception\LogicException;
7+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
8+
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
9+
10+
/**
11+
* ProjectServiceContainer.
12+
*
13+
* This class has been auto-generated
14+
* by the Symfony Dependency Injection Component.
15+
*/
16+
class ProjectServiceContainer extends Container
17+
{
18+
private $parameters;
19+
private $targetDirs = array();
20+
21+
/**
22+
* Constructor.
23+
*/
24+
public function __construct()
25+
{
26+
$this->services = array();
27+
$this->methodMap = array(
28+
'bar' => 'getBarService',
29+
);
30+
31+
$this->aliases = array();
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function compile()
38+
{
39+
throw new LogicException('You cannot compile a dumped frozen container.');
40+
}
41+
42+
/**
43+
* Gets the 'bar' service.
44+
*
45+
* This service is shared.
46+
* This method always returns the same instance of the service.
47+
*
48+
* @return \stdClass A stdClass instance.
49+
*/
50+
protected function getBarService()
51+
{
52+
$a = new \stdClass();
53+
$a->add($this);
54+
55+
return $this->services['bar'] = new \stdClass($a);
56+
}
57+
}

0 commit comments

Comments
 (0)