Skip to content

Commit bedcf6d

Browse files
Merge branch '2.8' into 3.1
* 2.8: Fix merge [DI] Dont share service when no id provided Fix Container and PhpDumper test inaccuracies [DI] Fix missing new line after private alias [ClassLoader] Throw an exception if the cache is not writeable Fixing regression in TwigEngine exception handling.
2 parents 87e395f + 7479943 commit bedcf6d

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

ContainerBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
399399
}
400400

401401
if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
402-
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
402+
return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior);
403403
}
404404

405405
try {
@@ -1036,14 +1036,14 @@ private function callMethod($service, $call)
10361036
/**
10371037
* Shares a given service in the container.
10381038
*
1039-
* @param Definition $definition
1040-
* @param mixed $service
1041-
* @param string $id
1039+
* @param Definition $definition
1040+
* @param mixed $service
1041+
* @param string|null $id
10421042
*/
10431043
private function shareService(Definition $definition, $service, $id)
10441044
{
1045-
if ($definition->isShared()) {
1046-
$this->services[$lowerId = strtolower($id)] = $service;
1045+
if (null !== $id && $definition->isShared()) {
1046+
$this->services[strtolower($id)] = $service;
10471047
}
10481048
}
10491049

Dumper/YamlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function addServiceAlias($alias, $id)
168168
return sprintf(" %s: '@%s'\n", $alias, $id);
169169
}
170170

171-
return sprintf(" %s:\n alias: %s\n public: false", $alias, $id);
171+
return sprintf(" %s:\n alias: %s\n public: false\n", $alias, $id);
172172
}
173173

174174
/**

Tests/Compiler/AutowirePassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ public function testCreateDefinition()
213213
$this->assertCount(1, $container->getDefinition('coop_tilleuls')->getArguments());
214214
$this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0));
215215

216-
$dunglasDefinition = $container->getDefinition('autowired.symfony\component\dependencyinjection\tests\compiler\dunglas');
216+
$dunglasDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas');
217217
$this->assertEquals(__NAMESPACE__.'\Dunglas', $dunglasDefinition->getClass());
218218
$this->assertFalse($dunglasDefinition->isPublic());
219219
$this->assertCount(1, $dunglasDefinition->getArguments());
220220
$this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\lille', $dunglasDefinition->getArgument(0));
221221

222-
$lilleDefinition = $container->getDefinition('autowired.symfony\component\dependencyinjection\tests\compiler\lille');
222+
$lilleDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille');
223223
$this->assertEquals(__NAMESPACE__.'\Lille', $lilleDefinition->getClass());
224224
}
225225

Tests/ContainerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function testSet()
132132
{
133133
$sc = new Container();
134134
$sc->set('foo', $foo = new \stdClass());
135-
$this->assertEquals($foo, $sc->get('foo'), '->set() sets a service');
135+
$this->assertSame($foo, $sc->get('foo'), '->set() sets a service');
136136
}
137137

138138
public function testSetWithNullResetTheService()
@@ -154,15 +154,15 @@ public function testGet()
154154
{
155155
$sc = new ProjectServiceContainer();
156156
$sc->set('foo', $foo = new \stdClass());
157-
$this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id');
158-
$this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
159-
$this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
160-
$this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
161-
$this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
162-
$this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined');
157+
$this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id');
158+
$this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
159+
$this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
160+
$this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
161+
$this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
162+
$this->assertSame($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined');
163163

164164
$sc->set('bar', $bar = new \stdClass());
165-
$this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()');
165+
$this->assertSame($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()');
166166

167167
try {
168168
$sc->get('');

Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function testOverrideServiceWhenUsingADumpedContainer()
250250
$container->set('bar', $bar = new \stdClass());
251251
$container->setParameter('foo_bar', 'foo_bar');
252252

253-
$this->assertEquals($bar, $container->get('bar'), '->set() overrides an already defined service');
253+
$this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service');
254254
}
255255

256256
public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne()

Tests/Fixtures/yaml/services6.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ services:
2525
class: Request
2626
synthetic: true
2727
lazy: true
28+
another_third_alias_for_foo:
29+
alias: foo
2830
decorator_service:
2931
decorates: decorated
3032
decorator_service_with_name:

0 commit comments

Comments
 (0)