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
This PR was merged into the 3.2-dev branch.
Discussion
----------
[DI] Revert "deprecate get() for uncompiled container builders"
| Q | A
| ------------- | ---
| Branch? | 3.2
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #18728
| License | MIT
| Doc PR | -
ping @xabbuh
This reverts commit 27f4680, reversing
changes made to e4177a0.
While upgrading a few projects to 3.2, I found it impossible to remove this deprecation without duplicating "by hand" the instantiation logic of some service needed in a compiler pass.
See https://github.com/dustin10/VichUploaderBundle/blob/master/DependencyInjection/Compiler/RegisterPropelModelsPass.php#L30 for such an example into the wild.
I think we should revert this deprecation. Using the container builder before it is compiled is tricky. Yet, bootstrapping in general is tricky and full of chicken-and-egg issues. In this case, using some services while bootstrapping the container works well. Deprecating would be fine if we were to provide some viable alternative. Duplicating the instantiation logic doesn't qualify as such to me, hence the proposed revert.
@xabbuh, if you'd like to keep some test cases that may be unrelated to the revert, please add comments on the PR, or better
8000
: push on my fork, branch revert-get-deprec.
Commits
-------
e449af0 Revert "feature #18728 deprecate get() for uncompiled container builders (xabbuh)"
@trigger_error(sprintf('Calling %s() before compiling the container is deprecated since version 3.2 and will throw an exception in 4.0.', __METHOD__), E_USER_DEPRECATED);
424
-
}
425
-
426
420
$id = strtolower($id);
427
421
6D40
428
422
if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
$this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service does not exist and NULL_ON_INVALID_REFERENCE is passed as a second argument');
111
108
}
@@ -117,15 +114,13 @@ public function testGetThrowsCircularReferenceExceptionIfServiceHasReferenceToIt
$this->assertInstanceOf('\Bar\FooClass', $builder->get('foo1'), '->createService() requires the file defined by the service definition');
310
289
$this->assertInstanceOf('\Bar\FooClass', $builder->get('foo2'), '->createService() replaces parameters in the file provided by the service definition');
311
290
}
@@ -317,8 +296,6 @@ public function testCreateProxyWithRealServiceInstantiator()
$this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar'), '%unescape_it%'), $builder->get('foo1')->arguments, '->createService() replaces parameters and service references in the arguments provided by the service definition');
349
320
}
350
321
@@ -356,8 +327,6 @@ public function testCreateServiceFactory()
$this->assertEquals(array('bar', $builder->get('bar')), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments');
377
343
}
378
344
@@ -382,9 +348,6 @@ public function testCreateServiceMethodCallsWithEscapedParam()
$this->assertEquals(array('bar', $builder->get('bar'), '%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the properties');
401
361
}
402
362
@@ -411,8 +371,6 @@ public function testCreateServiceConfigurator()
$this->assertEquals($builder->get('foo'), $builder->resolveServices(newReference('foo')), '->resolveServices() resolves service references to service instances');
461
411
$this->assertEquals(array('foo' => array('foo', $builder->get('foo'))), $builder->resolveServices(array('foo' => array('foo', newReference('foo')))), '->resolveServices() resolves service references to service instances in nested arrays');
0 commit comments