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
bug #25284 [DI] Cast ids to string, as done on 3.4 (nicolas-grekas, sroze)
This PR was merged into the 4.0 branch.
Discussion
----------
[DI] Cast ids to string, as done on 3.4
| Q | A
| ------------- | ---
| Branch? | 4.0
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
As reported on slack, we're now missing cast-to-string.
This PR puts them explicitly at the places where 3.4 has a call to the removed "normalizeId" method.

Commits
-------
11c6b38 Ensure services & aliases can be referred to with `__toString`able objects
483dd13 [DI] Cast ids to string, as done on 3.4
Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+19-5Lines changed: 19 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -467,6 +467,8 @@ public function getCompiler()
467
467
*/
468
468
publicfunctionset($id, $service)
469
469
{
470
+
$id = (string) $id;
471
+
470
472
if ($this->isCompiled() && (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())) {
471
473
// setting a synthetic service on a compiled container is alright
472
474
thrownewBadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
@@ -484,7 +486,7 @@ public function set($id, $service)
484
486
*/
485
487
publicfunctionremoveDefinition($id)
486
488
{
487
-
if (isset($this->definitions[$id])) {
489
+
if (isset($this->definitions[$id = (string) $id])) {
488
490
unset($this->definitions[$id]);
489
491
$this->removedIds[$id] = true;
490
492
}
@@ -499,6 +501,8 @@ public function removeDefinition($id)
0 commit comments