From 390cb335fab2854407eb2a13f53d067b3a8f6915 Mon Sep 17 00:00:00 2001 From: Bertalan Attila Date: Fri, 6 Jan 2017 14:37:03 +0100 Subject: [PATCH 1/8] Fixing regression in TwigEngine exception handling. --- src/Symfony/Bundle/TwigBundle/TwigEngine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index fb4b728a5b..d4b88be797 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -74,11 +74,11 @@ class TwigEngine extends BaseEngine implements EngineInterface if ($name instanceof TemplateReference) { try { // try to get the real name of the template where the error occurred - $name = $e->getTemplateName(); - $path = (string) $this->locator->locate($this->parser->parse($name)); if (method_exists($e, 'setSourceContext')) { - $e->setSourceContext(new \Twig_Source('', $name, $path)); + $e->setSourceContext($e->getSourceContext()); } else { + $templateName = $e->getTemplateName(); + $path = (string) $this->locator->locate($this->parser->parse($templateName)); $e->setTemplateName($path); } } catch (\Exception $e2) { From 3c887da4f3552478b3367d384c8f5688e92aa3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 9 Jan 2017 00:56:52 +0100 Subject: [PATCH 2/8] [ClassLoader] Throw an exception if the cache is not writeable --- .../Component/ClassLoader/ClassCollectionLoader.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 5d09848952..6f88286de0 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -275,7 +275,13 @@ REGEX; */ private static function writeCacheFile($file, $content) { - $tmpFile = tempnam(dirname($file), basename($file)); + $dir = dirname($file); + if (!is_writable($dir)) { + throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir)); + } + + $tmpFile = tempnam($dir, basename($file)); + if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { @chmod($file, 0666 & ~umask()); From 101a165d0da707f99007bc2fe86104f33ea492f1 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Mon, 9 Jan 2017 19:49:53 +0100 Subject: [PATCH 3/8] [DI] Fix missing new line after private alias --- src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php | 2 +- .../DependencyInjection/Tests/Fixtures/yaml/services6.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 955cb7c14e..1fa08e2b32 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -165,7 +165,7 @@ class YamlDumper extends Dumper return sprintf(" %s: '@%s'\n", $alias, $id); } - return sprintf(" %s:\n alias: %s\n public: false", $alias, $id); + return sprintf(" %s:\n alias: %s\n public: false\n", $alias, $id); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index e9e91fa6ba..9601516633 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -23,6 +23,8 @@ services: another_alias_for_foo: alias: foo public: false + another_third_alias_for_foo: + alias: foo decorator_service: decorates: decorated decorator_service_with_name: From 24b93cc75cd403dce481c898a2e6cc8cd2485c1a Mon Sep 17 00:00:00 2001 From: Nikita Nefedov Date: Tue, 10 Jan 2017 14:14:08 +0300 Subject: [PATCH 4/8] Fix Container and PhpDumper test inaccuracies --- .../DependencyInjection/Tests/ContainerTest.php | 16 ++++++++-------- .../Tests/Dumper/PhpDumperTest.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index b4eba04f97..83a805d612 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -134,7 +134,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase { $sc = new Container(); $sc->set('foo', $foo = new \stdClass()); - $this->assertEquals($foo, $sc->get('foo'), '->set() sets a service'); + $this->assertSame($foo, $sc->get('foo'), '->set() sets a service'); } public function testSetWithNullResetTheService() @@ -196,15 +196,15 @@ class ContainerTest extends \PHPUnit_Framework_TestCase { $sc = new ProjectServiceContainer(); $sc->set('foo', $foo = new \stdClass()); - $this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id'); - $this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase'); - $this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); - $this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); - $this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); - $this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); + $this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id'); + $this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase'); + $this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); + $this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); + $this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); + $this->assertSame($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); $sc->set('bar', $bar = new \stdClass()); - $this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); + $this->assertSame($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); try { $sc->get(''); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index ab9d592610..05918b14ec 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -230,7 +230,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $container->set('bar', $bar = new \stdClass()); $container->setParameter('foo_bar', 'foo_bar'); - $this->assertEquals($bar, $container->get('bar'), '->set() overrides an already defined service'); + $this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service'); } public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne() From 814f63390d0c96a376a3771ab2af1383ddfc8981 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 11:21:41 +0100 Subject: [PATCH 5/8] [DI] Dont share service when no id provided --- .../DependencyInjection/FrameworkExtensionTest.php | 2 +- .../DependencyInjection/CompleteConfigurationTest.php | 2 +- .../Component/DependencyInjection/ContainerBuilder.php | 10 +++++----- .../Component/HttpKernel/Tests/Bundle/BundleTest.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 9736cf17c3..b9116d39a3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -587,7 +587,7 @@ abstract class FrameworkExtensionTest extends TestCase private function assertVersionStrategy(ContainerBuilder $container, Reference $reference, $version, $format) { - $versionStrategy = $container->getDefinition($reference); + $versionStrategy = $container->getDefinition((string) $reference); if (null === $version) { $this->assertEquals('assets.empty_version_strategy', (string) $reference); } else { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 16e5787bdf..a07b3fc829 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -162,7 +162,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase ); } elseif (3 === $i) { $this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]); - $expression = $container->getDefinition($attributes[1])->getArgument(0); + $expression = $container->getDefinition((string) $attributes[1])->getArgument(0); $this->assertEquals("token.getUsername() matches '/^admin/'", $expression); } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 012a8e946e..496adb9426 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -430,7 +430,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) { - return $this->get($this->aliasDefinitions[$id], $invalidBehavior); + return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior); } try { @@ -1099,15 +1099,15 @@ class ContainerBuilder extends Container implements TaggedContainerInterface /** * Shares a given service in the container. * - * @param Definition $definition - * @param mixed $service - * @param string $id + * @param Definition $definition + * @param mixed $service + * @param string|null $id * * @throws InactiveScopeException */ private function shareService(Definition $definition, $service, $id) { - if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { + if (null !== $id && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) { if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) { throw new InactiveScopeException($id, $scope); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index 5faf795f87..5864433698 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -46,7 +46,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAsServices() { $container = new ContainerBuilder(); - $container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); + $container->register('console.command.symfony_component_httpkernel_tests_fixtures_extensionpresentbundle_command_foocommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); $application = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); // add() is never called when the found command classes are already registered as services From 87db587fa68a96ce08d82a28c6d6cf4dfcd2fd9e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 15:07:18 +0100 Subject: [PATCH 6/8] Fix merge --- .../Tests/Compiler/AutowirePassTest.php | 224 +----------------- 1 file changed, 2 insertions(+), 222 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index bb7bed43be..c9445c01dc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -211,13 +211,13 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase $pass->process($container); $this->assertCount(1, $container->getDefinition('coop_tilleuls')->getArguments()); - $this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0)); + $this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0)); $dunglasDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas'); $this->assertEquals(__NAMESPACE__.'\Dunglas', $dunglasDefinition->getClass()); $this->assertFalse($dunglasDefinition->isPublic()); $this->assertCount(1, $dunglasDefinition->getArguments()); - $this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille', $dunglasDefinition->getArgument(0)); + $this->assertEquals('autowired.symfony\component\dependencyinjection\tests\compiler\lille', $dunglasDefinition->getArgument(0)); $lilleDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille'); $this->assertEquals(__NAMESPACE__.'\Lille', $lilleDefinition->getClass()); @@ -429,107 +429,6 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase ); } - public function testSetterInjection() - { - $container = new ContainerBuilder(); - $container->register('app_foo', Foo::class); - $container->register('app_a', A::class); - $container->register('app_collision_a', CollisionA::class); - $container->register('app_collision_b', CollisionB::class); - - // manually configure *one* call, to override autowiring - $container - ->register('setter_injection', SetterInjection::class) - ->setAutowiredMethods(array('__construct', 'set*')) - ->addMethodCall('setWithCallsConfigured', array('manual_arg1', 'manual_arg2')) - ; - - $pass = new AutowirePass(); - $pass->process($container); - - $methodCalls = $container->getDefinition('setter_injection')->getMethodCalls(); - - // grab the call method names - $actualMethodNameCalls = array_map(function ($call) { - return $call[0]; - }, $methodCalls); - $this->assertEquals( - array('setWithCallsConfigured', 'setFoo', 'setDependencies'), - $actualMethodNameCalls - ); - - // test setWithCallsConfigured args - $this->assertEquals( - array('manual_arg1', 'manual_arg2'), - $methodCalls[0][1] - ); - // test setFoo args - $this->assertEquals( - array(new Reference('app_foo')), - $methodCalls[1][1] - ); - } - - public function testExplicitMethodInjection() - { - $container = new ContainerBuilder(); - $container->register('app_foo', Foo::class); - $container->register('app_a', A::class); - $container->register('app_collision_a', CollisionA::class); - $container->register('app_collision_b', CollisionB::class); - - $container - ->register('setter_injection', SetterInjection::class) - ->setAutowiredMethods(array('setFoo', 'notASetter')) - ; - - $pass = new AutowirePass(); - $pass->process($container); - - $methodCalls = $container->getDefinition('setter_injection')->getMethodCalls(); - - $actualMethodNameCalls = array_map(function ($call) { - return $call[0]; - }, $methodCalls); - $this->assertEquals( - array('setFoo', 'notASetter'), - $actualMethodNameCalls - ); - } - - /** - * @dataProvider getCreateResourceTests - */ - public function testCreateResourceForClass($className, $isEqual) - { - $startingResource = AutowirePass::createResourceForClass( - new \ReflectionClass(__NAMESPACE__.'\ClassForResource') - ); - $newResource = AutowirePass::createResourceForClass( - new \ReflectionClass(__NAMESPACE__.'\\'.$className) - ); - - // hack so the objects don't differ by the class name - $startingReflObject = new \ReflectionObject($startingResource); - $reflProp = $startingReflObject->getProperty('class'); - $reflProp->setAccessible(true); - $reflProp->setValue($startingResource, __NAMESPACE__.'\\'.$className); - - if ($isEqual) { - $this->assertEquals($startingResource, $newResource); - } else { - $this->assertNotEquals($startingResource, $newResource); - } - } - - public function getCreateResourceTests() - { - return array( - array('IdenticalClassResource', true), - array('ClassChangedConstructorArgs', false), - ); - } - public function testIgnoreServiceWithClassNotExisting() { $container = new ContainerBuilder(); @@ -544,37 +443,6 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase $this->assertTrue($container->hasDefinition('bar')); } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException - * @expectedExceptionMessage Unable to autowire argument of type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" for the service "setter_injection_collision". Multiple services exist for this interface (c1, c2). - * @expectedExceptionCode 1 - */ - public function testSetterInjectionCollisionThrowsException() - { - $container = new ContainerBuilder(); - - $container->register('c1', CollisionA::class); - $container->register('c2', CollisionB::class); - $aDefinition = $container->register('setter_injection_collision', SetterInjectionCollision::class); - $aDefinition->setAutowiredMethods(array('__construct', 'set*')); - - $pass = new AutowirePass(); - $pass->process($container); - } - - public function testLogUnusedPatterns() - { - $container = new ContainerBuilder(); - - $definition = $container->register('foo', Foo::class); - $definition->setAutowiredMethods(array('not', 'exist*')); - - $pass = new AutowirePass(); - $pass->process($container); - - $this->assertEquals(array(AutowirePass::class.': Autowiring\'s patterns "not", "exist*" for service "foo" don\'t match any method.'), $container->getCompiler()->getLog()); - } } class Foo @@ -730,91 +598,3 @@ class MultipleArgumentsOptionalScalarNotReallyOptional { } } - -/* - * Classes used for testing createResourceForClass - */ -class ClassForResource -{ - public function __construct($foo, Bar $bar = null) - { - } - - public function setBar(Bar $bar) - { - } -} -class IdenticalClassResource extends ClassForResource -{ -} - -class ClassChangedConstructorArgs extends ClassForResource -{ - public function __construct($foo, Bar $bar, $baz) - { - } -} - -class SetterInjection -{ - public function setFoo(Foo $foo) - { - // should be called - } - - public function setDependencies(Foo $foo, A $a) - { - // should be called - } - - public function setBar() - { - // should not be called - } - - public function setNotAutowireable(NotARealClass $n) - { - // should not be called - } - - public function setArgCannotAutowire($foo) - { - // should not be called - } - - public function setOptionalNotAutowireable(NotARealClass $n = null) - { - // should not be called - } - - public function setOptionalNoTypeHint($foo = null) - { - // should not be called - } - - public function setOptionalArgNoAutowireable($other = 'default_val') - { - // should not be called - } - - public function setWithCallsConfigured(A $a) - { - // this method has a calls configured on it - // should not be called - } - - public function notASetter(A $a) - { - // should be called only when explicitly specified - } -} - -class SetterInjectionCollision -{ - public function setMultipleInstancesForOneArg(CollisionInterface $collision) - { - // The CollisionInterface cannot be autowired - there are multiple - - // should throw an exception - } -} From 80ed2c5173f2432d59b1c20c9cc1983f490f6c6b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 08:04:52 +0100 Subject: [PATCH 7/8] Minor tweaks --- .../DependencyInjection/Compiler/CachePoolPass.php | 7 +++---- .../DependencyInjection/FrameworkExtensionTest.php | 14 +++++++------- .../DependencyInjection/SecurityExtension.php | 2 +- .../CompleteConfigurationTest.php | 2 +- .../Tests/Dumper/PhpDumperTest.php | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php index df02d65259..db1430eb49 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php @@ -36,7 +36,6 @@ class CachePoolPass implements CompilerPassInterface } $seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment'); - $aliases = $container->getAliases(); $attributes = array( 'provider', 'namespace', @@ -57,9 +56,9 @@ class CachePoolPass implements CompilerPassInterface $tags[0]['namespace'] = $this->getNamespace($seed, $id); } if (isset($tags[0]['clearer'])) { - $clearer = strtolower($tags[0]['clearer']); - while (isset($aliases[$clearer])) { - $clearer = (string) $aliases[$clearer]; + $clearer = $tags[0]['clearer']; + while ($container->hasAlias($clearer)) { + $clearer = (string) $container->getAlias($clearer); } } else { $clearer = null; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 2543eb5506..4663ee4ba6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -317,26 +317,26 @@ abstract class FrameworkExtensionTest extends TestCase $packages = $container->getDefinition('assets.packages'); // default package - $defaultPackage = $container->getDefinition($packages->getArgument(0)); + $defaultPackage = $container->getDefinition((string) $packages->getArgument(0)); $this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s'); // packages $packages = $packages->getArgument(1); $this->assertCount(5, $packages); - $package = $container->getDefinition($packages['images_path']); + $package = $container->getDefinition((string) $packages['images_path']); $this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s'); - $package = $container->getDefinition($packages['images']); + $package = $container->getDefinition((string) $packages['images']); $this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', '%%s?version=%%s'); - $package = $container->getDefinition($packages['foo']); + $package = $container->getDefinition((string) $packages['foo']); $this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s'); - $package = $container->getDefinition($packages['bar']); + $package = $container->getDefinition((string) $packages['bar']); $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), 'SomeVersionScheme', '%%s?version=%%s'); - $package = $container->getDefinition($packages['bar_version_strategy']); + $package = $container->getDefinition((string) $packages['bar_version_strategy']); $this->assertEquals('assets.custom_version_strategy', (string) $package->getArgument(1)); } @@ -346,7 +346,7 @@ abstract class FrameworkExtensionTest extends TestCase $packages = $container->getDefinition('assets.packages'); // default package - $defaultPackage = $container->getDefinition($packages->getArgument(0)); + $defaultPackage = $container->getDefinition((string) $packages->getArgument(0)); $this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1)); } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index faa28fc175..7b5774361c 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -403,7 +403,7 @@ class SecurityExtension extends Extension $config->replaceArgument(8, isset($firewall['access_denied_handler']) ? $firewall['access_denied_handler'] : null); $config->replaceArgument(9, isset($firewall['access_denied_url']) ? $firewall['access_denied_url'] : null); - $container->setAlias(new Alias('security.user_checker.'.$id, false), $firewall['user_checker']); + $container->setAlias('security.user_checker.'.$id, new Alias($firewall['user_checker'], false)); foreach ($this->factories as $position) { foreach ($position as $factory) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index fad3b8a76e..cbdb6e8f0f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -73,7 +73,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase $arguments = $contextDef->getArguments(); $listeners[] = array_map(function ($ref) { return (string) $ref; }, $arguments['index_0']); - $configDef = $container->getDefinition($arguments['index_2']); + $configDef = $container->getDefinition((string) $arguments['index_2']); $configs[] = array_values($configDef->getArguments()); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index ab2881b611..14c27febe4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -287,7 +287,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $container = include self::$fixturesPath.'/containers/container24.php'; $dumper = new PhpDumper($container); - $this->assertEquals(file_get_contents(self::$fixturesPath.'/php/services24.php'), $dumper->dump()); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/services24.php', $dumper->dump()); } public function testEnvParameter() From c5847696eac0c71615f1c2ea9ed0b2ac8dd32302 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Jan 2017 15:26:05 +0100 Subject: [PATCH 8/8] [DI] Add missing legacy group on testLegacy --- .../DependencyInjection/Tests/ContainerBuilderTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index b95574ab46..77015aab25 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -308,6 +308,9 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertTrue($builder->get('baz')->called, '->createService() uses another service as factory'); } + /** + * @group legacy + */ public function testLegacyCreateServiceFactory() { $builder = new ContainerBuilder(); @@ -324,6 +327,9 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar')), $builder->get('foo1')->arguments, '->createService() passes the arguments to the factory method'); } + /** + * @group legacy + */ public function testLegacyCreateServiceFactoryService() { $builder = new ContainerBuilder();