Skip to content

Commit ce44756

Browse files
Merge branch '4.2'
* 4.2: [Serializer] fixed DateTimeNormalizer to maintain microseconds when a different timezone required [Routing] fix taking verb into account when redirecting [TwigBundle] Sync tab navigation css [WebProfilerBundle] Fix log filter in dark mode [WebProfilerBundle][4.2] Deny messenger <4.2 [DI] Fix dumping expressions accessing single-use private services [VarExporter] fix dumping protected property from abstract classes [WebProfilerBundle] Split form field heading Minor tweak for c3ad8a5
2 parents 4450ad2 + 46af7a3 commit ce44756

11 files changed

+20
-21
lines changed

Dumper/PhpDumper.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,7 @@ private function addServiceConfigurator(Definition $definition, string $variable
597597
if ($callable[0] instanceof Reference
598598
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))
599599
) {
600-
$callable[0] = $this->dumpValue($callable[0]);
601-
602-
return sprintf(' '.('$' === $callable[0][0] ? '%s' : '(%s)')."->%s(\$%s);\n", $callable[0], $callable[1], $variableName);
600+
return sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
603601
}
604602

605603
$class = $this->dumpValue($callable[0]);
@@ -1639,6 +1637,7 @@ private function getServiceCall(string $id, Reference $reference = null): string
16391637
if ($definition->isShared() && !isset($this->singleUsePrivateIds[$id])) {
16401638
$code = sprintf('$this->%s[\'%s\'] = %s', $definition->isPublic() ? 'services' : 'privates', $id, $code);
16411639
}
1640+
$code = "($code)";
16421641
} elseif ($this->asFiles && !$this->isHotPath($definition)) {
16431642
$code = sprintf("\$this->load('%s.php')", $this->generateMethodName($id));
16441643
if (!$definition->isShared()) {

Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ public function testExpressionReferencingPrivateService()
821821
->setPublic(false);
822822
$container->register('public_foo', 'stdClass')
823823
->setPublic(true)
824-
->addArgument(new Expression('service("private_foo")'));
824+
->addArgument(new Expression('service("private_foo").bar'));
825825

826826
$container->compile();
827827
$dumper = new PhpDumper($container);

Tests/Fixtures/php/services9_as_files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
338338

339339
return $this->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () {
340340
yield 0 => ($this->services['foo'] ?? $this->load('getFooService.php'));
341-
yield 1 => ($this->privates['tagged_iterator_foo'] ?? $this->privates['tagged_iterator_foo'] = new \Bar());
341+
yield 1 => ($this->privates['tagged_iterator_foo'] ?? ($this->privates['tagged_iterator_foo'] = new \Bar()));
342342
}, 2));
343343

344344
[Container%s/getThrowingOneService.php] => <?php

Tests/Fixtures/php/services9_compiled.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ protected function getTaggedIteratorService()
391391
{
392392
return $this->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () {
393393
yield 0 => ($this->services['foo'] ?? $this->getFooService());
394-
yield 1 => ($this->privates['tagged_iterator_foo'] ?? $this->privates['tagged_iterator_foo'] = new \Bar());
394+
yield 1 => ($this->privates['tagged_iterator_foo'] ?? ($this->privates['tagged_iterator_foo'] = new \Bar()));
395395
}, 2));
396396
}
397397

Tests/Fixtures/php/services_almost_circular_public.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function getBar3Service()
103103
{
104104
$this->services['bar3'] = $instance = new \BarCircular();
105105

106-
$a = ($this->services['foobar3'] ?? $this->services['foobar3'] = new \FoobarCircular());
106+
$a = ($this->services['foobar3'] ?? ($this->services['foobar3'] = new \FoobarCircular()));
107107

108108
$instance->addFoobar($a, $a);
109109

Tests/Fixtures/php/services_env_in_id.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getRemovedIds()
5959
*/
6060
protected function getBarService()
6161
{
62-
return $this->services['bar'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? $this->privates['bar_%env(BAR)%'] = new \stdClass()));
62+
return $this->services['bar'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? ($this->privates['bar_%env(BAR)%'] = new \stdClass())));
6363
}
6464

6565
/**
@@ -69,7 +69,7 @@ protected function getBarService()
6969
*/
7070
protected function getFooService()
7171
{
72-
return $this->services['foo'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? $this->privates['bar_%env(BAR)%'] = new \stdClass()), array('baz_'.$this->getEnv('string:BAR') => new \stdClass()));
72+
return $this->services['foo'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? ($this->privates['bar_%env(BAR)%'] = new \stdClass())), array('baz_'.$this->getEnv('string:BAR') => new \stdClass()));
7373
}
7474

7575
public function getParameter($name)

