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/Container.php
+18-19Lines changed: 18 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -151,30 +151,25 @@ public function set($id, $service)
151
151
thrownewInvalidArgumentException('You cannot set service "service_container".');
152
152
}
153
153
154
+
if (isset($this->privates[$id])) {
155
+
thrownewInvalidArgumentException(sprintf('You cannot set the private service "%s".', $id));
156
+
}
157
+
158
+
if (isset($this->methodMap[$id])) {
159
+
thrownewInvalidArgumentException(sprintf('You cannot set the pre-defined service "%s".', $id));
160
+
}
161
+
154
162
if (isset($this->aliases[$id])) {
155
163
unset($this->aliases[$id]);
156
164
}
157
165
158
-
$this->services[$id] = $service;
159
-
160
166
if (null === $service) {
161
167
unset($this->services[$id]);
162
-
}
163
168
164
-
if (isset($this->privates[$id])) {
165
-
if (null === $service) {
166
-
@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);
167
-
unset($this->privates[$id]);
168
-
} else {
169
-
@trigger_error(sprintf('Setting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
170
-
}
171
-
} elseif (isset($this->methodMap[$id])) {
172
-
if (null === $service) {
173
-
@trigger_error(sprintf('Unsetting the "%s" pre-defined service is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
174
-
} else {
175
-
@trigger_error(sprintf('Setting the "%s" pre-defined service is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
176
-
}
169
+
return;
177
170
}
171
+
172
+
$this->services[$id] = $service;
178
173
}
179
174
180
175
/**
@@ -187,7 +182,7 @@ public function set($id, $service)
187
182
publicfunctionhas($id)
188
183
{
189
184
if (isset($this->privates[$id])) {
190
-
@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);
@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);
224
+
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
225
+
thrownewServiceNotFoundException($id);
226
+
}
227
+
228
+
return;
230
229
}
231
230
if ('service_container' === $id) {
232
231
return$this;
@@ -295,7 +294,7 @@ public function initialized($id)
295
294
}
296
295
297
296
if (isset($this->privates[$id])) {
298
-
@trigger_error(sprintf('Checking for the initialization of the "%s" private service is deprecated since Symfony 3.4 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
$this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
172
-
173
-
$sc = newProjectServiceContainer();
174
-
$sc->set('bar', null);
175
-
$this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
176
-
}
177
-
178
163
publicfunctiontestGet()
179
164
{
180
165
$sc = newProjectServiceContainer();
@@ -275,15 +260,11 @@ public function testInitialized()
275
260
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
276
261
}
277
262
278
-
/**
279
-
* @group legacy
280
-
* @expectedDeprecation Checking for the initialization of the "internal" private service is deprecated since Symfony 3.4 and won't be supported anymore in Symfony 4.0.
281
-
*/
282
263
publicfunctiontestInitializedWithPrivateService()
283
264
{
284
265
$sc = newProjectServiceContainer();
285
266
$sc->get('internal_dependency');
286
-
$this->assertTrue($sc->initialized('internal'));
267
+
$this->assertFalse($sc->initialized('internal'));
287
268
}
288
269
289
270
publicfunctiontestReset()
@@ -360,59 +341,51 @@ public function testThatCloningIsNotSupported()
360
341
}
361
342
362
343
/**
363
-
* @group legacy
364
-
* @expectedDeprecation Unsetting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
* @expectedDeprecation Checking for the existence of the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
0 commit comments