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 9922827

Browse filesBrowse files
[DI] Resolve aliases earlier
1 parent 559ccb2 commit 9922827
Copy full SHA for 9922827

File tree

Expand file treeCollapse file tree

2 files changed

+11
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-11
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Container.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,16 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
249249
// this method can be called thousands of times during a request, avoid
250250
// calling strtolower() unless necessary.
251251
for ($i = 2;;) {
252-
if ('service_container' === $id) {
253-
return $this;
254-
}
255252
if (isset($this->aliases[$id])) {
256253
$id = $this->aliases[$id];
257254
}
258255
// Re-use shared service instance if it exists.
259256
if (isset($this->services[$id]) || array_key_exists($id, $this->services)) {
260257
return $this->services[$id];
261258
}
259+
if ('service_container' === $id) {
260+
return $this;
261+
}
262262

263263
if (isset($this->loading[$id])) {
264264
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
@@ -328,16 +328,16 @@ public function initialized($id)
328328
{
329329
$id = strtolower($id);
330330

331+
if (isset($this->aliases[$id])) {
332+
$id = $this->aliases[$id];
333+
}
334+
331335
if ('service_container' === $id) {
332336
// BC: 'service_container' was a synthetic service previously.
333337
// @todo Change to false in next major release.
334338
return true;
335339
}
336340

337-
if (isset($this->aliases[$id])) {
338-
$id = $this->aliases[$id];
339-
}
340-
341341
return isset($this->services[$id]) || array_key_exists($id, $this->services);
342342
}
343343

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,10 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
14821482
*/
14831483
private function getServiceCall($id, Reference $reference = null)
14841484
{
1485+
while ($this->container->hasAlias($id)) {
1486+
$id = (string) $this->container->getAlias($id);
1487+
}
1488+
14851489
if ('service_container' === $id) {
14861490
return '$this';
14871491
}
@@ -1490,10 +1494,6 @@ private function getServiceCall($id, Reference $reference = null)
14901494
return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
14911495
}
14921496

1493-
if ($this->container->hasAlias($id)) {
1494-
$id = (string) $this->container->getAlias($id);
1495-
}
1496-
14971497
return sprintf('$this->get(\'%s\')', $id);
14981498
}
14991499

0 commit comments

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