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 9f195cd

Browse filesBrowse files
committed
feature #13260 [3.0][EventDispatcher][Event] removed deprecated methods (aitboudad)
This PR was merged into the 3.0-dev branch. Discussion ---------- [3.0][EventDispatcher][Event] removed deprecated methods | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Fixed tickets | ~ | Tests pass? | yes | License | MIT Commits ------- 4ab3e8b [3.0] [EventDispatcher][Event] removed deprecated name methods. ba70a48 [3.0] [EventDispatcher][Event] removed deprecated setDispatcher and getDispatcher methods.
2 parents cca5e41 + 4ab3e8b commit 9f195cd
Copy full SHA for 9f195cd

File tree

6 files changed

+7
-130
lines changed
Filter options

6 files changed

+7
-130
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* The methods Event::setDispatcher(), Event::getDispatcher(), Event::setName()
8+
and Event::setName() have been removed.
9+
The event dispatcher and name is passed to the listener call.
10+
411
2.5.0
512
-----
613

‎src/Symfony/Component/EventDispatcher/Event.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Event.php
-70Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ class Event
3434
*/
3535
private $propagationStopped = false;
3636

37-
/**
38-
* @var EventDispatcher Dispatcher that dispatched this event
39-
*/
40-
private $dispatcher;
41-
42-
/**
43-
* @var string This event's name
44-
*/
45-
private $name;
46-
4737
/**
4838
* Returns whether further event listeners should be triggered.
4939
*
@@ -71,64 +61,4 @@ public function stopPropagation()
7161
{
7262
$this->propagationStopped = true;
7363
}
74-
75-
/**
76-
* Stores the EventDispatcher that dispatches this Event.
77-
*
78-
* @param EventDispatcherInterface $dispatcher
79-
*
80-
* @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
81-
*
82-
* @api
83-
*/
84-
public function setDispatcher(EventDispatcherInterface $dispatcher)
85-
{
86-
$this->dispatcher = $dispatcher;
87-
}
88-
89-
/**
90-
* Returns the EventDispatcher that dispatches this Event.
91-
*
92-
* @return EventDispatcherInterface
93-
*
94-
* @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
95-
*
96-
* @api
97-
*/
98-
public function getDispatcher()
99-
{
100-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED);
101-
102-
return $this->dispatcher;
103-
}
104-
105-
/**
106-
* Gets the event's name.
107-
*
108-
* @return string
109-
*
110-
* @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
111-
*
112-
* @api
113-
*/
114-
public function getName()
115-
{
116-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED);
117-
118-
return $this->name;
119-
}
120-
121-
/**
122-
* Sets the event's name property.
123-
*
124-
* @param string $name The event name.
125-
*
126-
* @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
127-
*
128-
* @api
129-
*/
130-
public function setName($name)
131-
{
132-
$this->name = $name;
133-
}
13464
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/EventDispatcher.php
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ public function dispatch($eventName, Event $event = null)
4343
$event = new Event();
4444
}
4545

46-
$event->setDispatcher($this);
47-
$event->setName($eventName);
48-
4946
if (!isset($this->listeners[$eventName])) {
5047
return $event;
5148
}

‎src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php
-21Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,6 @@ public function testDispatch()
121121
$this->assertSame($event, $return);
122122
}
123123

124-
public function testLegacyDispatch()
125-
{
126-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
127-
128-
$event = new Event();
129-
$return = $this->dispatcher->dispatch(self::preFoo, $event);
130-
$this->assertEquals('pre.foo', $event->getName());
131-
}
132-
133124
public function testDispatchForClosure()
134125
{
135126
$invoked = 0;
@@ -247,18 +238,6 @@ public function testRemoveSubscriberWithMultipleListeners()
247238
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
248239
}
249240

250-
public function testLegacyEventReceivesTheDispatcherInstance()
251-
{
252-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
253-
254-
$dispatcher = null;
255-
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
256-
$dispatcher = $event->getDispatcher();
257-
});
258-
$this->dispatcher->dispatch('test');
259-
$this->assertSame($this->dispatcher, $dispatcher);
260-
}
261-
262241
public function testEventReceivesTheDispatcherInstanceAsArgument()
263242
{
264243
$listener = new TestWithDispatcher();

‎src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ public function testHasListenersOnLazyLoad()
164164
$dispatcher = new ContainerAwareEventDispatcher($container);
165165
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
166166

167-
$event->setDispatcher($dispatcher);
168-
$event->setName('onEvent');
169-
170167
$service
171168
->expects($this->once())
172169
->method('onEvent')

‎src/Symfony/Component/EventDispatcher/Tests/EventTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/EventTest.php
-33Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@ class EventTest extends \PHPUnit_Framework_TestCase
2424
*/
2525
protected $event;
2626

27-
/**
28-
* @var \Symfony\Component\EventDispatcher\EventDispatcher
29-
*/
30-
protected $dispatcher;
31-
3227
/**
3328
* Sets up the fixture, for example, opens a network connection.
3429
* This method is called before a test is executed.
3530
*/
3631
protected function setUp()
3732
{
3833
$this->event = new Event();
39-
$this->dispatcher = new EventDispatcher();
4034
}
4135

4236
/**
@@ -46,7 +40,6 @@ protected function setUp()
4640
protected function tearDown()
4741
{
4842
$this->event = null;
49-
$this->dispatcher = null;
5043
}
5144

5245
public function testIsPropagationStopped()
@@ -59,30 +52,4 @@ public function testStopPropagationAndIsPropagationStopped()
5952
$this->event->stopPropagation();
6053
$this->assertTrue($this->event->isPropagationStopped());
6154
}
62-
63-
public function testLegacySetDispatcher()
64-
{
65-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
66-
$this->event->setDispatcher($this->dispatcher);
67-
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
68-
}
69-
70-
public function testLegacyGetDispatcher()
71-
{
72-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
73-
$this->assertNull($this->event->getDispatcher());
74-
}
75-
76-
public function testLegacyGetName()
77-
{
78-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
79-
$this->assertNull($this->event->getName());
80-
}
81-
82-
public function testLegacySetName()
83-
{
84-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
85-
$this->event->setName('foo');
86-
$this->assertEquals('foo', $this->event->getName());
87-
}
8855
}

0 commit comments

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