Skip to content

Navigation Menu

Sign in
Appearance settings

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 cd06c12

Browse filesBrowse files
Revert "minor #22039 Skip abstract definitions in compiler passes (chalasr)"
This reverts commit 207d068, reversing changes made to 4836007.
1 parent 46fc0b9 commit cd06c12
Copy full SHA for cd06c12

File tree

7 files changed

+30
-18
lines changed
Filter options

7 files changed

+30
-18
lines changed

‎src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function process(ContainerBuilder $container)
7979
uasort($subscribers, $sortFunc);
8080
foreach ($subscribers as $id => $instance) {
8181
if ($container->getDefinition($id)->isAbstract()) {
82-
continue;
82+
throw new InvalidArgumentException(sprintf('The abstract service "%s" cannot be tagged as a doctrine event subscriber.', $id));
8383
}
8484

8585
$em->addMethodCall('addEventSubscriber', array(new Reference($id)));
@@ -95,7 +95,7 @@ public function process(ContainerBuilder $container)
9595
uasort($listeners, $sortFunc);
9696
foreach ($listeners as $id => $instance) {
9797
if ($container->getDefinition($id)->isAbstract()) {
98-
continue;
98+
throw new InvalidArgumentException(sprintf('The abstract service "%s" cannot be tagged as a doctrine event listener.', $id));
9999
}
100100

101101
$em->addMethodCall('addEventListener', array(

‎src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
class RegisterEventListenersAndSubscribersPassTest extends TestCase
2020
{
21+
/**
22+
* @expectedException \InvalidArgumentException
23+
*/
2124
public function testExceptionOnAbstractTaggedSubscriber()
2225
{
2326
$container = $this->createBuilder();
@@ -29,10 +32,12 @@ public function testExceptionOnAbstractTaggedSubscriber()
2932
$container->setDefinition('a', $abstractDefinition);
3033

3134
$this->process($container);
32-
$this->assertSame(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
3335
}
3436

35-
public function testAbstractTaggedListenerIsSkipped()
37+
/**
38+
* @expectedException \InvalidArgumentException
39+
*/
40+
public function testExceptionOnAbstractTaggedListener()
3641
{
3742
$container = $this->createBuilder();
3843

@@ -43,7 +48,6 @@ public function testAbstractTaggedListenerIsSkipped()
4348
$container->setDefinition('a', $abstractDefinition);
4449

4550
$this->process($container);
46-
$this->assertSame(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
4751
}
4852

4953
public function testProcessEventListenersWithPriorities()

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function visibilityProvider()
6262
);
6363
}
6464

65+
/**
66+
* @expectedException \InvalidArgumentException
67+
* @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract.
68+
*/
6569
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
6670
{
6771
$container = new ContainerBuilder();
@@ -73,8 +77,6 @@ public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
7377
$container->setDefinition('my-command', $definition);
7478

7579
$container->compile();
76-
77-
$this->assertSame(array(), $container->getParameter('console.command.ids'));
7880
}
7981

8082
/**

‎src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function process(ContainerBuilder $container)
3232
$definition = $container->getDefinition($id);
3333

3434
if ($definition->isAbstract()) {
35-
continue;
35+
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must not be abstract.', $id));
3636
}
3737

3838
$class = $container->getParameterBag()->resolveValue($definition->getClass());

‎src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public function visibilityProvider()
5050
);
5151
}
5252

53-
public function testProcessSkipAbstractDefinitions()
53+
/**
54+
* @expectedException \InvalidArgumentException
55+
* @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract.
56+
*/
57+
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
5458
{
5559
$container = new ContainerBuilder();
5660
$container->setResourceTracking(false);
@@ -62,8 +66,6 @@ public function testProcessSkipAbstractDefinitions()
6266
$container->setDefinition('my-command', $definition);
6367

6468
$container->compile();
65-
66-
$this->assertSame(array(), $container->getParameter('console.command.ids'));
6769
}
6870

6971
/**

‎src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function process(ContainerBuilder $container)
6363
foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) {
6464
$def = $container->getDefinition($id);
6565
if ($def->isAbstract()) {
66-
continue;
66+
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id));
6767
}
6868

6969
foreach ($events as $event) {
@@ -90,7 +90,7 @@ public function process(ContainerBuilder $container)
9090
foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) {
9191
$def = $container->getDefinition($id);
9292
if ($def->isAbstract()) {
93-
continue;
93+
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as event subscribers are lazy-loaded.', $id));
9494
}
9595

9696
// We must assume that the class value has been correctly filled, even if the service is created by a factory

‎src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public function testValidEventSubscriber()
8787
$registerListenersPass->process($builder);
8888
}
8989

90+
/**
91+
* @expectedException \InvalidArgumentException
92+
* @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded.
93+
*/
9094
public function testAbstractEventListener()
9195
{
9296
$container = new ContainerBuilder();
@@ -95,20 +99,20 @@ public function testAbstractEventListener()
9599

96100
$registerListenersPass = new RegisterListenersPass();
97101
$registerListenersPass->process($container);
98-
99-
$this->assertSame(array(), $container->getDefinition('event_dispatcher')->getMethodCalls());
100102
}
101103

102-
public function testAbstractEventSubscriberIsSkipped()
104+
/**
105+
* @expectedException \InvalidArgumentException
106+
* @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded.
107+
*/
108+
public function testAbstractEventSubscriber()
103109
{
104110
$container = new ContainerBuilder();
105111
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', array());
106112
$container->register('event_dispatcher', 'stdClass');
107113

108114
$registerListenersPass = new RegisterListenersPass();
109115
$registerListenersPass->process($container);
110-
111-
$this->assertSame(array(), $container->getDefinition('event_dispatcher')->getMethodCalls());
112116
}
113117

114118
public function testEventSubscriberResolvableClassName()

0 commit comments

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