Skip to content

Navigation Menu

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 c9e8318

Browse filesBrowse files
committed
review
1 parent 7b0d6ed commit c9e8318
Copy full SHA for c9e8318

File tree

5 files changed

+20
-11
lines changed
Filter options

5 files changed

+20
-11
lines changed

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
5.3.0
55
-----
66

7-
* added `ServicesConfigurator::remove()` in the PHP-DSL
7+
* added `ServicesConfigurator::remove()` in the PHP-DSL
88

99
5.2.0
1010
-----

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ final public function get(string $id): ServiceConfigurator
8484
/**
8585
* Removes an already defined service definition or alias.
8686
*/
87-
final public function remove(string $id)
87+
final public function remove(string $id): ServicesConfigurator
8888
{
8989
$this->__destruct();
9090

91-
$this->parent->remove($id);
91+
return $this->parent->remove($id);
9292
}
9393

9494
/**

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ServiceConfigurator extends AbstractServiceConfigurator
4545
private $instanceof;
4646
private $allowParent;
4747
private $path;
48+
private $destructed = false;
4849

4950
public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, $id, array $defaultTags, string $path = null)
5051
{
@@ -58,6 +59,11 @@ public function __construct(ContainerBuilder $container, array $instanceof, bool
5859

5960
public function __destruct()
6061
{
62+
if ($this->destructed) {
63+
return;
64+
}
65+
$this->destructed = true;
66+
6167
parent::__destruct();
6268

6369
$this->container->removeBindings($this->id);

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,18 @@ final public function set(?string $id, string $class = null): ServiceConfigurato
9393

9494
$configurator = new ServiceConfigurator($this->container, $this->instanceof, true, $this, $definition, $id, $defaults->getTags(), $this->path);
9595

96-
return null === $class ? $configurator : $configurator->class($class);
96+
return null !== $class ? $configurator->class($class) : $configurator;
9797
}
9898

9999
/**
100100
* Removes an already defined service definition or alias.
101101
*/
102-
final public function remove(string $id)
102+
final public function remove(string $id): self
103103
{
104104
$this->container->removeDefinition($id);
105105
$this->container->removeAlias($id);
106+
107+
return $this;
106108
}
107109

108110
/**

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/remove.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/remove.php
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
return function (ContainerConfigurator $c) {
66
$services = $c->services()->defaults()->public();
77

8-
$services->set('foo', FooService::class);
9-
$services->remove('foo');
8+
$services
9+
->set('foo', FooService::class)
10+
->remove('foo')
1011

11-
$services->set('baz', BazService::class);
12-
$services->alias('baz-alias', 'baz');
13-
$services->remove('baz-alias');
12+
->set('baz', BazService::class)
13+
->alias('baz-alias', 'baz')
14+
->remove('baz-alias')
1415

15-
$services->remove('bat'); // noop
16+
->remove('bat'); // noop
1617
};
1718

0 commit comments

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