bug #29853 Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused" (mmarynich)
This PR was merged into the 3.4 branch. Discussion ---------- Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused" This reverts commit44e9a91f30
, reversing changes made to91b28ff081
. | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29836 | License | MIT | Doc PR | 4.2.2 release changed the way tagged service are injected As asked by @nicolas-grekas https://github.com/symfony/symfony/issues/29836#issuecomment-453464500 Commits -------b3e17d2101
Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)"
This commit is contained in:
commit
ea68e28cf0
@ -34,8 +34,6 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$this->usedBindings = $container->getRemovedBindingIds();
|
||||
|
||||
try {
|
||||
parent::process($container);
|
||||
|
||||
|
@ -123,8 +123,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
|
||||
private $removedIds = array();
|
||||
|
||||
private $removedBindingIds = array();
|
||||
|
||||
private static $internalTypes = array(
|
||||
'int' => true,
|
||||
'float' => true,
|
||||
@ -533,8 +531,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
|
||||
}
|
||||
|
||||
$this->removeId($id);
|
||||
unset($this->removedIds[$id]);
|
||||
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);
|
||||
|
||||
parent::set($id, $service);
|
||||
}
|
||||
@ -547,7 +544,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
public function removeDefinition($id)
|
||||
{
|
||||
if (isset($this->definitions[$id = $this->normalizeId($id)])) {
|
||||
$this->removeId($id);
|
||||
unset($this->definitions[$id]);
|
||||
$this->removedIds[$id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -878,8 +876,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
|
||||
}
|
||||
|
||||
$this->removeId($alias);
|
||||
unset($this->removedIds[$alias]);
|
||||
unset($this->definitions[$alias], $this->removedIds[$alias]);
|
||||
|
||||
return $this->aliasDefinitions[$alias] = $id;
|
||||
}
|
||||
@ -892,7 +889,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
public function removeAlias($alias)
|
||||
{
|
||||
if (isset($this->aliasDefinitions[$alias = $this->normalizeId($alias)])) {
|
||||
$this->removeId($alias);
|
||||
unset($this->aliasDefinitions[$alias]);
|
||||
$this->removedIds[$alias] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,8 +1019,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
|
||||
$id = $this->normalizeId($id);
|
||||
|
||||
$this->removeId($id);
|
||||
unset($this->removedIds[$id]);
|
||||
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
|
||||
|
||||
return $this->definitions[$id] = $definition;
|
||||
}
|
||||
@ -1555,18 +1552,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
return $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets removed binding ids.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getRemovedBindingIds()
|
||||
{
|
||||
return $this->removedBindingIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a reasonably unique hash of a value.
|
||||
*
|
||||
@ -1671,21 +1656,4 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function removeId($id)
|
||||
{
|
||||
$this->removedIds[$id] = true;
|
||||
unset($this->aliasDefinitions[$id]);
|
||||
|
||||
if (!isset($this->definitions[$id])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->definitions[$id]->getBindings() as $binding) {
|
||||
list(, $identifier) = $binding->getValues();
|
||||
$this->removedBindingIds[$identifier] = true;
|
||||
}
|
||||
|
||||
unset($this->definitions[$id]);
|
||||
}
|
||||
}
|
||||
|
@ -111,22 +111,4 @@ class ResolveBindingsPassTest extends TestCase
|
||||
|
||||
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
|
||||
}
|
||||
|
||||
public function testOverriddenBindings()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$binding = new BoundArgument('bar');
|
||||
|
||||
$container->register('foo', 'stdClass')
|
||||
->setBindings(array('$foo' => clone $binding));
|
||||
$container->register('bar', 'stdClass')
|
||||
->setBindings(array('$foo' => clone $binding));
|
||||
|
||||
$container->register('foo', 'stdClass');
|
||||
|
||||
(new ResolveBindingsPass())->process($container);
|
||||
|
||||
$this->assertInstanceOf('stdClass', $container->get('foo'));
|
||||
}
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ class ResolveChildDefinitionsPassTest extends TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
||||
* @expectedExceptionMessageRegExp /^Circular reference detected for service "a", path: "a -> c -> b -> a"./
|
||||
* @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./
|
||||
*/
|
||||
public function testProcessDetectsChildDefinitionIndirectCircularReference()
|
||||
{
|
||||
|
@ -559,7 +559,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$config->setDefinition('baz', new Definition('BazClass'));
|
||||
$config->setAlias('alias_for_foo', 'foo');
|
||||
$container->merge($config);
|
||||
$this->assertEquals(array('foo', 'bar', 'service_container', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
|
||||
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
|
||||
|
||||
$aliases = $container->getAliases();
|
||||
$this->assertArrayHasKey('alias_for_foo', $aliases);
|
||||
|
@ -4,9 +4,6 @@ services:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
foo:
|
||||
class: App\FooService
|
||||
public: true
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||
public: true
|
||||
@ -19,3 +16,6 @@ services:
|
||||
|
||||
shared: false
|
||||
configurator: c
|
||||
foo:
|
||||
class: App\FooService
|
||||
public: true
|
||||
|
@ -4,6 +4,15 @@ services:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
public: true
|
||||
synthetic: true
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||
public: true
|
||||
tags:
|
||||
- { name: foo }
|
||||
- { name: baz }
|
||||
deprecated: '%service_id%'
|
||||
arguments: [1]
|
||||
factory: f
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
||||
public: true
|
||||
@ -14,12 +23,3 @@ services:
|
||||
lazy: true
|
||||
arguments: [1]
|
||||
factory: f
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||
public: true
|
||||
tags:
|
||||
- { name: foo }
|
||||
- { name: baz }
|
||||
deprecated: '%service_id%'
|
||||
arguments: [1]
|
||||
factory: f
|
||||
|
Reference in New Issue
Block a user