8000 Merge branch '3.2' · symfony/dependency-injection@c1cf3e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit c1cf3e9

Browse files
Merge branch '3.2'
* 3.2: [DI] Add missing legacy group on testLegacy Minor tweaks 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 68e769c + 22b2c97 commit c1cf3e9

File tree

6 files changed

+29
-31
lines changed

6 files changed

+29
-31
lines changed

ContainerBuilder.php

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

438438
if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
439-
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
439+
return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior);
440440
}
441441

442442
try {
@@ -1240,14 +1240,14 @@ private function callMethod($service, $call)
12401240
/**
12411241
* Shares a given service in the container.
12421242
*
1243-
* @param Definition $definition
1244-
* @param mixed $service
1245-
* @param string $id
1243+
* @param Definition $definition
1244+
* @param mixed $service
1245+
* @param string|null $id
12461246
*/
12471247
private function shareService(Definition $definition, $service, $id)
12481248
{
1249-
if ($definition->isShared()) {
1250-
$this->services[$lowerId = strtolower($id)] = $service;
1249+
if (null !== $id && $definition->isShared()) {
1250+
$this->services[strtolower($id)] = $service;
12511251
}
12521252
}
12531253

Dumper/YamlDumper.php

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

173-
return sprintf(" %s:\n alias: %s\n public: false", $alias, $id);
173+
return sprintf(" %s:\n alias: %s\n public: false\n", $alias, $id);
174174
}
175175

176176
/**

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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function testSet()
144144
{
145145
$sc = new Container();
146146
$sc->set('foo', $foo = new \stdClass());
147-
$this->assertEquals($foo, $sc->get('foo'), '->set() sets a service');
147+
$this->assertSame($foo, $sc->get('foo'), '->set() sets a service');
148148
}
149149

150150
public function testSetWithNullResetTheService()
@@ -166,14 +166,14 @@ public function testGet()
166166
{
167167
$sc = new ProjectServiceContainer();
168168
$sc->set('foo', $foo = new \stdClass());
169-
$this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id');
170-
$this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
171-
$this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
172-
$this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
173-
$this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
169+
$this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id');
170+
$this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
171+
$this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
172+
$this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
173+
$this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
174174

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

178178
try {
179179
$sc->get('');
@@ -196,15 +196,15 @@ public function testLegacyGet()
196196
$sc = new LegacyProjectServiceContainer();
197197
$sc->set('foo', $foo = new \stdClass());
198198

199-
$this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id');
200-
$this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
201-
$this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
202-
$this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
203-
$this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
204-
$this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined');
199+
$this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id');
200+
$this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
201+
$this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
202+
$this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
203+
$this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
204+
$this->assertSame($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined');
205205

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

209209
try {
210210
$sc->get('');

Tests/Dumper/PhpDumperTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function testOverrideServiceWhenUsingADumpedContainer()
272272
$container->set('bar', $bar = new \stdClass());
273273
$container->setParameter('foo_bar', 'foo_bar');
274274

275-
$this->assertEquals($bar, $container->get('bar'), '->set() overrides an already defined service');
275+
$this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service');
276276
}
277277

278278
public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne()
@@ -308,7 +308,7 @@ public function testDumpAutowireData()
308308
$container->compile();
309309
$dumper = new PhpDumper($container);
310310

311-
$this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services24.php'), $dumper->dump());
311+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services24.php', $dumper->dump());
312312
}
313313

314314
public function testEnvParameter()
@@ -466,8 +466,7 @@ public function testClosureProxy()
466466
$container->compile();
467467
$dumper = new PhpDumper($container);
468468

469-
$dump = $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Closure_Proxy'));
470-
$this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services31.php'), $dumper->dump());
469+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services31.php', $dumper->dump());
471470
$res = $container->getResources();
472471
$this->assertSame(realpath(self::$fixturesPath.'/containers/container31.php'), array_pop($res)->getResource());
473472
}
@@ -481,8 +480,7 @@ public function testClosureProxyPhp71()
481480
$container->compile();
482481
$dumper = new PhpDumper($container);
483482

484-
$dump = $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Closure_Proxy_Php71'));
485-
$this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services32.php'), $dumper->dump());
483+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services32.php', $dumper->dump());
486484
$res = $container->getResources();
487485
$this->assertSame(realpath(self::$fixturesPath.'/containers/container32.php'), array_pop($res)->getResource());
488486
}

Tests/Fixtures/yaml/services6.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ services:
1818
calls:
1919
- [ setBar, [ foo, '@foo', [true, false] ] ]
2020
alias_for_foo: '@foo'
21-
another_third_alias_for_foo:
22-
alias: foo
2321
another_alias_for_foo:
2422
alias: foo
2523
public: false
2624
request:
2725
class: Request
2826
synthetic: true
2927
lazy: true
28+
another_third_alias_for_foo:
29+
alias: foo
3030
decorator_service:
3131
decorates: decorated
3232
decorator_service_with_name:

0 commit comments

Comments
 (0)
0