Skip to content

Commit c0a2d02

Browse files
feature #22796 [EventDispatcher] remove deprecated features (xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- [EventDispatcher] remove deprecated features | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 598bec4 [EventDispatcher] remove deprecated features
2 parents 3359a46 + 598bec4 commit c0a2d02

File tree

7 files changed

+8
-446
lines changed

7 files changed

+8
-446
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

-10
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
3333
use Symfony\Component\DependencyInjection\Reference;
3434
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
35-
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
36-
use Symfony\Component\EventDispatcher\EventDispatcher;
3735
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
3836
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3937
use Symfony\Component\Finder\Finder;
@@ -98,13 +96,6 @@ public function load(array $configs, ContainerBuilder $container)
9896
$loader->load('web.xml');
9997
$loader->load('services.xml');
10098

101-
// forward compatibility with Symfony 4.0 where the ContainerAwareEventDispatcher class is removed
102-
if (!class_exists(ContainerAwareEventDispatcher::class)) {
103-
$definition = $container->getDefinition('event_dispatcher');
104-
$definition->setClass(EventDispatcher::class);
105-
$definition->setArguments(array());
106-
}
107-
10899
if (PHP_VERSION_ID < 70000) {
109100
$definition = $container->getDefinition('kernel.class_cache.cache_warmer');
110101
$definition->addTag('kernel.cache_warmer');
@@ -309,7 +300,6 @@ public function load(array $configs, ContainerBuilder $container)
309300
'Symfony\\Component\\DependencyInjection\\Container',
310301

311302
'Symfony\\Component\\EventDispatcher\\Event',
312-
'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher',
313303

314304
'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener',
315305
'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener',

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
<services>
88
<defaults public="false" />
99

10-
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher" public="true">
11-
<argument type="service" id="service_container" />
12-
</service>
10+
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\EventDispatcher" public="true" />
1311
<service id="Symfony\Component\EventDispatcher\EventDispatcherInterface" alias="event_dispatcher" />
1412

1513
<service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel" public="true">

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\EventDispatcher\EventDispatcher;
1818
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
1919
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
20-
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
2120
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
2221

2322
class AutowiringTypesTest extends WebTestCase
@@ -56,12 +55,7 @@ public function testEventDispatcherAutowiring()
5655
$container = static::$kernel->getContainer();
5756

5857
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
59-
60-
if (class_exists(ContainerAwareEventDispatcher::class)) {
61-
$this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
62-
} else {
63-
$this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
64-
}
58+
$this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
6559

6660
static::bootKernel(array('debug' => true));
6761
$container = static::$kernel->getContainer();

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface;
4040
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator;
4141
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
42-
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
4342
use Symfony\Component\ExpressionLanguage\Expression;
4443
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
4544

@@ -1076,11 +1075,8 @@ private function createService(Definition $definition, $id, $tryProxy = true)
10761075
$r = new \ReflectionClass($class = $parameterBag->resolveValue($definition->getClass()));
10771076

10781077
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);
1079-
// don't trigger deprecations for internal uses
1080-
// @deprecated since version 3.3, to be removed in 4.0 along with the deprecated class
1081-
$deprecationWhitelist = array('event_dispatcher' => ContainerAwareEventDispatcher::class);
10821078

1083-
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ") && (!isset($deprecationWhitelist[$id]) || $deprecationWhitelist[$id] !== $class)) {
1079+
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
10841080
@trigger_error(sprintf('The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name), E_USER_DEPRECATED);
10851081
}
10861082
}

src/Symfony/Component/EventDispatcher/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
-----
6+
7+
* removed the `ContainerAwareEventDispatcher` class
8+
49
3.3.0
510
-----
611

src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php

-211
This file was deleted.

0 commit comments

Comments
 (0)