Skip to content

Commit 2d05009

Browse files
Merge branch '2.7' into 2.8
* 2.7: `@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: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php src/Symfony/Component/Finder/Finder.php src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php src/Symfony/Component/Security/Acl/Model/AclInterface.php src/Symfony/Component/Security/Acl/Model/MutableAclProviderInterface.php src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php src/Symfony/Component/Translation/Loader/XliffFileLoader.php src/Symfony/Component/Yaml/Tests/InlineTest.php
2 parents 6068532 + 3d4146f commit 2d05009

File tree

5 files changed

+83
-1
lines changed

5 files changed

+83
-1
lines changed

Container.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
320320
return;
321321
}
322322

323+
throw $e;
324+
} catch (\Throwable $e) {
325+
unset($this->loading[$id]);
326+
unset($this->services[$id]);
327+
323328
throw $e;
324329
}
325330

ContainerBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
480480
return;
481481
}
482482

483+
throw $e;
484+
} catch (\Throwable $e) {
485+
unset($this->loading[$id]);
486+
483487
throw $e;
484488
}
485489

Dumper/PhpDumper.php

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

1291-
if ($deep && !isset($visited[$argumentId])) {
1291+
if ($deep && !isset($visited[$argumentId]) && 'service_container' !== $argumentId) {
12921292
$visited[$argumentId] = true;
12931293

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

Tests/Dumper/PhpDumperTest.php

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

265265
$this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services24.php'), $dumper->dump());
266266
}
267+
268+
public function testInlinedDefinitionReferencingServiceContainer()
269+
{
270+
$container = new ContainerBuilder();
271+
$container->register('foo', 'stdClass')->addMethodCall('add', array(new Reference('service_container')))->setPublic(false);
272+
$container->register('bar', 'stdClass')->addArgument(new Reference('foo'));
273+
$container->compile();
274+
275+
$dumper = new PhpDumper($container);
276+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services13.php', $dumper->dump(), '->dump() dumps inline definitions which reference service_container');
277+
}
267278
}

Tests/Fixtures/php/services13.php

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

0 commit comments

Comments
 (0)