8000 Merge branch '3.4' into 4.0 · symfony/symfony@9857419 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 9857419

Browse files
Merge branch '3.4' into 4.0
* 3.4: [DI] Add missing deprecation when fetching private services from ContainerBuilder [FrameworkBundle] Rename getDotEnvVars to getDotenvVars [DI] Fix false-positive circular exception Use a more specific file for detecting the bridge [HttpKernel] Fix issue when resetting DumpDataCollector bumped Symfony version to 3.4.1 updated VERSION for 3.4.0 updated CHANGELOG for 3.4.0
2 parents 186fd5c + 9401afd commit 9857419

File tree

13 files changed

+93
-8
lines changed

13 files changed

+93
-8
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (PHP_VERSION_ID >= 70200) {
2727
}
2828

2929
$root = __DIR__;
30-
while (!file_exists($root.'/composer.json') || file_exists($root.'/bin/simple-phpunit')) {
30+
while (!file_exists($root.'/composer.json') || file_exists($root.'/DeprecationErrorHandler.php')) {
3131
if ($root === dirname($root)) {
3232
break;
3333
}

src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9090
array('Xdebug', extension_loaded('xdebug') ? 'true' : 'false'),
9191
);
9292

93-
if ($dotenv = self::getDotEnvVars()) {
93+
if ($dotenv = self::getDotenvVars()) {
9494
$rows = array_merge($rows, array(
9595
new TableSeparator(),
9696
array('<info>Environment (.env)</>'),
@@ -129,7 +129,7 @@ private static function isExpired(string $date): bool
129129
return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59');
130130
}
131131

132-
private static function getDotEnvVars(): array
132+
private static function getDotenvVars(): array
133133
{
134134
$vars = array();
135135
foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) {

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 2 additions & 1 deletion
< 8000 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ public function testStopwatchExtensionAvailability($debug, $stopwatchEnabled, $e
218218
}
219219
$container->registerExtension(new TwigExtension());
220220
$container->loadFromExtension('twig', array());
221+
$container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true);
221222
$this->compileContainer($container);
222223

223-
$tokenParsers = $container->get('twig.extension.debug.stopwatch')->getTokenParsers();
224+
$tokenParsers = $container->get('test.twig.extension.debug.stopwatch')->getTokenParsers();
224225
$stopwatchIsAvailable = new \ReflectionProperty($tokenParsers[0], 'stopwatchIsAvailable');
225226
$stopwatchIsAvailable->setAccessible(true);
226227

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ public function has($id)
519519
*/
520520
public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
521521
{
522+
if ($this->isCompiled() && isset($this->removedIds[$id]) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
523+
return parent::get($id);
524+
}
525+
522526
return $this->doGet($id, $invalidBehavior);
523527
}
524528

@@ -715,6 +719,12 @@ public function compile(bool $resolveEnvPlaceholders = false)
715719
}
716720

717721
parent::compile();
722+
723+
foreach ($this->definitions + $this->aliasDefinitions as $id => $definition) {
724+
if (!$definition->isPublic() || $definition->isPrivate()) {
725+
$this->removedIds[$id] = true;
726+
}
727+
}
718728
}
719729

720730
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ private function addServiceInlinedDefinitions(string $id, Definition $definition
472472
// $b = new ServiceB();
473473
// $a = new ServiceA(ServiceB $b);
474474
// $b->setServiceA(ServiceA $a);
475-
if ($this->hasReference($id, array($def->getArguments(), $def->getFactory()))) {
475+
if (isset($inlinedDefinition[$definition]) && $this->hasReference($id, array($def->getArguments(), $def->getFactory()))) {
476476
throw new ServiceCircularReferenceException($id, array($id));
477477
}
478478

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ public function testEnvInId()
733733
PsrContainerInterface::class => true,
734734
ContainerInterface::class => true,
735735
'baz_%env(BAR)%' => true,
736+
'bar_%env(BAR)%' => true,
736737
);
737738
$this->assertSame($expected, $container->getRemovedIds());
738739

@@ -1237,6 +1238,9 @@ public function testAlmostCircular($visibility)
12371238
$this->assertSame($foo2, $foo2->bar->foobar->foo);
12381239

12391240
$this->assertSame(array(), (array) $container->get('foobar4'));
1241+
1242+
$foo5 = $container->get('foo5');
1243+
$this->assertSame($foo5, $foo5->bar->foo);
12401244
}
12411245

12421246
public function provideAlmostCircular()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,9 @@ public function testAlmostCircular($visibility)
781781
$this->assertSame($foo2, $foo2->bar->foobar->foo);
782782

783783
$this->assertSame(array(), (array) $container->get('foobar4'));
784+
785+
$foo5 = $container->get('foo5');
786+
$this->assertSame($foo5, $foo5->bar->foo);
784787
}
785788

786789
public function provideAlmostCircular()

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container_almost_circular.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@
4646
$container->register('foobar4', 'stdClass')->setPublic(true)
4747
->addArgument(new Reference('foo4'));
4848

49+
// loop on the constructor of a setter-injected dep with property
50+
51+
$container->register('foo5', 'stdClass')->setPublic(true)
52+
->setProperty('bar', new Reference('bar5'));
53+
54+
$container->register('bar5', 'stdClass')->setPublic($public)
55+
->addArgument(new Reference('foo5'))
56+
->setProperty('foo', new Reference('foo5'));
57+
4958
return $container;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct()
2828
'bar3' => 'getBar3Service',
2929
'foo' => 'getFooService',
3030
'foo2' => 'getFoo2Service',
31+
'foo5' => 'getFoo5Service',
3132
'foobar4' => 'getFoobar4Service',
3233
);
3334

