8000 [DI] Remove deprecated scope concept · symfony/symfony@683e837 · GitHub
[go: up one dir, main page]

Skip to content

Commit 683e837

Browse files
[DI] Remove deprecated scope concept
1 parent eca45b7 commit 683e837

File tree

70 files changed

+35
-1660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+35
-1660
lines changed

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
1616
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
1717
use Symfony\Component\DependencyInjection\Container;
18-
use Symfony\Component\DependencyInjection\ContainerInterface;
1918
use Symfony\Component\DependencyInjection\Definition;
2019
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
2120

@@ -68,10 +67,8 @@ public function getProxyFactoryCode(Definition $definition, $id)
6867
{
6968
$instantiation = 'return';
7069

71-
if ($definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
70+
if ($definition->isShared()) {
7271
$instantiation .= " \$this->services['$id'] =";
73-
} elseif ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
74-
$instantiation .= " \$this->services['$id'] = \$this->scopedServices['$scope']['$id'] =";
7572
}
7673

7774
$methodName = 'get'.Container::camelize($id).'Service';

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use Symfony\Component\DependencyInjection\ContainerInterface;
44
use Symfony\Component\DependencyInjection\Container;
5-
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
65
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
76
use Symfony\Component\DependencyInjection\Exception\LogicException;
87
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
@@ -23,11 +22,7 @@ class LazyServiceProjectServiceContainer extends Container
2322
*/
2423
public function __construct()
2524
{
26-
$this->services =
27-
$this->scopedServices =
28-
$this->scopeStacks = array();
29-
$this->scopes = array();
30-
$this->scopeChildren = array();
25+
$this->services = array();
3126
}
3227

3328
/**
@@ -43,7 +38,6 @@ public function __construct()
4338
public function getFooService($lazyLoad = true)
4439
{
4540
if ($lazyLoad) {
46-
4741
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8(
4842
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {
4943
$wrappedInstance = $this->getFooService(false);

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
205205
{
206206
$data = array(
207207
'class' => (string) $definition->getClass(),
208-
'scope' => $definition->getScope(false),
209208
'public' => $definition->isPublic(),
210209
'synthetic' => $definition->isSynthetic(),
211210
'lazy' => $definition->isLazy(),

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
176176
protected function describeContainerDefinition(Definition $definition, array $options = array())
177177
{
178178
$output = '- Class: `'.$definition->getClass().'`'
179-
."\n".'- Scope: `'.$definition->getScope(false).'`'
180179
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
181180
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
182181
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ protected function describeContainerDefinition(Definition $definition, array $op
256256
$description[] = '<comment>Tags</comment> -';
257257
}
258258

259-
$description[] = sprintf('<comment>Scope</comment> %s', $definition->getScope(false));
260259
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
261260
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
262261
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
346346
}
347347
}
348348

349-
$serviceXML->setAttribute('scope', $definition->getScope(false));
350349
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
351350
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
352351
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use Symfony\Component\Debug\ErrorHandler;
3232
use Symfony\Component\DependencyInjection\ContainerBuilder;
3333
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
34-
use Symfony\Component\DependencyInjection\Scope;
3534
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
3635
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
3736
use Symfony\Component\HttpFoundation\Request;
@@ -65,10 +64,6 @@ public function build(ContainerBuilder $container)
6564
{
6665
parent::build($container);
6766

68-
// we need to add the request scope as early as possible so that
69-
// the compilation can find scope widening issues
70-
$container->addScope(new Scope('request'));
71-
7267
$container->addCompilerPass(new RoutingResolverPass());
7368
$container->addCompilerPass(new ProfilerPass());
7469
// must be registered before removing private services as some might be listeners/subscribers

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"definitions": {
33
"definition_1": {
44
"class": "Full\\Qualified\\Class1",
5-
"scope": "container",
65
"public": true,
76
"synthetic": false,
87
"lazy": true,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ definition_1
88
~~~~~~~~~~~~
99
1010
- Class: `Full\Qualified\Class1`
11-
- Scope: `container`
1211
- Public: yes
1312
- Synthetic: no
1413
- Lazy: yes

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<container>
33
<alias id="alias_1" service="service_1" public="true"/>
44
<alias id="alias_2" service="service_2" public="false"/>
5-
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
5+
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
66
<factory class="Full\Qualified\FactoryClass" method="get"/>
77
</definition>
88
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"definitions": {
33
"definition_1": {
44
"class": "Full\\Qualified\\Class1",
5-
"scope": "container",
65
"public": true,
76
"synthetic": false,
87
"lazy": true,
@@ -17,7 +16,6 @@
1716
},
1817
"definition_2": {
1918
"class": "Full\\Qualified\\Class2",
20-
"scope": "container",
2119
"public": false,
2220
"synthetic": true,
2321
"lazy": false,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ definition_1
88
~~~~~~~~~~~~
99
1010
- Class: `Full\Qualified\Class1`
11-
- Scope: `container`
1211
- Public: yes
1312
- Synthetic: no
1413
- Lazy: yes
@@ -21,7 +20,6 @@ definition_2
2120
~~~~~~~~~~~~
2221

2322
- Class: `Full\Qualified\Class2`
24-
- Scope: `container`
2523
- Public: no
2624
- Synthetic: yes
2725
- Lazy: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<container>
33
<alias id="alias_1" service="service_1" public="true"/>
44
<alias id="alias_2" service="service_2" public="false"/>
5-
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
5+
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
66
<factory class="Full\Qualified\FactoryClass" method="get"/>
77
</definition>
8-
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
8+
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
99
<factory service="factory.service" method="get"/>
1010
<tags>
1111
<tag name="tag1">

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"definitions": {
33
"definition_2": {
44
"class": "Full\\Qualified\\Class2",
5-
"scope": "container",
65
"public": false,
76
"synthetic": true,
87
"lazy": false,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ definition_2
88
~~~~~~~~~~~~
99
1010
- Class: `Full\Qualified\Class2`
11-
- Scope: `container`
1211
- Public: no
1312
- Synthetic: yes
1413
- Lazy: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<container>
3-
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
3+
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
44
<factory service="factory.service" method="get"/>
55
<tags>
66
<tag name="tag1">

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"tag1": [
33
{
44
"class": "Full\\Qualified\\Class2",
5-
"scope": "container",
65
"public": false,
76
"synthetic": true,
87
"lazy": false,
@@ -16,7 +15,6 @@
1615
"tag2": [
1716
{
1817
"class": "Full\\Qualified\\Class2",
19-
"scope": "container",
2018
"public": false,
2119
"synthetic": true,
2220
"lazy": false,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ definition_2
88
~~~~~~~~~~~~
99
1010
- Class: `Full\Qualified\Class2`
11-
- Scope: `container`
1211
- Public: no
1312
- Synthetic: yes
1413
- Lazy: no
@@ -26,7 +25,6 @@ definition_2
2625
~~~~~~~~~~~~
2726

2827
- Class: `Full\Qualified\Class2`
29-
- Scope: `container`
3028
- Public: no
3129
- Synthetic: yes
3230
- Lazy: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<container>
33
<tag name="tag1">
4-
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
4+
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
55
<factory service="factory.service" method="get"/>
66
</definition>
77
</tag>
88
<tag name="tag2">
9-
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
9+
<definition id="definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
1010
<factory service="factory.service" method="get"/>
1111
</definition>
1212
</tag>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"class": "Full\\Qualified\\Class1",
3-
"scope": "container",
43
"public": true,
54
"synthetic": false,
65
"lazy": true,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md 10000

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
- Class: `Full\Qualified\Class1`
2-
- Scope: `container`
32
- Public: yes
43
- Synthetic: no
54
- Lazy: yes

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<comment>Service Id</comment> -
22
<comment>Class</comment> Full\Qualified\Class1
33
<comment>Tags</comment> -
4-
<comment>Scope</comment> container
54
<comment>Public</comment> yes
65
<comment>Synthetic</comment> no
76
<comment>Lazy</comment> yes
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<definition class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
2+
<definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" file="">
33
<factory class="Full\Qualified\FactoryClass" method="get"/>
44
</definition>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"class": "Full\\Qualified\\Class2",
3-
"scope": "container",
43
"public": false,
54
"synthetic": true,
65
"lazy": false,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
- Class: `Full\Qualified\Class2`
2-
- Scope: `container`
32
- Public: no
43
- Synthetic: yes
54
- Lazy: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
- tag1 (<info>attr1</info>: val1, <info>attr2</info>: val2)
55
- tag1 (<info>attr3</info>: val3)
66
- tag2 ()
7-
<comment>Scope</comment> container
87
<comment>Public</comment> no
98
<comment>Synthetic</comment> yes
109
<comment>Lazy</comment> no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<definition class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
2+
<definition class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" file="/path/to/file">
33
<factory service="factory.service" method="get"/>
44
<tags>
55
<tag nam 10000 e="tag1">

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* removed all deprecated codes from 2.x versions
8+
49
2.8.0
510
-----
611

src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*
2525
* - non synthetic, non abstract services always have a class set
2626
* - synthetic services are always public
27-
* - synthetic services are always of non-prototype scope
28-
* - shared services are always of non-prototype scope
2927
*
3028
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
3129
*/
@@ -46,16 +44,6 @@ public function process(ContainerBuilder $container)
4644
throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id));
4745
}
4846

49-
// synthetic service has non-prototype scope
50-
if ($definition->isSynthetic() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
51-
throw new RuntimeException(sprintf('A synthetic service ("%s") cannot be of scope "prototype".', $id));
52-
}
53-
54-
// shared service has non-prototype scope
55-
if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope(false)) {
56-
throw new RuntimeException(sprintf('A shared service ("%s") cannot be of scope "prototype".', $id));
57-
}
58-
5947
// non-synthetic, non-abstract service has class
6048
if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass()) {
6149
if ($definition->getFactory()) {

0 commit comments

Comments
 (0)
0