Skip to content

Commit 090e406

Browse files
browner12taylorotwell
authored andcommitted
[5.8] Remove fire method (#26392)
* remove `fire` methods these are aliases to the `dispatch()` method. * fix events dispatcher tests update to use `dispatch()` method, as dictated by the contract.
1 parent 573cc96 commit 090e406

File tree

3 files changed

+14
-40
lines changed

3 files changed

+14
-40
lines changed

src/Illuminate/Events/Dispatcher.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,6 @@ public function until($event, $payload = [])
169169
return $this->dispatch($event, $payload, true);
170170
}
171171

172-
/**
173-
* Fire an event and call the listeners.
174-
*
175-
* @param string|object $event
176-
* @param mixed $payload
177-
* @param bool $halt
178-
* @return array|null
179-
*/
180-
public function fire($event, $payload = [], $halt = false)
181-
{
182-
return $this->dispatch($event, $payload, $halt);
183-
}
184-
185172
/**
186173
* Fire an event and call the listeners.
187174
*

src/Illuminate/Support/Testing/Fakes/EventFake.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,6 @@ public function flush($event)
183183
//
184184
}
185185

186-
/**
187-
* Fire an event and call the listeners.
188-
*
189-
* @param string|object $event
190-
* @param mixed $payload
191-
* @param bool $halt
192-
* @return array|null
193-
*/
194-
public function fire($event, $payload = [], $halt = false)
195-
{
196-
return $this->dispatch($event, $payload, $halt);
197-
}
198-
199186
/**
200187
* Fire an event and call the listeners.
201188
*

tests/Events/EventsDispatcherTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testBasicEventExecution()
2626
$d->listen('foo', function ($foo) {
2727
$_SERVER['__event.test'] = $foo;
2828
});
29-
$d->fire('foo', ['bar']);
29+
$d->dispatch('foo', ['bar']);
3030
$this->assertEquals('bar', $_SERVER['__event.test']);
3131
}
3232

@@ -51,7 +51,7 @@ public function testContainerResolutionOfEventHandlers()
5151
$container->shouldReceive('make')->once()->with('FooHandler')->andReturn($handler = m::mock(stdClass::class));
5252
$handler->shouldReceive('onFooEvent')->once()->with('foo', 'bar');
5353
$d->listen('foo', 'FooHandler@onFooEvent');
54-
$d->fire('foo', ['foo', 'bar']);
54+
$d->dispatch('foo', ['foo', 'bar']);
5555
}
5656

5757
public function testContainerResolutionOfEventHandlersWithDefaultMethods()
@@ -60,7 +60,7 @@ public function testContainerResolutionOfEventHandlersWithDefaultMethods()
6060
$container->shouldReceive('make')->once()->with('FooHandler')->andReturn($handler = m::mock(stdClass::class));
6161
$handler->shouldReceive('handle')->once()->with('foo', 'bar');
6262
$d->listen('foo', 'FooHandler');
63-
$d->fire('foo', ['foo', 'bar']);
63+
$d->dispatch('foo', ['foo', 'bar']);
6464
}
6565

6666
public function testQueuedEventsAreFired()
@@ -104,7 +104,7 @@ public function testWildcardListeners()
104104
$d->listen('bar.*', function () {
105105
$_SERVER['__event.test'] = 'nope';
106106
});
107-
$d->fire('foo.bar');
107+
$d->dispatch('foo.bar');
108108

109109
$this->assertEquals('wildcard', $_SERVER['__event.test']);
110110
}
@@ -116,13 +116,13 @@ public function testWildcardListenersCacheFlushing()
116116
$d->listen('foo.*', function () {
117117
$_SERVER['__event.test'] = 'cached_wildcard';
118118
});
119-
$d->fire('foo.bar');
119+
$d->dispatch('foo.bar');
120120
$this->assertEquals('cached_wildcard', $_SERVER['__event.test']);
121121

122122
$d->listen('foo.*', function () {
123123
$_SERVER['__event.test'] = 'new_wildcard';
124124
});
125-
$d->fire('foo.bar');
125+
$d->dispatch('foo.bar');
126126
$this->assertEquals('new_wildcard', $_SERVER['__event.test']);
127127
}
128128

@@ -134,7 +134,7 @@ public function testListenersCanBeRemoved()
134134
$_SERVER['__event.test'] = 'foo';
135135
});
136136
$d->forget('foo');
137-
$d->fire('foo');
137+
$d->dispatch('foo');
138138

139139
$this->assertFalse(isset($_SERVER['__event.test']));
140140
}
@@ -147,7 +147,7 @@ public function testWildcardListenersCanBeRemoved()
147147
$_SERVER['__event.test'] = 'foo';
148148
});
149149
$d->forget('foo.*');
150-
$d->fire('foo.bar');
150+
$d->dispatch('foo.bar');
151151

152152
$this->assertFalse(isset($_SERVER['__event.test']));
153153
}
@@ -181,14 +181,14 @@ public function testEventPassedFirstToWildcards()
181181
$this->assertEquals('foo.bar', $event);
182182
$this->assertEquals(['first', 'second'], $data);
183183
});
184-
$d->fire('foo.bar', ['first', 'second']);
184+
$d->dispatch('foo.bar', ['first', 'second']);
185185

186186
$d = new Dispatcher;
187187
$d->listen('foo.bar', function ($first, $second) {
188188
$this->assertEquals('first', $first);
189189
$this->assertEquals('second', $second);
190190
});
191-
$d->fire('foo.bar', ['first', 'second']);
191+
$d->dispatch('foo.bar', ['first', 'second']);
192192
}
193193

194194
public function testQueuedEventHandlersAreQueued()
@@ -205,7 +205,7 @@ public function testQueuedEventHandlersAreQueued()
205205
});
206206

207207
$d->listen('some.event', TestDispatcherQueuedHandler::class.'@someMethod');
208-
$d->fire('some.event', ['foo', 'bar']);
208+
$d->dispatch('some.event', ['foo', 'bar']);
209209
}
210210

211211
public function testClassesWork()
@@ -215,7 +215,7 @@ public function testClassesWork()
215215
$d->listen(ExampleEvent::class, function () {
216216
$_SERVER['__event.test'] = 'baz';
217217
});
218-
$d->fire(new ExampleEvent);
218+
$d->dispatch(new ExampleEvent);
219219

220220
$this->assertSame('baz', $_SERVER['__event.test']);
221221
}
@@ -227,7 +227,7 @@ public function testInterfacesWork()
227227
$d->listen(SomeEventInterface::class, function () {
228228
$_SERVER['__event.test'] = 'bar';
229229
});
230-
$d->fire(new AnotherEvent);
230+
$d->dispatch(new AnotherEvent);
231231

232232
$this->assertSame('bar', $_SERVER['__event.test']);
233233
}
@@ -242,7 +242,7 @@ public function testBothClassesAndInterfacesWork()
242242
$d->listen(SomeEventInterface::class, function () {
243243
$_SERVER['__event.test2'] = 'baar';
244244
});
245-
$d->fire(new AnotherEvent);
245+
$d->dispatch(new AnotherEvent);
246246

247247
$this->assertSame('fooo', $_SERVER['__event.test1']);
248248
$this->assertSame('baar', $_SERVER['__event.test2']);

0 commit comments

Comments
 (0)