1 | <?php |
||
25 | trait EventsTrait |
||
26 | { |
||
27 | /** |
||
28 | * @var EventManagerInterface |
||
29 | */ |
||
30 | private $events; |
||
31 | |||
32 | /** |
||
33 | * @var \Zend\EventManager\ListenerAggregateInterface[] |
||
34 | */ |
||
35 | protected $listeners = []; |
||
36 | |||
37 | /** |
||
38 | * @param string $service |
||
39 | * @return mixed |
||
40 | */ |
||
41 | abstract public function get($service); |
||
42 | |||
43 | /** |
||
44 | * @param mixed $service |
||
45 | * @param null $factory |
||
46 | * @return $this |
||
47 | */ |
||
48 | abstract public function set($service, $factory = null); |
||
49 | |||
50 | /** |
||
51 | * @param $service |
||
52 | * @return bool |
||
53 | */ |
||
54 | abstract public function has($service); |
||
55 | |||
56 | /** |
||
57 | * @param mixed|\WebinoLogLib\Message\MessageInterface $level |
||
58 | * @param mixed ...$args |
||
59 | * @return \Psr\Log\LoggerInterface |
||
60 | */ |
||
61 | abstract public function log($level = null, ...$args); |
||
62 | |||
63 | /** |
||
64 | * Require service from services into application |
||
65 | * |
||
66 | * @param string $service Service name |
||
67 | * @throws Exception\DomainException Unable to get service |
||
68 | */ |
||
69 | abstract protected function requireService($service); |
||
70 | |||
71 | /** |
||
72 | * @return EventManagerInterface |
||
73 | */ |
||
74 | public function getEvents() |
||
81 | |||
82 | /** |
||
83 | * @param EventManagerInterface $events |
||
84 | */ |
||
85 | protected function setEvents(EventManagerInterface $events) |
||
89 | |||
90 | /** |
||
91 | * Attach a listener to an event |
||
92 | * |
||
93 | * @param string|\Zend\EventManager\ListenerAggregateInterface $event |
||
94 | * @param string|callable|int $callback If string $event provided, expects PHP callback; |
||
95 | * @param int $priority Invocation priority |
||
96 | * @return \Zend\Stdlib\CallbackHandler|mixed CallbackHandler if attaching callable |
||
97 | * (to allow later unsubscribe); mixed if attaching aggregate |
||
98 | */ |
||
99 | public function bind($event, $callback = null, $priority = 1) |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | public function unbind($event = null, $callback = null, $priority = null) |
||
182 | |||
183 | /** |
||
184 | * {@inheritdoc} |
||
185 | */ |
||
186 | public function emit($event, $argv = [], $callback = null) |
||
202 | |||
203 | /** |
||
204 | * Normalize the callback argument |
||
205 | * |
||
206 | * If the callback is a string, register it to the services then return it. |
||
207 | * |
||
208 | * @param mixed $callback |
||
209 | * @return mixed |
||
210 | */ |
||
211 | private function normalizeCallback($callback) |
||
219 | |||
220 | /** |
||
221 | * @param mixed $event |
||
222 | * @return mixed|string |
||
223 | */ |
||
224 | private function resolveListenerAggregate($event) |
||
235 | } |
||
236 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.