8000 minor #21225 [DI] Dont share service when no id provided (nicolas-gre… · symfony/symfony@e355739 · GitHub
[go: up one dir, main page]

Skip to content

Commit e355739

Browse files
minor #21225 [DI] Dont share service when no id provided (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [DI] Dont share service when no id provided | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 814f633 [DI] Dont share service when no id provided
2 parents 44f6a8c + 814f633 commit e355739

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ private function assertUrlPackage(ContainerBuilder $container, DefinitionDecorat
587587

588588
private function assertVersionStrategy(ContainerBuilder $container, Reference $reference, $version, $format)
589589
{
590-
$versionStrategy = $container->getDefinition($reference);
590+
$versionStrategy = $container->getDefinition((string) $reference);
591591
if (null === $version) {
592592
$this->assertEquals('assets.empty_version_strategy', (string) $reference);
593593
} else {

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function testAccess()
162162
);
163163
} elseif (3 === $i) {
164164
$this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]);
165-
$expression = $container->getDefinition($attributes[1])->getArgument(0);
165+
$expression = $container->getDefinition((string) $attributes[1])->getArgument(0);
166166
$this->assertEquals("token.getUsername() matches '/^admin/'", $expression);
167167
}
168168
}

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
430430
}
431431

432432
if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
433-
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
433+
return $this->get((string) $this->aliasDefinitions[$id], $invalidBehavior);
434434
}
435435

436436
try {
@@ -1099,15 +1099,15 @@ private function callMethod($service, $call)
10991099
/**
11001100
* Shares a given service in the container.
11011101
*
1102-
* @param Definition $definition
1103-
* @param mixed $service
1104-
* @param string $id
1102+
* @param Definition $definition
1103+
* @param mixed $service
1104+
* @param string|null $id
11051105
*
11061106
* @throws InactiveScopeException
11071107
*/
11081108
private function shareService(Definition $definition, $service, $id)
11091109
{
1110-
if (self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
1110+
if (null !== $id && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
11111111
if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) {
11121112
throw new InactiveScopeException($id, $scope);
11131113
}

src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testGetContainerExtensionWithInvalidClass()
4646
public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAsServices()
4747
{
4848
$container = new ContainerBuilder();
49-
$container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand');
49+
$container->register('console.command.symfony_component_httpkernel_tests_fixtures_extensionpresentbundle_command_foocommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand');
5050

5151
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
5252
// add() is never called when the found command classes are already registered as services

0 commit comments

Comments
 (0)
0