8000 Merge branch '3.1' into 3.2 · symfony/symfony@783abab · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 783abab

Browse files
Merge branch '3.1' into 3.2
* 3.1: 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 dd0ee1f + 15ff7f9 commit 783abab

File tree

11 files changed

+38
-34
lines changed

11 files changed

+38
-34
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ private function assertUrlPackage(ContainerBuilder $container, DefinitionDecorat
850850

851851
private function assertVersionStrategy(ContainerBuilder $container, Reference $reference, $version, $format)
852852
{
853-
$versionStrategy = $container->getDefinition($reference);
853+
$versionStrategy = $container->getDefinition((string) $reference);
854854
if (null === $version) {
855855
$this->assertEquals('assets.empty_version_strategy', (string) $reference);
856856
} else {

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function testAccess()
234234
);
235235
} elseif (3 === $i) {
236236
$this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]);
237-
$expression = $container->getDefinition($attributes[1])->getArgument(0);
237+
$expression = $container->getDefinition((string) $attributes[1])->getArgument(0);
238238
$this->assertEquals("token.getUsername() matches '/^admin/'", $expression);
239239
}
240240
}

src/Symfony/Bundle/TwigBundle/TwigEngine.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,12 @@ public function render($name, array $parameters = array())
4949
try {
5050
return parent::render($name, $parameters);
5151
} catch (\Twig_Error $e) {
52-
if ($name instanceof TemplateReference) {
52+
if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) {
5353
try {
5454
// try to get the real name of the template where the error occurred
5555
$name = $e->getTemplateName();
5656
$path = (string) $this->locator->locate($this->parser->parse($name));
57-
if (method_exists($e, 'setSourceContext')) {
58-
$e->setSourceContext(new \Twig_Source('', $name, $path));
59-
} else {
60-
$e->setTemplateName($path);
61-
}
57+
$e->setTemplateName($path);
6258
} catch (\Exception $e2) {
6359
}
6460
}

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,13 @@ private static function compressCode($code)
299299
*/
300300
private static function writeCacheFile($file, $content)
301301
{
302-
$tmpFile = tempnam(dirname($file), basename($file));
302+
$dir = dirname($file);
303+
if (!is_writable($dir)) {
304+
throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir));
305+
}
306+
307+
$tmpFile = tempnam($dir, basename($file));
308+
303309
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
304310
@chmod($file, 0666 & ~umask());
305311

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

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

426426
if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
427-
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
427+
return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior);
428428
}
429429

430430
try {
@@ -1140,14 +1140,14 @@ private function callMethod($service, $call)
11401140
/**
11411141
* Shares a given service in the container.
11421142
*
1143-
* @param Definition $definition
1144-
* @param mixed $service
1145-
* @param string $id
1143+
* @param Definition $definition
1144+
* @param mixed $service
1145+
* @param string|null $id
11461146
*/
11471147
private function shareService(Definition $definition, $service, $id)
11481148
{
1149-
if ($definition->isShared()) {
1150-
$this->services[$lowerId = strtolower($id)] = $service;
1149+
if (null !== $id && $definition->isShared()) {
1150+
$this->services[strtolower($id)] = $service;
11511151
}
11521152
}
11531153

src/Symfony/Component/DependencyInjection/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
/**

src/Symfony/Component/DependencyInjection/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

src/Symfony/Component/DependencyInjection/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('');

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

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

255-
$this->assertEquals($bar, $container->get('bar'), '->set() overrides an already defined service');
255+
$this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service');
256256
}
257257

258258
public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne()

src/Symfony/Component/DependencyInjection/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)
0