diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md
index a58bb1834f..966f1f4711 100644
--- a/UPGRADE-2.8.md
+++ b/UPGRADE-2.8.md
@@ -65,3 +65,74 @@ Translator
$messages = array_replace_recursive($catalogue->all(), $messages);
}
```
+
+DependencyInjection
+-------------------
+
+ * The concept of scopes were deprecated, the deprecated methods are:
+
+ - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()`
+ - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopeChildren()`
+ - `Symfony\Component\DependencyInjection\ContainerInterface::enterScope()`
+ - `Symfony\Component\DependencyInjection\ContainerInterface::leaveScope()`
+ - `Symfony\Component\DependencyInjection\ContainerInterface::addScope()`
+ - `Symfony\Component\DependencyInjection\ContainerInterface::hasScope()`
+ - `Symfony\Component\DependencyInjection\ContainerInterface::isScopeActive()`
+ - `Symfony\Component\DependencyInjection\Definition::setScope()`
+ - `Symfony\Component\DependencyInjection\Definition::getScope()`
+ - `Symfony\Component\DependencyInjection\Reference::isStrict()`
+
+ Also, the `$scope` and `$strict` parameters of `Symfony\Component\DependencyInjection\ContainerInterface::set()` and `Symfony\Component\DependencyInjection\Reference` respectively were deprecated.
+
+ * A new `shared` flag has been added to the service definition
+ in replacement of the `prototype` scope.
+
+ Before:
+
+ ```php
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+ $container = new ContainerBuilder();
+ $container
+ ->register('foo', 'stdClass')
+ ->setScope(ContainerBuilder::SCOPE_PROTOTYPE)
+ ;
+ ```
+
+ ```yml
+ services:
+ foo:
+ class: stdClass
+ scope: prototype
+ ```
+
+ ```xml
+
+
+
+ ```
+
+ After:
+
+ ```php
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+ $container = new ContainerBuilder();
+ $container
+ ->register('foo', 'stdClass')
+ ->setShared(false)
+ ;
+ ```
+
+ ```yml
+ services:
+ foo:
+ class: stdClass
+ shared: false
+ ```
+
+ ```xml
+
+
+
+ ```
diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
index bba5055d00..076484567a 100644
--- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
+++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
@@ -68,9 +68,9 @@ class ProxyDumper implements DumperInterface
{
$instantiation = 'return';
- if (ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
+ if ($definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
$instantiation .= " \$this->services['$id'] =";
- } elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
+ } elseif ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
$instantiation .= " \$this->services['$id'] = \$this->scopedServices['$scope']['$id'] =";
}
diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json
index 1e0209760e..b37bf7b875 100644
--- a/src/Symfony/Bridge/ProxyManager/composer.json
+++ b/src/Symfony/Bridge/ProxyManager/composer.json
@@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.9",
- "symfony/dependency-injection": "~2.3|~3.0.0",
+ "symfony/dependency-injection": "~2.8|~3.0.0",
"ocramius/proxy-manager": "~0.4|~1.0"
},
"require-dev": {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
index 5981a700c7..57780d2e52 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
@@ -213,12 +213,16 @@ class JsonDescriptor extends Descriptor
{
$data = array(
'class' => (string) $definition->getClass(),
- 'scope' => $definition->getScope(),
+ 'scope' => $definition->getScope(false),
'public' => $definition->isPublic(),
'synthetic' => $definition->isSynthetic(),
'lazy' => $definition->isLazy(),
);
+ if (method_exists($definition, 'isShared')) {
+ $data['shared'] = $definition->isShared();
+ }
+
if (method_exists($definition, 'isSynchronized')) {
$data['synchronized'] = $definition->isSynchronized(false);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
index 8231c87477..8f5437146b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
@@ -179,12 +179,16 @@ class MarkdownDescriptor extends Descriptor
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
$output = '- Class: `'.$definition->getClass().'`'
- ."\n".'- Scope: `'.$definition->getScope().'`'
+ ."\n".'- Scope: `'.$definition->getScope(false).'`'
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
;
+ if (method_exists($definition, 'isShared')) {
+ $output .= "\n".'- Shared: '.($definition->isShared() ? 'yes' : 'no');
+ }
+
if (method_exists($definition, 'isSynchronized')) {
$output .= "\n".'- Synchronized: '.($definition->isSynchronized(false) ? 'yes' : 'no');
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
index 6916832060..024da4d3b9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -174,7 +174,7 @@ class TextDescriptor extends Descriptor
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
$maxTags = array();
- foreach ($serviceIds as $key => $serviceId) {
+ foreach ($serviceIds as $key => $serviceId) {
$definition = $this->resolveServiceDefinition($builder, $serviceId);
if ($definition instanceof Definition) {
// filter out private services unless shown explicitly
@@ -261,10 +261,13 @@ class TextDescriptor extends Descriptor
$description[] = 'Tags -';
}
- $description[] = sprintf('Scope %s', $definition->getScope());
+ $description[] = sprintf('Scope %s', $definition->getScope(false));
$description[] = sprintf('Public %s', $definition->isPublic() ? 'yes' : 'no');
$description[] = sprintf('Synthetic %s', $definition->isSynthetic() ? 'yes' : 'no');
$description[] = sprintf('Lazy %s', $definition->isLazy() ? 'yes' : 'no');
+ if (method_exists($definition, 'isShared')) {
+ $description[] = sprintf('Shared %s', $definition->isShared() ? 'yes' : 'no');
+ }
if (method_exists($definition, 'isSynchronized')) {
$description[] = sprintf('Synchronized %s', $definition->isSynchronized(false) ? 'yes' : 'no');
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
index e62c71a2a0..c9e6f7eb73 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
@@ -362,10 +362,13 @@ class XmlDescriptor extends Descriptor
}
}
- $serviceXML->setAttribute('scope', $definition->getScope());
+ $serviceXML->setAttribute('scope', $definition->getScope(false));
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');
+ if (method_exists($definition, 'isShared')) {
+ $serviceXML->setAttribute('shared', $definition->isShared() ? 'true' : 'false');
+ }
if (method_exists($definition, 'isSynchronized')) {
$serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false');
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml
index 4e609a06e5..428ba0c8ee 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml
@@ -13,16 +13,16 @@
-
+
%test.client.parameters%
-
+
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
index 047f4e8c16..9be35dad07 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
@@ -6,6 +6,7 @@
"public": true,
"synthetic": false,
"lazy": true,
+ "shared": true,
"synchronized": false,
"abstract": true,
"file": null,
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
index 1c3b958bd9..de404d24d0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
@@ -12,6 +12,7 @@ definition_1
- Public: yes
- Synthetic: no
- Lazy: yes
+- Shared: yes
- Synchronized: no
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml
index b21190dc79..59a1e85c6b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
index 3397fd67ac..c76d13ee42 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
@@ -6,6 +6,7 @@
"public": true,
"synthetic": false,
"lazy": true,
+ "shared": true,
"synchronized": false,
"abstract": true,
"file": null,
@@ -21,6 +22,7 @@
"public": false,
"synthetic": true,
"lazy": false,
+ "shared": true,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
index b3018b80b7..3a3de41c40 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
@@ -12,6 +12,7 @@ definition_1
- Public: yes
- Synthetic: no
- Lazy: yes
+- Shared: yes
- Synchronized: no
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
@@ -25,6 +26,7 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
+- Shared: yes
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml
index 7aecc4f629..5ceee2772a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml
@@ -2,10 +2,10 @@
-
+
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
index 53bf114e81..40a3da0096 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
@@ -6,6 +6,7 @@
"public": false,
"synthetic": true,
"lazy": false,
+ "shared": true,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md
index 56a2c39077..c0d4f11e33 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md
@@ -12,6 +12,7 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
+- Shared: yes
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml
index d6ac0b750b..51bb9c254f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
index 3837b95cb8..6844d2d180 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
@@ -6,6 +6,7 @@
"public": false,
"synthetic": true,
"lazy": false,
+ "shared": true,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
@@ -20,6 +21,7 @@
"public": false,
"synthetic": true,
"lazy": false,
+ "shared": true,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md
index 6577037f9c..551c9cb24b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md
@@ -12,6 +12,7 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
+- Shared: yes
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
@@ -30,6 +31,7 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
+- Shared: yes
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml
index be9d2f015b..01f3248608 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml
@@ -1,12 +1,12 @@
-
+
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
index 8de781dfc4..92f1300b4b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
@@ -4,6 +4,7 @@
"public": true,
"synthetic": false,
"lazy": true,
+ "shared": true,
"synchronized": false,
"abstract": true,
"file": null,
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
index 68d3569732..6c18a6c2bb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
@@ -3,6 +3,7 @@
- Public: yes
- Synthetic: no
- Lazy: yes
+- Shared: yes
- Synchronized: no
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
index af495497dd..4c37faccf2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
@@ -5,6 +5,7 @@
Public yes
Synthetic no
Lazy yes
+Shared yes
Synchronized no
Abstract yes
Factory Class Full\Qualified\FactoryClass
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.xml
index 92a9bbd70b..ec8a8cefa9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
index 9d58434c17..22a094928a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
@@ -4,6 +4,7 @@
"public": false,
"synthetic": true,
"lazy": false,
+ "shared": true,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
index 6b2f14651d..8668587994 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
@@ -3,6 +3,7 @@
- Public: no
- Synthetic: yes
- Lazy: no
+- Shared: yes
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
index 28a00d583b..62fc7d2dc6 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
@@ -8,6 +8,7 @@
Public no
Synthetic yes
Lazy no
+Shared yes
Synchronized no
Abstract no
Required File /path/to/file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml
index f128e522e5..ce9b1d0522 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.json
index 6372d9e5b5..b7a5dec87d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.json
@@ -4,6 +4,7 @@
"public": true,
"synthetic": false,
"lazy": true,
+ "shared": true,
"synchronized": true,
"abstract": true,
"file": null,
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.md
index d9832a1511..f527ab9ff8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.md
@@ -3,6 +3,7 @@
- Public: yes
- Synthetic: no
- Lazy: yes
+- Shared: yes
- Synchronized: yes
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.txt
index 3d9cbb2077..09340efcf5 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.txt
@@ -5,6 +5,7 @@
Public yes
Synthetic no
Lazy yes
+Shared yes
Synchronized yes
Abstract yes
Factory Class Full\Qualified\FactoryClass
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.xml
index 75d0820244..6088d9a21b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.xml
@@ -1,2 +1,2 @@
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.json
index 278a5bfed4..bb0f5685f3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.json
@@ -4,6 +4,7 @@
"public": false,
"synthetic": true,
"lazy": false,
+ "shared": true,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.md
index f552debbf1..43227638d8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.md
@@ -3,6 +3,7 @@
- Public: no
- Synthetic: yes
- Lazy: no
+- Shared: yes
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.txt
index 28a00d583b..62fc7d2dc6 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.txt
@@ -8,6 +8,7 @@
Public no
Synthetic yes
Lazy no
+Shared yes
Synchronized no
Abstract no
Required File /path/to/file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.xml
index dd3e2e06d7..7a2154487d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.xml
@@ -1,5 +1,5 @@
-
+
val1
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php
index d76d8fd629..04d41752c8 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php
@@ -16,7 +16,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
-use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
@@ -29,14 +29,14 @@ use Symfony\Component\Security\Core\Security;
*/
class UserLoginFormType extends AbstractType
{
- private $request;
+ private $requestStack;
/**
- * @param Request $request A request instance
+ * @param RequestStack $requestStack A RequestStack instance
*/
- public function __construct(Request $request)
+ public function __construct(RequestStack $requestStack)
{
- $this->request = $request;
+ $this->requestStack = $requestStack;
}
/**
@@ -50,7 +50,7 @@ class UserLoginFormType extends AbstractType
->add('_target_path', 'hidden')
;
- $request = $this->request;
+ $request = $this->requestStack->getCurrentRequest();
/* Note: since the Security component's form login listener intercepts
* the POST request, this form will never really be bound to the
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml
index e1e2b0e883..2b97bd5a66 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml
@@ -4,9 +4,8 @@ imports:
services:
csrf_form_login.form.type:
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType
- scope: request
arguments:
- - @request
+ - @request_stack
tags:
- { name: form.type, alias: user_login }
diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json
index 94847e822b..0bab4dbcbb 100644
--- a/src/Symfony/Bundle/SecurityBundle/composer.json
+++ b/src/Symfony/Bundle/SecurityBundle/composer.json
@@ -29,7 +29,7 @@
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0",
"symfony/form": "~2.7|~3.0.0",
"symfony/framework-bundle": "~2.7|~3.0.0",
- "symfony/http-foundation": "~2.3|~3.0.0",
+ "symfony/http-foundation": "~2.4|~3.0.0",
"symfony/twig-bundle": "~2.7|~3.0.0",
"symfony/twig-bridge": "~2.7|~3.0.0",
"symfony/process": "~2.0,>=2.0.5|~3.0.0",
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
index 132315fd23..00d17cee42 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
@@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
-use Symfony\Component\DependencyInjection\Scope;
class WebProfilerExtensionTest extends TestCase
{
@@ -49,8 +48,6 @@ class WebProfilerExtensionTest extends TestCase
$this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
$this->container = new ContainerBuilder();
- $this->container->addScope(new Scope('request'));
- $this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
$this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'));
$this->container->register('twig', 'Twig_Environment');
$this->container->setParameter('kernel.bundles', array());
@@ -125,7 +122,6 @@ class WebProfilerExtensionTest extends TestCase
eval('?>'.$dumper->dump(array('class' => $class)));
$container = new $class();
- $container->enterScope('request');
$container->set('kernel', $this->kernel);
return $container;
diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md
index 9f35827ecb..7c4ff51e8c 100644
--- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md
+++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md
@@ -5,6 +5,8 @@ CHANGELOG
-----
* allowed specifying a directory to recursively load all configuration files it contains
+ * deprecated the concept of scopes
+ * added `Definition::setShared()` and `Definition::isShared()`
2.7.0
-----
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php
index 219e66313d..e54ee60abb 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php
@@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
* - non synthetic, non abstract services always have a class set
* - synthetic services are always public
* - synthetic services are always of non-prototype scope
+ * - shared services are always of non-prototype scope
*
* @author Johannes M. Schmitt
*/
@@ -46,10 +47,15 @@ class CheckDefinitionValidityPass implements CompilerPassInterface
}
// synthetic service has non-prototype scope
- if ($definition->isSynthetic() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope()) {
+ if ($definition->isSynthetic() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
throw new RuntimeException(sprintf('A synthetic service ("%s") cannot be of scope "prototype".', $id));
}
+ // shared service has non-prototype scope
+ if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
+ throw new RuntimeException(sprintf('A shared service ("%s") cannot be of scope "prototype".', $id));
+ }
+
if ($definition->getFactory() && ($definition->getFactoryClass(false) || $definition->getFactoryService(false) || $definition->getFactoryMethod(false))) {
throw new RuntimeException(sprintf('A service ("%s") can use either the old or the new factory syntax, not both.', $id));
}
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php
index 3d4988d2e6..b4526edec8 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php
@@ -46,10 +46,10 @@ class CheckReferenceValidityPass implements CompilerPassInterface
{
$this->container = $container;
- $children = $this->container->getScopeChildren();
+ $children = $this->container->getScopeChildren(false);
$ancestors = array();
- $scopes = $this->container->getScopes();
+ $scopes = $this->container->getScopes(false);
foreach ($scopes as $name => $parent) {
$ancestors[$name] = array($parent);
@@ -65,7 +65,7 @@ class CheckReferenceValidityPass implements CompilerPassInterface
$this->currentId = $id;
$this->currentDefinition = $definition;
- $this->currentScope = $scope = $definition->getScope();
+ $this->currentScope = $scope = $definition->getScope(false);
if (ContainerInterface::SCOPE_CONTAINER === $scope) {
$this->currentScopeChildren = array_keys($scopes);
@@ -125,7 +125,7 @@ class CheckReferenceValidityPass implements CompilerPassInterface
return;
}
- if (!$reference->isStrict()) {
+ if (!$reference->isStrict(false)) {
return;
}
@@ -133,7 +133,7 @@ class CheckReferenceValidityPass implements CompilerPassInterface
return;
}
- if ($this->currentScope === $scope = $definition->getScope()) {
+ if ($this->currentScope === $scope = $definition->getScope(false)) {
return;
}
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
index 026700d226..c3c4ef5fd6 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
@@ -92,7 +92,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
if ($this->isInlineableDefinition($container, $id, $definition = $container->getDefinition($id))) {
$this->compiler->addLogMessage($this->formatter->formatInlineService($this, $id, $this->currentId));
- if (ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope()) {
+ if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false)) {
$arguments[$k] = $definition;
} else {
$arguments[$k] = clone $definition;
@@ -119,7 +119,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
*/
private function isInlineableDefinition(ContainerBuilder $container, $id, Definition $definition)
{
- if (ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope()) {
+ if (!$definition->isShared() || ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
return true;
}
@@ -152,6 +152,6 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
return false;
}
- return $container->getDefinition(reset($ids))->getScope() === $definition->getScope();
+ return $container->getDefinition(reset($ids))->getScope(false) === $definition->getScope(false);
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
index 0efc6b500b..daaee8159d 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
@@ -153,7 +153,7 @@ class ResolveDefinitionTemplatesPass implements CompilerPassInterface
// these attributes are always taken from the child
$def->setAbstract($definition->isAbstract());
- $def->setScope($definition->getScope());
+ $def->setScope($definition->getScope(false), false);
$def->setTags($definition->getTags());
// set new definition on container
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php
index c90d76f48a..3111d7f091 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php
@@ -68,7 +68,7 @@ class ResolveReferencesToAliasesPass implements CompilerPassInterface
$defId = $this->getDefinitionId($id = (string) $argument);
if ($defId !== $id) {
- $arguments[$k] = new Reference($defId, $argument->getInvalidBehavior(), $argument->isStrict());
+ $arguments[$k] = new Reference($defId, $argument->getInvalidBehavior(), $argument->isStrict(false));
}
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php
index f0db5de6bc..2b9fc5f487 100644
--- a/src/Symfony/Component/DependencyInjection/Container.php
+++ b/src/Symfony/Component/DependencyInjection/Container.php
@@ -180,6 +180,8 @@ class Container implements IntrospectableContainerInterface
* Setting a service to null resets the service: has() returns false and get()
* behaves in the same way as if the service was never created.
*
+ * Note: The $scope parameter is deprecated since version 2.8 and will be removed in 3.0.
+ *
* @param string $id The service identifier
* @param object $service The service instance
* @param string $scope The scope of the service
@@ -191,6 +193,10 @@ class Container implements IntrospectableContainerInterface
*/
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
{
+ if (!in_array($scope, array('container', 'request')) || ('request' === $scope && 'request' !== $id)) {
+ @trigger_error('The concept of container scopes is deprecated since version 2.8 and will be removed in 3.0. Omit the third parameter.', E_USER_DEPRECATED);
+ }
+
if (self::SCOPE_PROTOTYPE === $scope) {
throw new InvalidArgumentException(sprintf('You cannot set service "%s" of scope "prototype".', $id));
}
@@ -397,9 +403,15 @@ class Container implements IntrospectableContainerInterface
* @throws InvalidArgumentException When the scope does not exist
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function enterScope($name)
{
+ if ('request' !== $name) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
if (!isset($this->scopes[$name])) {
throw new InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name));
}
@@ -445,9 +457,15 @@ class Container implements IntrospectableContainerInterface
* @throws InvalidArgumentException if the scope is not active
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function leaveScope($name)
{
+ if ('request' !== $name) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
if (!isset($this->scopedServices[$name])) {
throw new InvalidArgumentException(sprintf('The scope "%s" is not active.', $name));
}
@@ -492,12 +510,17 @@ class Container implements IntrospectableContainerInterface
* @throws InvalidArgumentException
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function addScope(ScopeInterface $scope)
{
$name = $scope->getName();
$parentScope = $scope->getParentName();
+ if ('request' !== $name) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) {
throw new InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name));
}
@@ -526,9 +549,15 @@ class Container implements IntrospectableContainerInterface
* @return bool
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function hasScope($name)
{
+ if ('request' !== $name) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
return isset($this->scopes[$name]);
}
@@ -542,9 +571,13 @@ class Container implements IntrospectableContainerInterface
* @return bool
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function isScopeActive($name)
{
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+
return isset($this->scopedServices[$name]);
}
diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
index e697814bb1..5ac89cde57 100644
--- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
@@ -358,9 +358,15 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
* @return array An array of scopes
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
- public function getScopes()
+ public function getScopes($triggerDeprecationError = true)
{
+ if ($triggerDeprecationError) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
return $this->scopes;
}
@@ -370,15 +376,23 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
* @return array An array of scope children.
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
- public function getScopeChildren()
+ public function getScopeChildren($triggerDeprecationError = true)
{
+ if ($triggerDeprecationError) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
return $this->scopeChildren;
}
/**
* Sets a service.
*
+ * Note: The $scope parameter is deprecated since version 2.8 and will be removed in 3.0.
+ *
* @param string $id The service identifier
* @param object $service The service instance
* @param string $scope The scope
@@ -1176,7 +1190,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*/
private function shareService(Definition $definition, $service, $id)
{
- if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
+ if ($definition->isShared() && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) {
throw new InactiveScopeException($id, $scope);
}
diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php
index 19e800b314..39683a6d66 100644
--- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php
+++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php
@@ -34,6 +34,8 @@ interface ContainerInterface
/**
* Sets a service.
*
+ * Note: The $scope parameter is deprecated since version 2.8 and will be removed in 3.0.
+ *
* @param string $id The service identifier
* @param object $service The service instance
* @param string $scope The scope of the service
@@ -110,6 +112,8 @@ interface ContainerInterface
* @param string $name
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function enterScope($name);
@@ -119,6 +123,8 @@ interface ContainerInterface
* @param string $name
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function leaveScope($name);
@@ -128,6 +134,8 @@ interface ContainerInterface
* @param ScopeInterface $scope
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function addScope(ScopeInterface $scope);
@@ -139,6 +147,8 @@ interface ContainerInterface
* @return bool
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function hasScope($name);
@@ -152,6 +162,8 @@ interface ContainerInterface
* @return bool
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
public function isScopeActive($name);
}
diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php
index 71447fab12..e68e8b3cb8 100644
--- a/src/Symfony/Component/DependencyInjection/Definition.php
+++ b/src/Symfony/Component/DependencyInjection/Definition.php
@@ -29,6 +29,7 @@ class Definition
private $factoryClass;
private $factoryMethod;
private $factoryService;
+ private $shared = true;
private $scope = ContainerInterface::SCOPE_CONTAINER;
private $properties = array();
private $calls = array();
@@ -94,6 +95,7 @@ class Definition
* @return Definition The current instance
*
* @api
+ *
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryClass($factoryClass)
@@ -111,6 +113,7 @@ class Definition
* @return string|null The factory class name
*
* @api
+ *
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryClass($triggerDeprecationError = true)
@@ -130,6 +133,7 @@ class Definition
* @return Definition The current instance
*
* @api
+ *
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryMethod($factoryMethod)
@@ -182,6 +186,7 @@ class Definition
* @return string|null The factory method name
*
* @api
+ *
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryMethod($triggerDeprecationError = true)
@@ -201,6 +206,7 @@ class Definition
* @return Definition The current instance
*
* @api
+ *
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryService($factoryService)
@@ -218,6 +224,7 @@ class Definition
* @return string|null The factory service id
*
* @api
+ *
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryService($triggerDeprecationError = true)
@@ -597,6 +604,34 @@ class Definition
return $this->file;
}
+ /**
+ * Sets if the service must be shared or not.
+ *
+ * @param bool $shared Whether the service must be shared or not
+ *
+ * @return Definition The current instance
+ *
+ * @api
+ */
+ public function setShared($shared)
+ {
+ $this->shared = (bool) $shared;
+
+ return $this;
+ }
+
+ /**
+ * Whether this service is shared.
+ *
+ * @return bool
+ *
+ * @api
+ */
+ public function isShared()
+ {
+ return $this->shared;
+ }
+
/**
* Sets the scope of the service.
*
@@ -605,9 +640,15 @@ class Definition
* @return Definition The current instance
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
- public function setScope($scope)
+ public function setScope($scope, $triggerDeprecationError = true)
{
+ if ($triggerDeprecationError) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
$this->scope = $scope;
return $this;
@@ -619,9 +660,15 @@ class Definition
* @return string
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
- public function getScope()
+ public function getScope($triggerDeprecationError = true)
{
+ if ($triggerDeprecationError) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
return $this->scope;
}
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php
index 5f35a1e5bb..70e19af52f 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php
@@ -173,7 +173,7 @@ class GraphvizDumper extends Dumper
} catch (ParameterNotFoundException $e) {
}
- $nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted')));
+ $nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted')));
$container->setDefinition($id, new Definition('stdClass'));
}
@@ -201,7 +201,7 @@ class GraphvizDumper extends Dumper
$container->setDefinitions($this->container->getDefinitions());
$container->setAliases($this->container->getAliases());
$container->setResources($this->container->getResources());
- foreach ($this->container->getScopes() as $scope => $parentScope) {
+ foreach ($this->container->getScopes(false) as $scope => $parentScope) {
$container->addScope(new Scope($scope, $parentScope));
}
foreach ($this->container->getExtensions() as $extension) {
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
index 9c2b6dd54d..d3347a03c4 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
@@ -382,9 +382,9 @@ class PhpDumper extends Dumper
$isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
$instantiation = '';
- if (!$isProxyCandidate && ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
+ if (!$isProxyCandidate && $definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
$instantiation = "\$this->services['$id'] = ".($simple ? '' : '$instance');
- } elseif (!$isProxyCandidate && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
+ } elseif (!$isProxyCandidate && $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
$instantiation = "\$this->services['$id'] = \$this->scopedServices['$scope']['$id'] = ".($simple ? '' : '$instance');
} elseif (!$simple) {
$instantiation = '$instance';
@@ -578,7 +578,7 @@ class PhpDumper extends Dumper
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryService(false), $definition->getFactoryMethod(false));
}
- $scope = $definition->getScope();
+ $scope = $definition->getScope(false);
if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) {
if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
$return[] = '';
@@ -589,7 +589,7 @@ class PhpDumper extends Dumper
$return = implode("\n * ", $return);
$doc = '';
- if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
+ if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
$doc .= <<container->getScopes()) > 0) {
+ if (count($scopes = $this->container->getScopes(false)) > 0) {
$code .= "\n";
$code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n";
- $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n";
+ $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren(false)).";\n";
}
$code .= $this->addMethodMap();
@@ -907,9 +907,9 @@ EOF;
EOF;
$code .= "\n";
- if (count($scopes = $this->container->getScopes()) > 0) {
+ if (count($scopes = $this->container->getScopes(false)) > 0) {
$code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n";
- $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n";
+ $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren(false)).";\n";
} else {
$code .= " \$this->scopes = array();\n";
$code .= " \$this->scopeChildren = array();\n";
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
index 40486c4595..1f9183f418 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
@@ -126,7 +126,10 @@ class XmlDumper extends Dumper
if ($definition->getFactoryService(false)) {
$service->setAttribute('factory-service', $definition->getFactoryService(false));
}
- if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
+ if (!$definition->isShared()) {
+ $service->setAttribute('shared', 'false');
+ }
+ if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
$service->setAttribute('scope', $scope);
}
if (!$definition->isPublic()) {
@@ -283,7 +286,7 @@ class XmlDumper extends Dumper
} elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
$element->setAttribute('on-invalid', 'ignore');
}
- if (!$value->isStrict()) {
+ if (!$value->isStrict(false)) {
$element->setAttribute('strict', 'false');
}
} elseif ($value instanceof Definition) {
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
index 832929cd04..e1a5709dd3 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -128,7 +128,11 @@ class YamlDumper extends Dumper
$code .= sprintf(" calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
}
- if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
+ if (!$definition->isShared()) {
+ $code .= " shared: false\n";
+ }
+
+ if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
$code .= sprintf(" scope: %s\n", $scope);
}
@@ -212,7 +216,7 @@ class YamlDumper extends Dumper
}
/**
- * Dumps callable to YAML format
+ * Dumps callable to YAML format.
*
* @param callable $callable
*
diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
index 523c01cea4..93bb3a139d 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
@@ -148,7 +148,7 @@ class XmlFileLoader extends FileLoader
$definition = new Definition();
}
- foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'lazy', 'abstract') as $key) {
+ foreach (array('class', 'shared', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'lazy', 'abstract') as $key) {
if ($value = $service->getAttribute($key)) {
if (in_array($key, array('factory-class', 'factory-method', 'factory-service'))) {
@trigger_error(sprintf('The "%s" attribute in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use the "factory" element instead.', $key, $file), E_USER_DEPRECATED);
@@ -158,6 +158,16 @@ class XmlFileLoader extends FileLoader
}
}
+ if ($value = $service->getAttribute('scope')) {
+ $triggerDeprecation = 'request' !== (string) $service->getAttribute('id');
+
+ if ($triggerDeprecation) {
+ @trigger_error(sprintf('The "scope" attribute in file "%s" is deprecated since version 2.8 and will be removed in 3.0.', $file), E_USER_DEPRECATED);
+ }
+
+ $definition->setScope(XmlUtils::phpize($value), false);
+ }
+
if ($value = $service->getAttribute('synchronized')) {
$triggerDeprecation = 'request' !== (string) $service->getAttribute('id');
diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
index e10cfe2a4b..c0239c2f90 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
@@ -163,8 +163,15 @@ class YamlFileLoader extends FileLoader
$definition->setClass($service['class']);
}
+ if (isset($service['shared'])) {
+ $definition->setShared($service['shared']);
+ }
+
if (isset($service['scope'])) {
- $definition->setScope($service['scope']);
+ if ('request' !== $id) {
+ @trigger_error(sprintf('The "scope" key in file "%s" is deprecated since version 2.8 and will be removed in 3.0.', $file), E_USER_DEPRECATED);
+ }
+ $definition->setScope($service['scope'], false);
}
if (isset($service['synthetic'])) {
diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
index ac2cba7a80..11f869c04a 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
+++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
@@ -87,6 +87,7 @@
+
diff --git a/src/Symfony/Component/DependencyInjection/Reference.php b/src/Symfony/Component/DependencyInjection/Reference.php
index 88084880f8..6bb117abb6 100644
--- a/src/Symfony/Component/DependencyInjection/Reference.php
+++ b/src/Symfony/Component/DependencyInjection/Reference.php
@@ -27,6 +27,8 @@ class Reference
/**
* Constructor.
*
+ * Note: The $strict parameter is deprecated since version 2.8 and will be removed in 3.0.
+ *
* @param string $id The service identifier
* @param int $invalidBehavior The behavior when the service does not exist
* @param bool $strict Sets how this reference is validated
@@ -64,9 +66,15 @@ class Reference
* Returns true when this Reference is strict.
*
* @return bool
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
- public function isStrict()
+ public function isStrict($triggerDeprecationError = true)
{
+ if ($triggerDeprecationError) {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
+ }
+
return $this->strict;
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Scope.php b/src/Symfony/Component/DependencyInjection/Scope.php
index 161229e44b..c97c887584 100644
--- a/src/Symfony/Component/DependencyInjection/Scope.php
+++ b/src/Symfony/Component/DependencyInjection/Scope.php
@@ -17,6 +17,8 @@ namespace Symfony\Component\DependencyInjection;
* @author Johannes M. Schmitt
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
class Scope implements ScopeInterface
{
diff --git a/src/Symfony/Component/DependencyInjection/ScopeInterface.php b/src/Symfony/Component/DependencyInjection/ScopeInterface.php
index 81ac67cc4d..69d57685a2 100644
--- a/src/Symfony/Component/DependencyInjection/ScopeInterface.php
+++ b/src/Symfony/Component/DependencyInjection/ScopeInterface.php
@@ -17,6 +17,8 @@ namespace Symfony\Component\DependencyInjection;
* @author Johannes M. Schmitt
*
* @api
+ *
+ * @deprecated since version 2.8, to be removed in 3.0.
*/
interface ScopeInterface
{
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php
index 4e8efdc8b4..e0639825f0 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php
@@ -30,6 +30,7 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
+ * @group legacy
*/
public function testProcessDetectsSyntheticPrototypeDefinitions()
{
@@ -39,6 +40,18 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
$this->process($container);
}
+ /**
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
+ * @group legacy
+ */
+ public function testProcessDetectsSharedPrototypeDefinitions()
+ {
+ $container = new ContainerBuilder();
+ $container->register('a')->setShared(true)->setScope(ContainerInterface::SCOPE_PROTOTYPE);
+
+ $this->process($container);
+ }
+
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
*/
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php
index cd4448a96a..45cf279e37 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php
@@ -19,6 +19,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
class CheckReferenceValidityPassTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @group legacy
+ */
public function testProcessIgnoresScopeWideningIfNonStrictReference()
{
$container = new ContainerBuilder();
@@ -30,6 +33,7 @@ class CheckReferenceValidityPassTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \RuntimeException
+ * @group legacy
*/
public function testProcessDetectsScopeWidening()
{
@@ -40,6 +44,9 @@ class CheckReferenceValidityPassTest extends \PHPUnit_Framework_TestCase
$this->process($container);
}
+ /**
+ * @group legacy
+ */
public function testProcessIgnoresCrossScopeHierarchyReferenceIfNotStrict()
{
$container = new ContainerBuilder();
@@ -54,6 +61,7 @@ class CheckReferenceValidityPassTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \RuntimeException
+ * @group legacy
*/
public function testProcessDetectsCrossScopeHierarchyReference()
{
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
index 590ca4cfae..0388434163 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php
@@ -41,6 +41,29 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
$this->assertSame($container->getDefinition('inlinable.service'), $arguments[0]);
}
+ public function testProcessDoesNotInlinesWhenAliasedServiceIsShared()
+ {
+ $container = new ContainerBuilder();
+ $container
+ ->register('foo')
+ ->setPublic(false)
+ ;
+ $container->setAlias('moo', 'foo');
+
+ $container
+ ->register('service')
+ ->setArguments(array($ref = new Reference('foo')))
+ ;
+
+ $this->process($container);
+
+ $arguments = $container->getDefinition('service')->getArguments();
+ $this->assertSame($ref, $arguments[0]);
+ }
+
+ /**
+ * @group legacy
+ */
public function testProcessDoesNotInlineWhenAliasedServiceIsNotOfPrototypeScope()
{
$container = new ContainerBuilder();
@@ -61,6 +84,38 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
$this->assertSame($ref, $arguments[0]);
}
+ public function testProcessDoesInlineNonSharedService()
+ {
+ $container = new ContainerBuilder();
+ $container
+ ->register('foo')
+ ->setShared(false)
+ ;
+ $container
+ ->register('bar')
+ ->setPublic(false)
+ ->setShared(false)
+ ;
+ $container->setAlias('moo', 'bar');
+
+ $container
+ ->register('service')
+ ->setArguments(array(new Reference('foo'), $ref = new Reference('moo'), new Reference('bar')))
+ ;
+
+ $this->process($container);
+
+ $arguments = $container->getDefinition('service')->getArguments();
+ $this->assertEquals($container->getDefinition('foo'), $arguments[0]);
+ $this->assertNotSame($container->getDefinition('foo'), $arguments[0]);
+ $this->assertSame($ref, $arguments[1]);
+ $this->assertEquals($container->getDefinition('bar'), $arguments[2]);
+ $this->assertNotSame($container->getDefinition('bar'), $arguments[2]);
+ }
+
+ /**
+ * @group legacy
+ */
public function testProcessDoesInlineServiceOfPrototypeScope()
{
$container = new ContainerBuilder();
@@ -188,6 +243,9 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
$this->assertSame($ref, $args[0]);
}
+ /**
+ * @group legacy
+ */
public function testProcessInlinesOnlyIfSameScope()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
index fb2bb5fca3..0060b35e9a 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
@@ -79,6 +79,9 @@ class ResolveDefinitionTemplatesPassTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($def->isAbstract());
}
+ /**
+ * @group legacy
+ */
public function testProcessDoesNotCopyScope()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php
index 72058868d4..498baf82fc 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php
@@ -61,6 +61,9 @@ class ResolveInvalidReferencesPassTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(), $def->getProperties());
}
+ /**
+ * @group legacy
+ */
public function testStrictFlagIsPreserved()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 8155e0b7c6..7e5564c92b 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -117,10 +117,21 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('Circular reference detected for service "baz", path: "baz".', $e->getMessage(), '->get() throws a LogicException if the service has a circular reference to itself');
}
- $builder->register('foobar', 'stdClass')->setScope('container');
$this->assertTrue($builder->get('bar') === $builder->get('bar'), '->get() always returns the same instance if the service is shared');
}
+ /**
+ * @covers Symfony\Component\DependencyInjection\ContainerBuilder::get
+ * @covers Symfony\Component\DependencyInjection\ContainerBuilder::setShared
+ */
+ public function testNonSharedServicesReturnsDifferentInstances()
+ {
+ $builder = new ContainerBuilder();
+ $builder->register('bar', 'stdClass')->setShared(false);
+
+ $this->assertNotSame($builder->get('bar'), $builder->get('bar'));
+ }
+
/**
* @covers \Symfony\Component\DependencyInjection\ContainerBuilder::get
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
@@ -143,6 +154,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::get
+ * @group legacy
*/
public function testGetReturnsNullOnInactiveScope()
{
@@ -154,6 +166,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::get
+ * @group legacy
*/
public function testGetReturnsNullOnInactiveScopeWhenServiceIsCreatedByAMethod()
{
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
index dd8358e929..603269ccc6 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
@@ -171,6 +171,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \InvalidArgumentException
+ * @group legacy
*/
public function testSetDoesNotAllowPrototypeScope()
{
@@ -180,6 +181,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \RuntimeException
+ * @group legacy
*/
public function testSetDoesNotAllowInactiveScope()
{
@@ -188,6 +190,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$c->set('foo', new \stdClass(), 'foo');
}
+ /**
+ * @group legacy
+ */
public function testSetAlsoSetsScopedService()
{
$c = new Container();
@@ -200,6 +205,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertSame($foo, $scoped['foo']['foo'], '->set() sets a scoped service');
}
+ /**
+ * @group legacy
+ */
public function testSetAlsoCallsSynchronizeService()
{
$c = new ProjectServiceContainer();
@@ -273,6 +281,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @covers Symfony\Component\DependencyInjection\Container::get
+ * @group legacy
*/
public function testGetReturnsNullOnInactiveScope()
{
@@ -311,6 +320,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
}
+ /**
+ * @group legacy
+ */
public function testEnterLeaveCurrentScope()
{
$container = new ProjectServiceContainer();
@@ -336,6 +348,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertSame($scopedFoo1, $scopedFoo3);
}
+ /**
+ * @group legacy
+ */
public function testEnterLeaveScopeWithChildScopes()
{
$container = new Container();
@@ -366,6 +381,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($container->has('a'));
}
+ /**
+ * @group legacy
+ */
public function testEnterScopeRecursivelyWithInactiveChildScopes()
{
$container = new Container();
@@ -407,6 +425,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($container->has('a'));
}
+ /**
+ * @group legacy
+ */
public function testEnterChildScopeRecursively()
{
$container = new Container();
@@ -444,6 +465,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \InvalidArgumentException
+ * @group legacy
*/
public function testEnterScopeNotAdded()
{
@@ -453,6 +475,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \RuntimeException
+ * @group legacy
*/
public function testEnterScopeDoesNotAllowInactiveParentScope()
{
@@ -462,6 +485,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$container->enterScope('bar');
}
+ /**
+ * @group legacy
+ */
public function testLeaveScopeNotActive()
{
$container = new Container();
@@ -486,7 +512,8 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \InvalidArgumentException
- * @dataProvider getBuiltInScopes
+ * @dataProvider getLegacyBuiltInScopes
+ * @group legacy
*/
public function testAddScopeDoesNotAllowBuiltInScopes($scope)
{
@@ -496,6 +523,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \InvalidArgumentException
+ * @group legacy
*/
public function testAddScopeDoesNotAllowExistingScope()
{
@@ -506,7 +534,8 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \InvalidArgumentException
- * @dataProvider getInvalidParentScopes
+ * @dataProvider getLegacyInvalidParentScopes
+ * @group legacy
*/
public function testAddScopeDoesNotAllowInvalidParentScope($scope)
{
@@ -514,6 +543,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$c->addScope(new Scope('foo', $scope));
}
+ /**
+ * @group legacy
+ */
public function testAddScope()
{
$c = new Container();
@@ -529,6 +561,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertSame(array('foo' => array('bar', 'baz'), 'bar' => array('baz'), 'baz' => array()), $this->getField($c, 'scopeChildren'));
}
+ /**
+ * @group legacy
+ */
public function testHasScope()
{
$c = new Container();
@@ -577,6 +612,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($c->initialized('throws_exception_on_service_configuration'));
}
+ /**
+ * @group legacy
+ */
public function testIsScopeActive()
{
$c = new Container();
@@ -593,7 +631,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($c->isScopeActive('foo'));
}
- public function getInvalidParentScopes()
+ public function getLegacyInvalidParentScopes()
{
return array(
array(ContainerInterface::SCOPE_PROTOTYPE),
@@ -601,7 +639,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
);
}
- public function getBuiltInScopes()
+ public function getLegacyBuiltInScopes()
{
return array(
array(ContainerInterface::SCOPE_CONTAINER),
diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
index b501f11839..4bac0e2a0b 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php
@@ -127,9 +127,22 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('foo', $def->getFile(), '->getFile() returns the file to include');
}
+ /**
+ * @covers Symfony\Component\DependencyInjection\Definition::setShared
+ * @covers Symfony\Component\DependencyInjection\Definition::isShared
+ */
+ public function testSetIsShared()
+ {
+ $def = new Definition('stdClass');
+ $this->assertTrue($def->isShared(), '->isShared() returns true by default');
+ $this->assertSame($def, $def->setShared(false), '->setShared() implements a fluent interface');
+ $this->assertFalse($def->isShared(), '->isShared() returns false if the instance must not be shared');
+ }
+
/**
* @covers Symfony\Component\DependencyInjection\Definition::setScope
* @covers Symfony\Component\DependencyInjection\Definition::getScope
+ * @group legacy
*/
public function testSetGetScope()
{
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php
index 5da11359fa..1b75712b79 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php
@@ -81,9 +81,12 @@ class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services17.dot')), $dumper->dump(), '->dump() dumps services');
}
+ /**
+ * @group legacy
+ */
public function testDumpWithScopes()
{
- $container = include self::$fixturesPath.'/containers/container18.php';
+ $container = include self::$fixturesPath.'/containers/legacy-container18.php';
$dumper = new GraphvizDumper($container);
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services18.dot')), $dumper->dump(), '->dump() dumps services');
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
index e97a2dda69..d9b65a43fe 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
@@ -28,12 +28,11 @@ $container
$container
->register('bar', 'Bar\FooClass')
->setArguments(array('foo', new Reference('foo.baz'), new Parameter('foo_bar')))
- ->setScope('container')
->setConfigurator(array(new Reference('foo.baz'), 'configure'))
;
$container
->register('foo_bar', '%foo_class%')
- ->setScope('prototype')
+ ->setShared(false)
;
$container->getParameterBag()->clear();
$container->getParameterBag()->add(array(
@@ -93,7 +92,6 @@ $container
$container
->register('new_factory', 'FactoryClass')
->setProperty('foo', 'bar')
- ->setScope('container')
->setPublic(false)
;
$container
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container18.php
similarity index 100%
rename from src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php
rename to src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container18.php
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container9.php
index 9f4210c9d5..22dc44a4e4 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container9.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container9.php
@@ -30,8 +30,13 @@ $container->
setFactoryService('foo.baz')->
setFactoryMethod('getInstance')
;
+$container
+ ->register('foo_bar', '%foo_class%')
+ ->setScope('prototype')
+;
$container->getParameterBag()->clear();
$container->getParameterBag()->add(array(
+ 'foo_class' => 'Bar\FooClass',
'baz_class' => 'BazClass',
'foo' => 'bar',
));
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/legacy-services9.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/legacy-services9.dot
index 4e8dfb9774..ce52c6dcd0 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/legacy-services9.dot
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/legacy-services9.dot
@@ -6,6 +6,7 @@ digraph sc {
node_foo [label="foo\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_foo_baz [label="foo.baz\nBazClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
node_factory_service [label="factory_service\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
+ node_foo_bar [label="foo_bar\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="dotted"];
node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"];
node_bar [label="bar\n\n", shape=record, fillcolor="#ff9999", style="filled"];
node_foo -> node_foo_baz [label="" style="filled"];
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services6.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services6.xml
index 708e10fd5d..c8e6e30bc9 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services6.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services6.xml
@@ -6,6 +6,9 @@
+
+
+
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 5692ba13ea..dc55972a28 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml
@@ -1,6 +1,7 @@
+ Bar\FooClass
BazClass
bar
@@ -32,5 +33,6 @@
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml
index 9eb7b8915e..a1a320bd82 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml
@@ -6,9 +6,7 @@
-
-
-
+
%path%/foo.php
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
index c4ddc416b4..f1e6e98efa 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
@@ -40,7 +40,7 @@
%foo_bar%
-
+
%path%foo.php
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services6.yml
index 46ac679940..2e702bff2f 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services6.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services6.yml
@@ -1,6 +1,9 @@
services:
constructor: { class: FooClass, factory_method: getInstance }
factory_service: { class: BazClass, factory_method: getInstance, factory_service: baz_factory }
+ scope.container: { class: FooClass, scope: container }
+ scope.custom: { class: FooClass, scope: custom }
+ scope.prototype: { class: FooClass, scope: prototype }
request:
class: Request
synthetic: true
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 64d17262aa..6a5f03d9b8 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml
@@ -1,4 +1,5 @@
parameters:
+ foo_class: Bar\FooClass
baz_class: BazClass
foo: bar
@@ -26,3 +27,6 @@ services:
class: Bar
factory_method: getInstance
factory_service: foo.baz
+ foo_bar:
+ class: %foo_class%
+ scope: prototype
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml
index 78abf4d155..2186620045 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml
@@ -1,9 +1,7 @@
services:
foo: { class: FooClass }
baz: { class: BazClass }
- scope.container: { class: FooClass, scope: container }
- scope.custom: { class: FooClass, scope: custom }
- scope.prototype: { class: FooClass, scope: prototype }
+ not_shared: { class: FooClass, shared: false }
file: { class: FooClass, file: %path%/foo.php }
arguments: { class: FooClass, arguments: [foo, @foo, [true, false]] }
configurator1: { class: FooClass, configurator: sc_configure }
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
index fdab85fc7e..ddb5d3a96a 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
@@ -27,7 +27,7 @@ services:
configurator: ['@foo.baz', configure]
foo_bar:
class: %foo_class%
- scope: prototype
+ shared: false
method_call1:
class: Bar\FooClass
file: %path%foo.php
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index 8bf524ae4f..581dc675fb 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -204,6 +204,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertNull($services['factory_service']->getClass());
$this->assertEquals('baz_factory', $services['factory_service']->getFactoryService());
$this->assertEquals('getInstance', $services['factory_service']->getFactoryMethod());
+ $this->assertEquals('container', $services['scope.container']->getScope());
+ $this->assertEquals('custom', $services['scope.custom']->getScope());
+ $this->assertEquals('prototype', $services['scope.prototype']->getScope());
$this->assertTrue($services['request']->isSynthetic(), '->load() parses the synthetic flag');
$this->assertTrue($services['request']->isSynchronized(), '->load() parses the synchronized flag');
$this->assertTrue($services['request']->isLazy(), '->load() parses the lazy flag');
@@ -217,11 +220,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader->load('services6.xml');
$services = $container->getDefinitions();
$this->assertTrue(isset($services['foo']), '->load() parses elements');
+ $this->assertFalse($services['not_shared']->isShared(), '->load() parses shared flag');
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts element to Definition instances');
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
- $this->assertEquals('container', $services['scope.container']->getScope());
- $this->assertEquals('custom', $services['scope.custom']->getScope());
- $this->assertEquals('prototype', $services['scope.prototype']->getScope());
$this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag');
$this->assertEquals(array('foo', new Reference('foo'), array(true, false)), $services['arguments']->getArguments(), '->load() parses the argument tags');
$this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag');
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
index 28cf0ebf62..058f5b66df 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -133,6 +133,9 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('BazClass', $services['factory_service']->getClass());
$this->assertEquals('baz_factory', $services['factory_service']->getFactoryService());
$this->assertEquals('getInstance', $services['factory_service']->getFactoryMethod());
+ $this->assertEquals('container', $services['scope.container']->getScope());
+ $this->assertEquals('custom', $services['scope.custom']->getScope());
+ $this->assertEquals('prototype', $services['scope.prototype']->getScope());
$this->assertTrue($services['request']->isSynthetic(), '->load() parses the synthetic flag');
$this->assertTrue($services['request']->isSynchronized(), '->load() parses the synchronized flag');
$this->assertTrue($services['request']->isLazy(), '->load() parses the lazy flag');
@@ -146,11 +149,9 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader->load('services6.yml');
$services = $container->getDefinitions();
$this->assertTrue(isset($services['foo']), '->load() parses service elements');
+ $this->assertFalse($services['not_shared']->isShared(), '->load() parses the shared flag');
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts service element to Definition instances');
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
- $this->assertEquals('container', $services['scope.container']->getScope());
- $this->assertEquals('custom', $services['scope.custom']->getScope());
- $this->assertEquals('prototype', $services['scope.prototype']->getScope());
$this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag');
$this->assertEquals(array('foo', new Reference('foo'), array(true, false)), $services['arguments']->getArguments(), '->load() parses the argument tags');
$this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag');
diff --git a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
index 6f2fbcb9df..18a4b3f794 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
@@ -92,6 +92,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
/**
* @expectedException \InvalidArgumentException
+ * @group legacy
*/
public function testTriggerAListenerServiceOutOfScope()
{
@@ -111,6 +112,9 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
$dispatcher->dispatch('onEvent');
}
+ /**
+ * @group legacy
+ */
public function testReEnteringAScope()
{
$event = new Event();