Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[EventDispatcher] fix BC layer#31258

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?master
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#31221
LicenseMIT
Doc PR-

}
$listener($eventinstanceof Event ?$event :newWrappedEvent($event),$eventName,$this);
// @deprecated: the ternary operator is part of a BC layer and should be removed in 5.0
$listener($eventinstanceof Event || !$listenerinstanceof WrappedListener ?$event :newWrappedEvent($event),$eventName,$this);
Copy link
Member

@chalasrchalasrApr 26, 2019
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$event instanceof Event is always false because of the early return l234
and!$listener instanceof WrappedListener is always true as listeners are optimized at this point (plain\Closure).
Broken test case:

diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.phpindex 8fd0305b0e..db3176dcd1 100644--- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php+++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php@@ -18,6 +18,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Stopwatch\Stopwatch;+use Symfony\Contracts\EventDispatcher\Event as ContractsEvent;  class TraceableEventDispatcherTest extends TestCase {@@ -151,6 +152,15 @@ class TraceableEventDispatcherTest extends TestCase         $this->assertArrayHasKey('stub', $listeners[0]);     }+    public function testDispatchContractsEvent()+    {+        $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());+        $tdispatcher->addListener('foo', function () {}, 5);+        $tdispatcher->dispatch(new ContractsEvent(), 'foo');+        $listeners = $tdispatcher->getCalledListeners();+        $this->assertArrayHasKey('stub', $listeners[0]);+    }+     public function testGetCalledListenersNested()     {         $tdispatcher = null;

@chalasr
Copy link
Member

chalasr commentedApr 26, 2019
edited
Loading

#31254 has been updated and fixes the issue mentioned above (with tests)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr left review comments

+1 more reviewer

@SimperfitSimperfitSimperfit approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

4 participants

@nicolas-grekas@chalasr@Simperfit@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp