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 10a2d39

Browse filesBrowse files
bug #27265 [DI] Shared services should not be inlined in non-shared ones (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Shared services should not be inlined in non-shared ones | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - [Already good on 2.7/2.8.](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php#L152) Commits ------- 6f8b862 [DI] Shared services should not be inlined in non-shared ones
2 parents 932dbd2 + 6f8b862 commit 10a2d39
Copy full SHA for 10a2d39

File tree

2 files changed

+3
-3
lines changed
Filter options

2 files changed

+3
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ private function isInlineableDefinition($id, Definition $definition, ServiceRefe
138138
return false;
139139
}
140140

141-
return true;
141+
return $this->container->getDefinition($ids[0])->isShared();
142142
}
143143
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testProcessDoesInlineNonSharedService()
9292
$this->assertNotSame($container->getDefinition('bar'), $arguments[2]);
9393
}
9494

95-
public function testProcessInlinesMixedServicesLoop()
95+
public function testProcessDoesNotInlineMixedServicesLoop()
9696
{
9797
$container = new ContainerBuilder();
9898
$container
@@ -108,7 +108,7 @@ public function testProcessInlinesMixedServicesLoop()
108108

109109
$this->process($container);
110110

111-
$this->assertEquals($container->getDefinition('foo')->getArgument(0), $container->getDefinition('bar'));
111+
$this->assertEquals(new Reference('bar'), $container->getDefinition('foo')->getArgument(0));
112112
}
113113

114114
/**

0 commit comments

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