Skip to content

Commit 578f454

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: bump required Twig version fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility SCA: minor code tweaks Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
2 parents a28dda9 + 9629e8d commit 578f454

File tree

7 files changed

+17
-69
lines changed

7 files changed

+17
-69
lines changed

Compiler/ResolveBindingsPass.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class ResolveBindingsPass extends AbstractRecursivePass
3434
*/
3535
public function process(ContainerBuilder $container)
3636
{
37-
$this->usedBindings = $container->getRemovedBindingIds();
38-
3937
try {
4038
parent::process($container);
4139

ContainerBuilder.php

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
124124

125125
private $removedIds = array();
126126

127-
private $removedBindingIds = array();
128-
129127
private static $internalTypes = array(
130128
'int' => true,
131129
'float' => true,
@@ -502,8 +500,7 @@ public function set($id, $service)
502500
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
503501
}
504502

505-
$this->removeId($id);
506-
unset($this->removedIds[$id]);
503+
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);
507504

508505
parent::set($id, $service);
509506
}
@@ -516,7 +513,8 @@ public function set($id, $service)
516513
public function removeDefinition($id)
517514
{
518515
if (isset($this->definitions[$id = (string) $id])) {
519-
$this->removeId($id);
516+
unset($this->definitions[$id]);
517+
$this->removedIds[$id] = true;
520518
}
521519
}
522520

@@ -838,8 +836,7 @@ public function setAlias($alias, $id)
838836
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
839837
}
840838

841-
$this->removeId($alias);
842-
unset($this->removedIds[$alias]);
839+
unset($this->definitions[$alias], $this->removedIds[$alias]);
843840

844841
return $this->aliasDefinitions[$alias] = $id;
845842
}
@@ -852,7 +849,8 @@ public function setAlias($alias, $id)
852849
public function removeAlias($alias)
853850
{
854851
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
855-
$this->removeId($alias);
852+
unset($this->aliasDefinitions[$alias]);
853+
$this->removedIds[$alias] = true;
856854
}
857855
}
858856

@@ -981,8 +979,7 @@ public function setDefinition($id, Definition $definition)
981979

982980
$id = (string) $id;
983981

984-
$this->removeId($id);
985-
unset($this->removedIds[$id]);
982+
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
986983

987984
return $this->definitions[$id] = $definition;
988985
}
@@ -1511,18 +1508,6 @@ public static function getInitializedConditionals($value)
15111508
return $services;
15121509
}
15131510

1514-
/**
1515-
* Gets removed binding ids.
1516-
*
1517-
* @return array
1518-
*
1519-
* @internal
1520-
*/
1521-
public function getRemovedBindingIds()
1522-
{
1523-
return $this->removedBindingIds;
1524-
}
1525-
15261511
/**
15271512
* Computes a reasonably unique hash of a value.
15281513
*
@@ -1627,21 +1612,4 @@ private function inVendors($path)
16271612

16281613
return false;
16291614
}
1630-
1631-
private function removeId($id)
1632-
{
1633-
$this->removedIds[$id] = true;
1634-
unset($this->aliasDefinitions[$id]);
1635-
1636-
if (!isset($this->definitions[$id])) {
1637-
return;
1638-
}
1639-
1640-
foreach ($this->definitions[$id]->getBindings() as $binding) {
1641-
list(, $identifier) = $binding->getValues();
1642-
$this->removedBindingIds[$identifier] = true;
1643-
}
1644-
1645-
unset($this->definitions[$id]);
1646-
}
16471615
}

Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,6 @@ public function testScalarSetter()
112112
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
113113
}
114114

115-
public function testOverriddenBindings()
116-
{
117-
$container = new ContainerBuilder();
118-
119-
$binding = new BoundArgument('bar');
120-
121-
$container->register('foo', 'stdClass')
122-
->setBindings(array('$foo' => clone $binding));
123-
$container->register('bar', 'stdClass')
124-
->setBindings(array('$foo' => clone $binding));
125-
126-
$container->register('foo', 'stdClass');
127-
128-
(new ResolveBindingsPass())->process($container);
129-
130-
$this->assertInstanceOf('stdClass', $container->get('foo'));
131-
}
132-
133115
public function testTupleBinding()
134116
{
135117
$container = new ContainerBuilder();

Tests/Compiler/ResolveChildDefinitionsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ protected function process(ContainerBuilder $container)
399399

400400
/**
401401
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
402-
* @expectedExceptionMessageRegExp /^Circular reference detected for service "a", path: "a -> c -> b -> a"./
402+
* @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./
403403
*/
404404
public function testProcessDetectsChildDefinitionIndirectCircularReference()
405405
{

Tests/ContainerBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ public function testMerge()
559559
$config->setDefinition('baz', new Definition('BazClass'));
560560
$config->setAlias('alias_for_foo', 'foo');
561561
$container->merge($config);
562-
$this->assertEquals(array('foo', 'bar', 'service_container', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
562+
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
563563

564564
$aliases = $container->getAliases();
565565
$this->assertArrayHasKey('alias_for_foo', $aliases);

Tests/Fixtures/config/instanceof.expected.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ services:
44
class: Symfony\Component\DependencyInjection\ContainerInterface
55
public: true
66
synthetic: true
7-
foo:
8-
class: App\FooService
9-
public: true
107
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
118
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
129
public: true
@@ -19,3 +16,6 @@ services:
1916

2017
shared: false
2118
configurator: c
19+
foo:
20+
class: App\FooService
21+
public: true

Tests/Fixtures/config/prototype.expected.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ services:
44
class: Symfony\Component\DependencyInjection\ContainerInterface
55
public: true
66
synthetic: true
7-
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
8-
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
7+
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
8+
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
99
public: true
1010
tags:
1111
- { name: foo }
1212
- { name: baz }
1313
deprecated: '%service_id%'
14-
lazy: true
1514
arguments: [1]
1615
factory: f
17-
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
18-
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
16+
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
17+
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
1918
public: true
2019
tags:
2120
- { name: foo }
2221
- { name: baz }
2322
deprecated: '%service_id%'
23+
lazy: true
2424
arguments: [1]
2525
factory: f

0 commit comments

Comments
 (0)