@@ -56,6 +57,7 @@ public function getRemovedIds()
5657
'Psr\\Container\\ContainerInterface' => true,
5758
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
5859
'bar' => true,
60+
'bar5' => true,
5961
'foo4' => true,
6062
'foobar' => true,
6163
'foobar2' => true,
@@ -125,6 +127,24 @@ protected function getFoo2Service()
125127
return $this->services['foo2'] = new \FooCircular($a);
126128
}
127129

130+
/**
131+
* Gets the public 'foo5' shared service.
132+
*
133+
* @return \stdClass
134+
*/
135+
protected function getFoo5Service()
136+
{
137+
$this->services['foo5'] = $instance = new \stdClass();
138+
139+
$a = new \stdClass(($this->services['foo5'] ?? $this->getFoo5Service()));
140+
141+
$a->foo = $instance;
142+
143+
$instance->bar = $a;
144+
145+
return $instance;
146+
}
147+
128148
/**
129149
* Gets the public 'foobar4' shared service.
130150
*

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ public function __construct()
2626
$this->methodMap = array(
2727
'bar' => 'getBarService',
2828
'bar3' => 'getBar3Service',
29+
'bar5' => 'getBar5Service',
2930
'foo' => 'getFooService',
3031
'foo2' => 'getFoo2Service',
3132
'foo4' => 'getFoo4Service',
33+
'foo5' => 'getFoo5Service',
3234
'foobar' => 'getFoobarService',
3335
'foobar2' => 'getFoobar2Service',
3436
'foobar3' => 'getFoobar3Service',
@@ -93,6 +95,26 @@ protected function getBar3Service()
9395
return $instance;
9496
}
9597

98+
/**
99+
* Gets the public 'bar5' shared service.
100+
*
101+
* @return \stdClass
102+
*/
103+
protected function getBar5Service()
104+
{
105+
$a = ($this->services['foo5'] ?? $this->getFoo5Service());
106+
107+
if (isset($this->services['bar5'])) {
108+
return $this->services['bar5'];
109+
}
110+
111+
$this->services['bar5'] = $instance = new \stdClass($a);
112+
113+
$instance->foo = $a;
114+
115+
return $instance;
116+
}
117+
96118
/**
97119
* Gets the public 'foo' shared service.
98120
*
@@ -139,6 +161,20 @@ protected function getFoo4Service()
139161
return $instance;
140162
}
141163

164+
/**
165+
* Gets the public 'foo5' shared service.
166+
*
167+
* @return \stdClass
168+
*/
169+
protected function getFoo5Service()
170+
{
171+
$this->services['foo5'] = $instance = new \stdClass();
172+
173+
$instance->bar = ($this->services['bar5'] ?? $this->getBar5Service());
174+
175+
return $instance;
176+
}
177+
142178
/**
143179
* Gets the public 'foobar' shared service.
144180
*

0 commit comments

Comments
 (0)
0