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 6f8b862

Browse filesBrowse files
[DI] Shared services should not be inlined in non-shared ones
1 parent 40bcd77 commit 6f8b862
Copy full SHA for 6f8b862

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.