From 2c3e9adcd11dff7302613fc84f1d1d4c5cb29a2b Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 8 Dec 2011 16:30:50 +0100 Subject: [PATCH] [DependencyInjection] Made the reference case insensitive The container is case insensitive so using capital letters in a reference made it fail in some cases when checking the dependencies. Closes #2807 --- src/Symfony/Component/DependencyInjection/Reference.php | 2 +- .../Tests/Component/DependencyInjection/ReferenceTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Reference.php b/src/Symfony/Component/DependencyInjection/Reference.php index 89279f71570e..1517da29885a 100644 --- a/src/Symfony/Component/DependencyInjection/Reference.php +++ b/src/Symfony/Component/DependencyInjection/Reference.php @@ -35,7 +35,7 @@ class Reference */ public function __construct($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $strict = true) { - $this->id = $id; + $this->id = strtolower($id); $this->invalidBehavior = $invalidBehavior; $this->strict = $strict; } diff --git a/tests/Symfony/Tests/Component/DependencyInjection/ReferenceTest.php b/tests/Symfony/Tests/Component/DependencyInjection/ReferenceTest.php index 3bf2b04116c5..83480c46f8aa 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/ReferenceTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/ReferenceTest.php @@ -23,4 +23,10 @@ public function testConstructor() $ref = new Reference('foo'); $this->assertEquals('foo', (string) $ref, '__construct() sets the id of the reference, which is used for the __toString() method'); } + + public function testCaseInsensitive() + { + $ref = new Reference('FooBar'); + $this->assertEquals('foobar', (string) $ref, 'the id is lowercased as the container is case insensitive'); + } }