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');
161
168
162
-
$c->set('alias', $foo = new \stdClass());
163
-
$this->assertSame($foo, $c->get('alias'), '->set() replaces an existing alias');
169
+
$sc = newProjectServiceContainer();
170
+
$sc->set('bar', null);
171
+
$this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
164
172
}
165
173
166
174
publicfunctiontestGet()
@@ -172,9 +180,6 @@ public function testGet()
172
180
$this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
173
181
$this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
174
182
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
183
try {
179
184
$sc->get('');
180
185
$this->fail('->get() throws a \InvalidArgumentException exception if the service is empty');
@@ -337,7 +342,7 @@ public function testInitialized()
337
342
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
338
343
$this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
339
344
340
-
$sc->set('bar', new \stdClass());
345
+
$sc->get('bar');
341
346
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
342
347
}
343
348
@@ -426,7 +431,7 @@ public function testUnsetInternalPrivateServiceIsDeprecated()
426
431
427
432
/**
428
433
* @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.
434
+
* @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