1 | <?php |
||
9 | trait EventsEmitter |
||
10 | { |
||
11 | /** |
||
12 | * @var Emitter |
||
13 | */ |
||
14 | public static $events; |
||
15 | |||
16 | /** |
||
17 | * Boot events emitter. |
||
18 | */ |
||
19 | 9 | public function bootEvents() |
|
25 | |||
26 | /** |
||
27 | * Emit event. |
||
28 | * |
||
29 | * @return \League\Event\EventInterface|string |
||
30 | */ |
||
31 | 4 | public static function emit() |
|
35 | |||
36 | /** |
||
37 | * Emit event. |
||
38 | * |
||
39 | * @param string $event |
||
40 | * @param ListenerInterface|callable $listener |
||
41 | * @return EventInterface|string |
||
42 | */ |
||
43 | 1 | public static function on($event, $listener) |
|
47 | |||
48 | /** |
||
49 | * Remove listeners. |
||
50 | * |
||
51 | * @param $event |
||
52 | */ |
||
53 | 1 | public static function off($event) |
|
57 | } |
||
58 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.