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 c3f17ac

Browse filesBrowse files
bug #48931 [DependencyInjection] Fix dumping inlined withers (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Fix dumping inlined withers | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48814 | License | MIT | Doc PR | - Commits ------- 455ace0 [DependencyInjection] Fix dumping inlined withers
2 parents 3af7d1d + 455ace0 commit c3f17ac
Copy full SHA for c3f17ac

File tree

4 files changed

+12
-2
lines changed
Filter options

4 files changed

+12
-2
lines changed

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ private function addServiceMethodCalls(Definition $definition, string $variableN
754754
$witherAssignation = '';
755755

756756
if ($call[2] ?? false) {
757-
if (null !== $sharedNonLazyId && $lastWitherIndex === $k) {
757+
if (null !== $sharedNonLazyId && $lastWitherIndex === $k && 'instance' === $variableName) {
758758
$witherAssignation = sprintf('$this->%s[\'%s\'] = ', $definition->isPublic() ? 'services' : 'privates', $sharedNonLazyId);
759759
}
760760
$witherAssignation .= sprintf('$%s = ', $variableName);

‎src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,8 @@ public function testAliasCanBeFoundInTheDumpedContainerWhenBothTheAliasAndTheSer
14391439
public function testWither()
14401440
{
14411441
$container = new ContainerBuilder();
1442-
$container->register(Foo::class);
1442+
$container->register(Foo::class)
1443+
->setAutowired(true);
14431444

14441445
$container
14451446
->register('wither', Wither::class)

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
class Foo
1919
{
20+
/**
21+
* @required
22+
* @return static
23+
*/
24+
public function cloneFoo()
25+
{
26+
return clone $this;
27+
}
2028
}
2129

2230
class Bar

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected function getWitherService()
5555
$instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither();
5656

5757
$a = new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo();
58+
$a = $a->cloneFoo();
5859

5960
$instance = $instance->withFoo1($a);
6061
$this->services['wither'] = $instance = $instance->withFoo2($a);

0 commit comments

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