You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+3
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ CHANGELOG
6
6
7
7
* allowed to prioritize compiler passes by introducing a third argument to `PassConfig::addPass()`, to `Compiler::addPass` and to `ContainerBuilder::addCompilerPass()`
8
8
* added support for PHP constants in YAML configuration files
9
+
* deprecated the ability to set or unset a private service with the `Container::set()` method
10
+
* deprecated the ability to check for the existence of a private service with the `Container::has()` method
11
+
* deprecated the ability to request a private service with the `Container::get()` method
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Container.php
+16
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,7 @@ class Container implements ResettableContainerInterface
65
65
66
66
protected$services = array();
67
67
protected$methodMap = array();
68
+
protected$privates = array();
68
69
protected$aliases = array();
69
70
protected$loading = array();
70
71
@@ -176,6 +177,14 @@ public function set($id, $service)
176
177
if (null === $service) {
177
178
unset($this->services[$id]);
178
179
}
180
+
181
+
if (isset($this->privates[$id])) {
182
+
if (null === $service) {
183
+
@trigger_error(sprintf('Unsetting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
184
+
} else {
185
+
@trigger_error(sprintf('Setting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. A new public service will be created instead.', $id), E_USER_DEPRECATED);
186
+
}
187
+
}
179
188
}
180
189
181
190
/**
@@ -198,6 +207,10 @@ public function has($id)
198
207
if (--$i && $id !== $lcId = strtolower($id)) {
199
208
$id = $lcId;
200
209
} else {
210
+
if (isset($this->privates[$id])) {
211
+
@trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
@@ -268,6 +281,9 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
268
281
269
282
return;
270
283
}
284
+
if (isset($this->privates[$id])) {
285
+
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
@@ -125,7 +126,7 @@ public function testGetServiceIds()
125
126
126
127
$sc = newProjectServiceContainer();
127
128
$sc->set('foo', $obj = new \stdClass());
128
-
$this->assertEquals(array('bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods, followed by service ids defined by set()');
129
+
$this->assertEquals(array('internal', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods, followed by service ids defined by set()');
129
130
}
130
131
131
132
publicfunctiontestSet()
@@ -306,11 +307,63 @@ public function testThatCloningIsNotSupported()
0 commit comments