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 71f8f15

Browse filesBrowse files
committed
bug #21312 [DI] Do not set values of lazy arguments after inlining them (chalasr)
This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Do not set values of lazy arguments after inlining them | Q | A | ------------- | --- | Branch? | master | Bug fix? | not yet | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21299 | License | MIT | Doc PR | n/a Commits ------- 04da7c3 [DI] Do not inline values of lazy arguments
2 parents f8b02ed + 04da7c3 commit 71f8f15
Copy full SHA for 71f8f15

File tree

2 files changed

+30
-1
lines changed
Filter options

2 files changed

+30
-1
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
@@ -69,7 +69,7 @@ private function inlineArguments(ContainerBuilder $container, array $arguments,
6969
if (is_array($argument)) {
7070
$arguments[$k] = $this->inlineArguments($container, $argument);
7171
} elseif ($argument instanceof ArgumentInterface) {
72-
$argument->setValues($this->inlineArguments($container, $argument->getValues()));
72+
$this->inlineArguments($container, $argument->getValues());
7373
} elseif ($argument instanceof Reference) {
7474
if (!$container->hasDefinition($id = (string) $argument)) {
7575
continue;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass;
1818
use Symfony\Component\DependencyInjection\Reference;
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
20+
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
21+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
2022

2123
class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
2224
{
@@ -222,6 +224,33 @@ public function testProcessDoesNotInlineWhenServiceReferencesItself()
222224
$this->assertSame($ref, $calls[0][1][0]);
223225
}
224226

227+
public function testProcessDoesNotSetLazyArgumentValuesAfterInlining()
228+
{
229+
$container = new ContainerBuilder();
230+
$container
231+
->register('inline')
232+
->setShared(false)
233+
;
234+
$container
235+
->register('closure-proxy')
236+
->setArguments(array(new ClosureProxyArgument('inline', 'method')))
237+
;
238+
$container
239+
->register('iterator')
240+
->setArguments(array(new IteratorArgument(array(new Reference('inline')))))
241+
;
242+
243+
$this->process($container);
244+
245+
$values = $container->getDefinition('closure-proxy')->getArgument(0)->getValues();
246+
$this->assertInstanceOf(Reference::class, $values[0]);
247+
$this->assertSame('inline', (string) $values[0]);
248+
249+
$values = $container->getDefinition('iterator')->getArgument(0)->getValues();
250+
$this->assertInstanceOf(Reference::class, $values[0]);
251+
$this->assertSame('inline', (string) $values[0]);
252+
}
253+
225254
protected function process(ContainerBuilder $container)
226255
{
227256
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass()));

0 commit comments

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