Tests/Fixtures/php/services_errored_definition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ protected function getTaggedIteratorService()
391391
{
392392
return $this->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () {
393393
yield 0 => ($this->services['foo'] ?? $this->getFooService());
394-
yield 1 => ($this->privates['tagged_iterator_foo'] ?? $this->privates['tagged_iterator_foo'] = new \Bar());
394+
yield 1 => ($this->privates['tagged_iterator_foo'] ?? ($this->privates['tagged_iterator_foo'] = new \Bar()));
395395
}, 2));
396396
}
397397

Tests/Fixtures/php/services_locator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function getRemovedIds()
6565
*/
6666
protected function getBarServiceService()
6767
{
68-
return $this->services['bar_service'] = new \stdClass(($this->privates['baz_service'] ?? $this->privates['baz_service'] = new \stdClass()));
68+
return $this->services['bar_service'] = new \stdClass(($this->privates['baz_service'] ?? ($this->privates['baz_service'] = new \stdClass())));
6969
}
7070

7171
/**
@@ -78,7 +78,7 @@ protected function getFooServiceService()
7878
return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\ServiceLocator(array('bar' => function () {
7979
return ($this->services['bar_service'] ?? $this->getBarServiceService());
8080
}, 'baz' => function (): \stdClass {
81-
return ($this->privates['baz_service'] ?? $this->privates['baz_service'] = new \stdClass());
81+
return ($this->privates['baz_service'] ?? ($this->privates['baz_service'] = new \stdClass()));
8282
}, 'nil' => function () {
8383
return NULL;
8484
}));
@@ -122,7 +122,7 @@ protected function getTranslator_Loader3Service()
122122
protected function getTranslator1Service()
123123
{
124124
return $this->services['translator_1'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_1' => function () {
125-
return ($this->services['translator.loader_1'] ?? $this->services['translator.loader_1'] = new \stdClass());
125+
return ($this->services['translator.loader_1'] ?? ($this->services['translator.loader_1'] = new \stdClass()));
126126
})));
127127
}
128128

@@ -134,10 +134,10 @@ protected function getTranslator1Service()
134134
protected function getTranslator2Service()
135135
{
136136
$this->services['translator_2'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_2' => function () {
137-
return ($this->services['translator.loader_2'] ?? $this->services['translator.loader_2'] = new \stdClass());
137+
return ($this->services['translator.loader_2'] ?? ($this->services['translator.loader_2'] = new \stdClass()));
138138
})));
139139

140-
$instance->addResource('db', ($this->services['translator.loader_2'] ?? $this->services['translator.loader_2'] = new \stdClass()), 'nl');
140+
$instance->addResource('db', ($this->services['translator.loader_2'] ?? ($this->services['translator.loader_2'] = new \stdClass())), 'nl');
141141

142142
return $instance;
143143
}
@@ -150,10 +150,10 @@ protected function getTranslator2Service()
150150
protected function getTranslator3Service()
151151
{
152152
$this->services['translator_3'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_3' => function () {
153-
return ($this->services['translator.loader_3'] ?? $this->services['translator.loader_3'] = new \stdClass());
153+
return ($this->services['translator.loader_3'] ?? ($this->services['translator.loader_3'] = new \stdClass()));
154154
})));
155155

156-
$a = ($this->services['translator.loader_3'] ?? $this->services['translator.loader_3'] = new \stdClass());
156+
$a = ($this->services['translator.loader_3'] ?? ($this->services['translator.loader_3'] = new \stdClass()));
157157

158158
$instance->addResource('db', $a, 'nl');
159159
$instance->addResource('db', $a, 'en');

Tests/Fixtures/php/services_private_frozen.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getRemovedIds()
5656
*/
5757
protected function getBarServiceService()
5858
{
59-
return $this->services['bar_service'] = new \stdClass(($this->privates['baz_service'] ?? $this->privates['baz_service'] = new \stdClass()));
59+
return $this->services['bar_service'] = new \stdClass(($this->privates['baz_service'] ?? ($this->privates['baz_service'] = new \stdClass())));
6060
}
6161

6262
/**
@@ -66,6 +66,6 @@ protected function getBarServiceService()
6666
*/
6767
protected function getFooServiceService()
6868
{
69-
return $this->services['foo_service'] = new \stdClass(($this->privates['baz_service'] ?? $this->privates['baz_service'] = new \stdClass()));
69+
return $this->services['foo_service'] = new \stdClass(($this->privates['baz_service'] ?? ($this->privates['baz_service'] = new \stdClass())));
7070
}
7171
}

Tests/Fixtures/php/services_private_in_expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public function getRemovedIds()
5656
*/
5757
protected function getPublicFooService()
5858
{
59-
return $this->services['public_foo'] = new \stdClass(new \stdClass());
59+
return $this->services['public_foo'] = new \stdClass((new \stdClass())->bar);
6060
}
6161
}

0 commit comments

Comments
 (0)