Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 744a4eb

Browse filesBrowse files
minor #23005 [DI] Deal with inlined non-shared services (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [DI] Deal with inlined non-shared services | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | no (fixing a non released bug fix) | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - A non-shared service can be inlined several times. Commits ------- 996698d [DI] Deal with inlined non-shared services
2 parents 7a9875c + 996698d commit 744a4eb
Copy full SHA for 744a4eb

File tree

4 files changed

+12
-8
lines changed
Filter options

4 files changed

+12
-8
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ private function doesServiceExistInTheContainer($serviceId, ContainerBuilder $co
5858

5959
// was the service inlined? Of so, does its parent service exist?
6060
if (isset($inlinedIds[$serviceId])) {
61-
return $this->doesServiceExistInTheContainer($inlinedIds[$serviceId], $container, $inlinedIds);
61+
foreach ($inlinedIds[$serviceId] as $parentId) {
62+
if ($this->doesServiceExistInTheContainer($parentId, $container, $inlinedIds)) {
63+
return true;
64+
}
65+
}
6266
}
6367

6468
return false;

‎src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function setRepeatedPass(RepeatedPass $repeatedPass)
3636
/**
3737
* Returns an array of all services inlined by this pass.
3838
*
39-
* The key is the inlined service id and its value is the service it was inlined into.
39+
* The key is the inlined service id and its value is the list of services it was inlined into.
4040
*
4141
* @return array
4242
*/
@@ -59,7 +59,7 @@ protected function processValue($value, $isRoot = false)
5959

6060
if ($this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) {
6161
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
62-
$this->inlinedServiceIds[$id] = $this->currentId;
62+
$this->inlinedServiceIds[$id][] = $this->currentId;
6363

6464
if ($definition->isShared()) {
6565
return $definition;

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public function testThrowExceptionIfServiceInlined()
6565
->method('getInlinedServiceIds')
6666
->will($this->returnValue(array(
6767
// a_service inlined into b_service
68-
'a_service' => 'b_service',
68+
'a_service' => array('b_service'),
6969
// b_service inlined into c_service
70-
'b_service' => 'c_service',
70+
'b_service' => array('c_service'),
7171
)));
7272

7373
$container = new ContainerBuilder();
@@ -100,9 +100,9 @@ public function testDoNotThrowExceptionIfServiceInlinedButRemoved()
100100
->method('getInlinedServiceIds')
101101
->will($this->returnValue(array(
102102
// a_service inlined into b_service
103-
'a_service' => 'b_service',
103+
'a_service' => array('b_service'),
104104
// b_service inlined into c_service
105-
'b_service' => 'c_service',
105+
'b_service' => array('c_service'),
106106
)));
107107

108108
// do NOT register c_service in the container

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function testGetInlinedServiceIdData()
273273
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), $inlinePass));
274274
$repeatedPass->process($container);
275275

276-
$this->assertEquals(array('inlinable.service' => 'other_service'), $inlinePass->getInlinedServiceIds());
276+
$this->assertEquals(array('inlinable.service' => array('other_service')), $inlinePass->getInlinedServiceIds());
277277
}
278278

279279
protected function process(ContainerBuilder $container)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.