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 #21223 [DI] Deprecate case insentivity of service identifiers (nicolas-grekas)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[DI] Deprecate case insentivity of service identifiers
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | minor (see UPGRADE note)
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #21193
| License | MIT
| Doc PR | -
As discussed in linked RFC.
Commits
-------
d08f1101df [DI] Deprecate case insentivity of service identifiers
@trigger_error(sprintf('Non-string identifiers are deprecated since Symfony 3.3 and won\'t be supported in 4.0 for Alias to "%s" ("%s" given.) Cast it to string beforehand.', $id, $type), E_USER_DEPRECATED);
@trigger_error(sprintf('Relying on its factory\'s return-type to define the class of service "%s" is deprecated since Symfony 3.3 and won\'t work in 4.0. Set the "class" attribute to "%s" on the service definition instead.', $id, $returnType), E_USER_DEPRECATED);
@trigger_error(sprintf('Non-string service identifiers are deprecated since Symfony 3.3 and won\'t be supported in 4.0 for service "%s" ("%s" given.) Cast it to string beforehand.', $id, $type), E_USER_DEPRECATED);
449
+
}
450
+
if (isset($this->normalizedIds[$normalizedId = strtolower($id)])) {
@trigger_error(sprintf('Service identifiers will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.3.', $id, $normalizedId), E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: ContainerBuilder.php
+30-47Lines changed: 30 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -103,11 +103,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
103
103
*/
104
104
private$envCounters = array();
105
105
106
-
/**
107
-
* @var array a map of case less to case sensitive ids
108
-
*/
109
-
private$caseSensitiveIds = array();
110
-
111
106
/**
112
107
* Sets the track resources flag.
113
108
*
@@ -372,18 +367,14 @@ public function getCompiler()
372
367
*/
373
368
publicfunctionset($id, $service)
374
369
{
375
-
$caseSensitiveId = $id;
376
-
$id = strtolower($caseSensitiveId);
370
+
$id = $this->normalizeId($id);
377
371
378
372
if ($this->isFrozen() && (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())) {
379
373
// setting a synthetic service on a frozen container is alright
380
374
thrownewBadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a frozen container is not allowed.', $id));
0 commit comments