Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecation notice for event_dispatcher service #22208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chalasr opened this issue Mar 28, 2017 · 0 comments
Closed

Deprecation notice for event_dispatcher service #22208

chalasr opened this issue Mar 28, 2017 · 0 comments

Comments

@chalasr
Copy link
Member

chalasr commented Mar 28, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3

ContainerAwareEventDispatcher is deprecated but the event_dispatcher service still relies on it for BC, triggering a deprecation in any user code that makes use of the service.

To reproduce, apply the following patch on this repository:

diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 51f97a5..a2df6c9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -878,6 +878,18 @@ abstract class FrameworkExtensionTest extends TestCase
         $this->assertTrue($container->has('property_info'));
     }
 
+    public function testEventDispatcherDecoration()
+    {
+        $container = $this->createContainer(array('kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret'));
+        $container->registerExtension(new FrameworkExtension());
+        $this->loadFromFile($container, 'default_config');
+        $container
+            ->register('foo', \stdClass::class)
+            ->setProperty('dispatcher', new Reference('event_dispatcher'));
+        $container->compile();
+        $container->get('foo');
+    }
+
     public function testCacheDefaultRedisProvider()
     {
         $container = $this->createContainerFromFile('cache');

Then run ./phpunit src/Symfony/Bundle/FrameworkBundle

Output:

Remaining deprecation notices (3)

The "event_dispatcher" service relies on the deprecated "Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher" class. It should either be deprecated or its implementation upgraded: 3x

Not sure about the better way to fix it, hence the issue.

fabpot added a commit that referenced this issue Apr 3, 2017
… (chalasr)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Dont trigger deprecation for event_dispatcher service

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22208
| License       | MIT
| Doc PR        | n/a

Mute deprecations for the event_dispatcher service keeping only relevant ones i.e when the api of the deprecated class is used intentionally, ugly but prevent breaking test suites like the [LexikJWTAuthenticationBundle one](https://travis-ci.org/lexik/LexikJWTAuthenticationBundle/jobs/216664013#L278).

Commits
-------

a49fe25 [DI] Dont trigger deprecation for event_dispatcher service
@fabpot fabpot closed this as completed Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants