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
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -190,7 +190,13 @@ public function set($id, $service)
190
190
@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);
191
191
unset($this->privates[$id]);
192
192
} else {
193
-
@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);
193
+
@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);
194
+
}
195
+
} elseif (isset($this->methodMap[$id])) {
196
+
if (null === $service) {
197
+
@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);
198
+
} else {
199
+
@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);
$this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
176
+
177
+
$sc = newProjectServiceContainer();
178
+
$sc->set('bar', null);
179
+
$this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
180
+
}
181
+
166
182
publicfunctiontestGet()
167
183
{
168
184
$sc = newProjectServiceContainer();
@@ -172,9 +188,6 @@ public function testGet()
172
188
$this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
173
189
$this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
174
190
175
-
$sc->set('bar', $bar = new \stdClass());
176
-
$this->assertSame($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()');
177
-
178
191
try {
179
192
$sc->get('');
180
193
$this->fail('->get() throws a \InvalidArgumentException exception if the service is empty');
@@ -337,7 +350,7 @@ public function testInitialized()
337
350
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
338
351
$this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
339
352
340
-
$sc->set('bar', new \stdClass());
353
+
$sc->get('bar');
341
354
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
342
355
}
343
356
@@ -426,7 +439,7 @@ public function testUnsetInternalPrivateServiceIsDeprecated()
426
439
427
440
/**
428
441
* @group legacy
429
-
* @expectedDeprecation Setting the "internal" 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.
442
+
* @expectedDeprecation Setting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
0 commit comments