Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 63e26fc

Browse filesBrowse files
ro0NLnicolas-grekas
authored andcommitted
[DI] Remove deprecated case insensitive service ids
1 parent d203ee3 commit 63e26fc
Copy full SHA for 63e26fc

21 files changed

+261
-229
lines changed

‎src/Symfony/Bridge/Doctrine/ManagerRegistry.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/ManagerRegistry.php
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ protected function resetService($name)
4949
}
5050
$manager->setProxyInitializer(\Closure::bind(
5151
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
52-
if (isset($this->normalizedIds[$normalizedId = strtolower($name)])) {
53-
$name = $this->normalizedIds[$normalizedId];
54-
}
5552
if (isset($this->aliases[$name])) {
5653
$name = $this->aliases[$name];
5754
}

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* removed `Container::isFrozen`
1111
* removed support for dumping an ucompiled container in `PhpDumper`
1212
* removed support for generating a dumped `Container` without populating the method map
13+
* removed support for case insensitive service identifiers
1314

1415
3.4.0
1516
-----

‎src/Symfony/Component/DependencyInjection/Container.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Container.php
+58-128Lines changed: 58 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,7 @@
2626
*
2727
* Services and parameters are simple key/pair stores.
2828
*
29-
* Parameter and service keys are case insensitive.
30-
*
31-
* A service id can contain lowercased letters, digits, underscores, and dots.
32-
* Underscores are used to separate words, and dots to group services
33-
* under namespaces:
34-
*
35-
* <ul>
36-
* <li>request</li>
37-
* <li>mysql_session_storage</li>
38-
* <li>symfony.mysql_session_storage</li>
39-
* </ul>
40-
*
41-
* A service can also be defined by creating a method named
42-
* getXXXService(), where XXX is the camelized version of the id:
43-
*
44-
* <ul>
45-
* <li>request -> getRequestService()</li>
46-
* <li>mysql_session_storage -> getMysqlSessionStorageService()</li>
47-
* <li>symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()</li>
48-
* </ul>
29+
* Parameter keys are case insensitive.
4930
*
5031
* The container can have three possible behaviors when a service does not exist:
5132
*
@@ -70,11 +51,6 @@ class Container implements ResettableContainerInterface
7051
protected $aliases = array();
7152
protected $loading = array();
7253

73-
/**
74-
* @internal
75-
*/
76-
protected $normalizedIds = array();
77-
7854
private $envCache = array();
7955
private $compiled = false;
8056

@@ -171,8 +147,6 @@ public function setParameter($name, $value)
171147
*/
172148
public function set($id, $service)
173149
{
174-
$id = $this->normalizeId($id);
175-
176150
if ('service_container' === $id) {
177151
throw new InvalidArgumentException('You cannot set service "service_container".');
178152
}
@@ -212,31 +186,24 @@ public function set($id, $service)
212186
*/
213187
public function has($id)
214188
{
215-
for ($i = 2;;) {
216-
if (isset($this->privates[$id])) {
217-
@trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
218-
}
219-
if ('service_container' === $id) {
220-
return true;
221-
}
222-
if (isset($this->aliases[$id])) {
223-
$id = $this->aliases[$id];
224-
}
225-
if (isset($this->services[$id])) {
226-
return true;
227-
}
228-
229-
if (isset($this->methodMap[$id])) {
230-
return true;
231-
}
232-
233-
if (--$i && $id !== $normalizedId = $this->normalizeId($id)) {
234-
$id = $normalizedId;
235-
continue;
236-
}
189+
if (isset($this->privates[$id])) {
190+
@trigger_error(sprintf('Checking for the existence of 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+
}
192+
if ('service_container' === $id) {
193+
return true;
194+
}
195+
if (isset($this->aliases[$id])) {
196+
$id = $this->aliases[$id];
197+
}
198+
if (isset($this->services[$id])) {
199+
return true;
200+
}
237201

238-
return false;
202+
if (isset($this->methodMap[$id])) {
203+
return true;
239204
}
205+
206+
return false;
240207
}
241208

242209
/**
@@ -258,69 +225,60 @@ public function has($id)
258225
*/
259226
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
260227
{
261-
// Attempt to retrieve the service by checking first aliases then
262-
// available services. Service IDs are case insensitive, however since
263-
// this method can be called thousands of times during a request, avoid
264-
// calling $this->normalizeId($id) unless necessary.
265-
for ($i = 2;;) {
266-
if (isset($this->privates[$id])) {
267-
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
268-
}
269-
if ('service_container' === $id) {
270-
return $this;
271-
}
272-
if (isset($this->aliases[$id])) {
273-
$id = $this->aliases[$id];
274-
}
228+
if (isset($this->privates[$id])) {
229+
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
230+
}
231+
if ('service_container' === $id) {
232+
return $this;
233+
}
234+
if (isset($this->aliases[$id])) {
235+
$id = $this->aliases[$id];
236+
}
275237

276-
// Re-use shared service instance if it exists.
277-
if (isset($this->services[$id])) {
278-
return $this->services[$id];
279-
}
238+
// Re-use shared service instance if it exists.
239+
if (isset($this->services[$id])) {
240+
return $this->services[$id];
241+
}
280242

281-
if (isset($this->loading[$id])) {
282-
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
283-
}
243+
if (isset($this->loading[$id])) {
244+
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
245+
}
284246

285-
if (isset($this->methodMap[$id])) {
286-
$method = $this->methodMap[$id];
287-
} elseif (--$i && $id !== $normalizedId = $this->normalizeId($id)) {
288-
$id = $normalizedId;
289-
continue;
290-
} else {
291-
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
292-
if (!$id) {
293-
throw new ServiceNotFoundException($id);
294-
}
247+
if (isset($this->methodMap[$id])) {
248+
$method = $this->methodMap[$id];
249+
} else {
250+
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
251+
if (!$id) {
252+
throw new ServiceNotFoundException($id);
253+
}
295254

296-
$alternatives = array();
297-
foreach ($this->getServiceIds() as $knownId) {
298-
$lev = levenshtein($id, $knownId);
299-
if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) {
300-
$alternatives[] = $knownId;
301-
}
255+
$alternatives = array();
256+
foreach ($this->getServiceIds() as $knownId) {
257+
$lev = levenshtein($id, $knownId);
258+
if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) {
259+
$alternatives[] = $knownId;
302260
}
303-
304-
throw new ServiceNotFoundException($id, null, null, $alternatives);
305261
}
306262

307-
return;
263+
throw new ServiceNotFoundException($id, null, null, $alternatives);
308264
}
309265

310-
$this->loading[$id] = true;
266+
return;
267+
}
311268

312-
try {
313-
$service = $this->$method();
314-
} catch (\Exception $e) {
315-
unset($this->services[$id]);
269+
$this->loading[$id] = true;
316270

317-
throw $e;
318-
} finally {
319-
unset($this->loading[$id]);
320-
}
271+
try {
272+
$service = $this->$method();
273+
} catch (\Exception $e) {
274+
unset($this->services[$id]);
321275

322-
return $service;
276+
throw $e;
277+
} finally {
278+
unset($this->loading[$id]);
323279
}
280+
281+
return $service;
324282
}
325283

326284
/**
@@ -332,8 +290,6 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
332290
*/
333291
public function initialized($id)
334292
{
335-
$id = $this->normalizeId($id);
336-
337293
if ('service_container' === $id) {
338294
return false;
339295
}
@@ -418,32 +374,6 @@ protected function getEnv($name)
418374
return $this->envCache[$name] = $this->getParameter("env($name)");
419375
}
420376

421-
/**
422-
* Returns the case sensitive id used at registration time.
423-
*
424-
* @param string $id
425-
*
426-
* @return string
427-
*
428-
* @internal
429-
*/
430-
public function normalizeId($id)
431-
{
432-
if (!is_string($id)) {
433-
$id = (string) $id;
434-
}
435-
if (isset($this->normalizedIds[$normalizedId = strtolower($id)])) {
436-
$normalizedId = $this->normalizedIds[$normalizedId];
437-
if ($id !== $normalizedId) {
438-
@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);
439-
}
440-
} else {
441-
$normalizedId = $this->normalizedIds[$normalizedId] = $id;
442-
}
443-
444-
return $normalizedId;
445-
}
446-
447377
private function __clone()
448378
{
449379
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.