Skip to content

Commit 5f2738e

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: [DependencyInjection] Fixed incorrect report for private services if required service does not exist Remove Xdebug from php-extra runs.
2 parents 98cec9b + d4e571a commit 5f2738e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

Compiler/PassConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ public function __construct()
7979
new ReplaceAliasByActualDefinitionPass(),
8080
new RemoveAbstractDefinitionsPass(),
8181
new RemoveUnusedDefinitionsPass(),
82+
new AnalyzeServiceReferencesPass(),
83+
new CheckExceptionOnInvalidReferenceBehaviorPass(),
8284
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
8385
new AnalyzeServiceReferencesPass(),
8486
new DefinitionErrorExceptionPass(),
8587
]];
8688

8789
$this->afterRemovingPasses = [[
88-
new CheckExceptionOnInvalidReferenceBehaviorPass(),
8990
new ResolveHotPathPass(),
9091
new ResolveNoPreloadPass(),
9192
new AliasDeprecatedPublicServicesPass(),

Tests/ContainerBuilderTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,47 @@ public function testNoClassFromNsSeparatorId()
13371337
$container->compile();
13381338
}
13391339

1340+
public function testGetThrownServiceNotFoundExceptionWithCorrectServiceId()
1341+
{
1342+
$this->expectException(ServiceNotFoundException::class);
1343+
$this->expectExceptionMessage('The service "child_service" has a dependency on a non-existent service "non_existent_service".');
1344+
1345+
$container = new ContainerBuilder();
1346+
$container->register('child_service', \stdClass::class)
1347+
->setPublic(false)
1348+
->addArgument([
1349+
'non_existent' => new Reference('non_existent_service'),
1350+
])
1351+
;
1352+
$container->register('parent_service', \stdClass::class)
1353+
->setPublic(true)
1354+
->addArgument([
1355+
'child_service' => new Reference('child_service'),
1356+
])
1357+
;
1358+
1359+
$container->compile();
1360+
}
1361+
1362+
public function testUnusedServiceRemovedByPassAndServiceNotFoundExceptionWasNotThrown()
1363+
{
1364+
$container = new ContainerBuilder();
1365+
$container->register('service', \stdClass::class)
1366+
->setPublic(false)
1367+
->addArgument([
1368+
'non_existent_service' => new Reference('non_existent_service'),
1369+
])
1370+
;
1371+
1372+
try {
1373+
$container->compile();
1374+
} catch (ServiceNotFoundException $e) {
1375+
$this->fail('Should not be thrown');
1376+
}
1377+
1378+
$this->addToAssertionCount(1);
1379+
}
1380+
13401381
public function testServiceLocator()
13411382
{
13421383
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)