diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php
index e68e8b3cb8..4e99cca77a 100644
--- a/src/Symfony/Component/DependencyInjection/Definition.php
+++ b/src/Symfony/Component/DependencyInjection/Definition.php
@@ -649,6 +649,10 @@ class Definition
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
+ if (ContainerInterface::SCOPE_PROTOTYPE === $scope) {
+ $this->setShared(false);
+ }
+
$this->scope = $scope;
return $this;
diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
index 4bac0e2a0b..d67f1d7224 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests;
use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\ContainerInterface;
class DefinitionTest extends \PHPUnit_Framework_TestCase
{
@@ -139,6 +140,18 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($def->isShared(), '->isShared() returns false if the instance must not be shared');
}
+ /**
+ * @group legacy
+ */
+ public function testPrototypeScopedDefinitionAreNotShared()
+ {
+ $def = new Definition('stdClass');
+ $def->setScope(ContainerInterface::SCOPE_PROTOTYPE);
+
+ $this->assertFalse($def->isShared());
+ $this->assertEquals(ContainerInterface::SCOPE_PROTOTYPE, $def->getScope());
+ }
+
/**
* @covers Symfony\Component\DependencyInjection\Definition::setScope
* @covers Symfony\Component\DependencyInjection\Definition::getScope
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml
index dc55972a28..dcb312a1e9 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml
@@ -33,6 +33,6 @@
-
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml
index 6a5f03d9b8..c7e80ea5b8 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml
@@ -29,4 +29,5 @@ services:
factory_service: foo.baz
foo_bar:
class: %foo_class%
+ shared: false
scope: prototype