Skip to content

Commit 07e3983

Browse files
committed
Merge branch '2.3' into 2.6
* 2.3: [DependencyInjection] Removed extra strtolower calls [Validator] Fixed Choice when an empty array is used in the "choices" option Fixed tests [StringUtil] Fixed singularification of 'selfies' Fix Portuguese (Portugal) translation for Security improved exception when missing required component CS: unalign = Show a better error when the port is in use CS: unalign => [FrameworkBundle] Check for 'xlf' instead of 'xliff' Add better phpdoc message for getListeners method of the EventDispatcher Conflicts: src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php src/Symfony/Bundle/TwigBundle/Command/LintCommand.php src/Symfony/Component/DependencyInjection/ContainerBuilder.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php src/Symfony/Component/Validator/Constraints/ChoiceValidator.php
2 parents c49cf76 + 65bf250 commit 07e3983

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

ContainerBuilder.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
470470
return $service;
471471
}
472472

473-
if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) {
473+
if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
474474
return $this->get($this->aliasDefinitions[$id]);
475475
}
476476

@@ -684,7 +684,7 @@ public function setAlias($alias, $id)
684684
throw new InvalidArgumentException('$id must be a string, or an Alias object.');
685685
}
686686

687-
if ($alias === strtolower($id)) {
687+
if ($alias === (string) $id) {
688688
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
689689
}
690690

@@ -746,7 +746,7 @@ public function getAlias($id)
746746
{
747747
$id = strtolower($id);
748748

749-
if (!$this->hasAlias($id)) {
749+
if (!isset($this->aliasDefinitions[$id])) {
750750
throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id));
751751
}
752752

@@ -864,7 +864,7 @@ public function getDefinition($id)
864864
{
865865
$id = strtolower($id);
866866

867-
if (!$this->hasDefinition($id)) {
867+
if (!array_key_exists($id, $this->definitions)) {
868868
throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id));
869869
}
870870

@@ -886,8 +886,10 @@ public function getDefinition($id)
886886
*/
887887
public function findDefinition($id)
888888
{
889-
while ($this->hasAlias($id)) {
890-
$id = (string) $this->getAlias($id);
889+
$id = strtolower($id);
890+
891+
while (isset($this->aliasDefinitions[$id])) {
892+
$id = (string) $this->aliasDefinitions[$id];
891893
}
892894

893895
return $this->getDefinition($id);

Dumper/PhpDumper.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,6 @@ public function __construct()
898898
\$this->services =
899899
\$this->scopedServices =
900900
\$this->scopeStacks = array();
901-
902-
\$this->set('service_container', \$this);
903-
904901
EOF;
905902

906903
$code .= "\n";

Tests/ContainerBuilderTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ public function testAliases()
190190
$this->assertTrue($builder->has('bar'), '->setAlias() defines a new service');
191191
$this->assertTrue($builder->get('bar') === $builder->get('foo'), '->setAlias() creates a service that is an alias to another one');
192192

193+
try {
194+
$builder->setAlias('foobar', 'foobar');
195+
$this->fail('->setAlias() throws an InvalidArgumentException if the alias references itself');
196+
} catch (\InvalidArgumentException $e) {
197+
$this->assertEquals('An alias can not reference itself, got a circular reference on "foobar".', $e->getMessage(), '->setAlias() throws an InvalidArgumentException if the alias references itself');
198+
}
199+
193200
try {
194201
$builder->getAlias('foobar');
195202
$this->fail('->getAlias() throws an InvalidArgumentException if the alias does not exist');

Tests/Fixtures/php/services10.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public function __construct()
2929
$this->services =
3030
$this->scopedServices =
3131
$this->scopeStacks = array();
32-
33-
$this->set('service_container', $this);
34-
3532
$this->scopes = array();
3633
$this->scopeChildren = array();
3734
$this->methodMap = array(

Tests/Fixtures/php/services12.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public function __construct()
3333
$this->services =
3434
$this->scopedServices =
3535
$this->scopeStacks = array();
36-
37-
$this->set('service_container', $this);
38-
3936
$this->scopes = array();
4037
$this->scopeChildren = array();
4138
$this->methodMap = array(

Tests/Fixtures/php/services9_compiled.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public function __construct()
2929
$this->services =
3030
$this->scopedServices =
3131
$this->scopeStacks = array();
32-
33-
$this->set('service_container', $this);
34-
3532
$this->scopes = array();
3633
$this->scopeChildren = array();
3734
$this->methodMap = array(

0 commit comments

Comments
 (0)