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
feature #22809 [DI] Remove deprecated generating a dumped container without populating the method map (ro0NL)
This PR was merged into the 4.0-dev branch.
Discussion
----------
[DI] Remove deprecated generating a dumped container without populating the method map
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->
See #20113
Commits
-------
fdb8c58 [DI] Remove deprecated generating a dumped container without populating the method map
@trigger_error('Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', E_USER_DEPRECATED);
244
-
245
-
returntrue;
246
-
}
247
-
248
240
returnfalse;
249
241
}
250
242
}
@@ -293,11 +285,6 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
// We only check the convention-based factory in a compiled container (i.e. a child class other than a ContainerBuilder,
298
-
// and only when the dumper has not generated the method map (otherwise the method map is considered to be fully populated by the dumper)
299
-
@trigger_error('Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', E_USER_DEPRECATED);
300
-
// $method is set to the right value, proceed
301
288
} else {
302
289
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
303
290
if (!$id) {
@@ -374,22 +361,7 @@ public function reset()
374
361
*/
375
362
publicfunctiongetServiceIds()
376
363
{
377
-
$ids = array();
378
-
379
-
if (!$this->methodMap && !$thisinstanceof ContainerBuilder && __CLASS__ !== static::class) {
380
-
// We only check the convention-based factory in a compiled container (i.e. a child class other than a ContainerBuilder,
381
-
// and only when the dumper has not generated the method map (otherwise the method map is considered to be fully populated by the dumper)
382
-
@trigger_error('Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', E_USER_DEPRECATED);
383
-
384
-
foreach (get_class_methods($this) as$method) {
385
-
if (preg_match('/^get(.+)Service$/', $method, $match)) {
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
-121
Original file line number
Diff line number
Diff line change
@@ -137,18 +137,6 @@ public function testGetServiceIds()
137
137
$this->assertEquals(array('service_container', 'internal', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by factory methods in the method map, followed by service ids defined by set()');
138
138
}
139
139
140
-
/**
141
-
* @group legacy
142
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
143
-
*/
144
-
publicfunctiontestGetLegacyServiceIds()
145
-
{
146
-
$sc = newLegacyProjectServiceContainer();
147
-
$sc->set('foo', $obj = new \stdClass());
148
-
149
-
$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()');
150
-
}
151
-
152
140
publicfunctiontestSet()
153
141
{
154
142
$sc = newContainer();
@@ -227,38 +215,6 @@ public function testNormalizeIdKeepsCase()
* @expectedDeprecation Service identifiers will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since version 3.3.
233
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
234
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
235
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
236
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
237
-
*/
238
-
publicfunctiontestLegacyGet()
239
-
{
240
-
$sc = newLegacyProjectServiceContainer();
241
-
$sc->set('foo', $foo = new \stdClass());
242
-
243
-
$this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id');
244
-
$this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
245
-
$this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
246
-
$this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
247
-
$this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
248
-
$this->assertSame($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined');
249
-
250
-
$sc->set('bar', $bar = new \stdClass());
251
-
$this->assertSame($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()');
252
-
253
-
try {
254
-
$sc->get('');
255
-
$this->fail('->get() throws a \InvalidArgumentException exception if the service is empty');
256
-
} catch (\Exception$e) {
257
-
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty');
258
-
}
259
-
$this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service is empty');
$this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined');
318
274
}
319
275
320
-
/**
321
-
* @group legacy
322
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
323
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
324
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
325
-
* @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
326
-
*/
327
-
publicfunctiontestLegacyHas()
328
-
{
329
-
$sc = newLegacyProjectServiceContainer();
330
-
$sc->set('foo', new \stdClass());
331
-
332
-
$this->assertFalse($sc->has('foo1'), '->has() returns false if the service does not exist');
333
-
$this->assertTrue($sc->has('foo'), '->has() returns true if the service exists');
334
-
$this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined');
335
-
$this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined');
336
-
$this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined');
337
-
$this->assertTrue($sc->has('foo\\baz'), '->has() returns true if a get*Method() is defined');
338
-
}
339
-
340
276
publicfunctiontestInitialized()
341
277
{
342
278
$sc = newProjectServiceContainer();
@@ -542,60 +478,3 @@ protected function getThrowsExceptionOnServiceConfigurationService()
542
478
thrownew \Exception('Something was terribly wrong while trying to configure the service!');
543
479
}
544
480
}
545
-
546
-
class LegacyProjectServiceContainer extends Container
547
-
{
548
-
public$__bar;
549
-
public$__foo_bar;
550
-
public$__foo_baz;
551
-
public$__internal;
552
-
553
-
publicfunction__construct()
554
-
{
555
-
parent::__construct();
556
-
557
-
$this->__bar = new \stdClass();
558
-
$this->__foo_bar = new \stdClass();
559
-
$this->__foo_baz = new \stdClass();
560
-
$this->__internal = new \stdClass();
561
-
$this->privates = array('internal' => true);
562
-
$this->aliases = array('alias' => 'bar');
563
-
}
564
-
565
-
protectedfunctiongetInternalService()
566
-
{
567
-
return$this->__internal;
568
-
}
569
-
570
-
protectedfunctiongetBarService()
571
-
{
572
-
return$this->__bar;
573
-
}
574
-
575
-
protectedfunctiongetFooBarService()
576
-
{
577
-
return$this->__foo_bar;
578
-
}
579
-
580
-
protectedfunctiongetFoo_BazService()
581
-
{
582
-
return$this->__foo_baz;
583
-
}
584
-
585
-
protectedfunctiongetCircularService()
586
-
{
587
-
return$this->get('circular');
588
-
}
589
-
590
-
protectedfunctiongetThrowExceptionService()
591
-
{
592
-
thrownew \Exception('Something went terribly wrong!');
0 commit comments