1 | <?php |
||
9 | class Event |
||
10 | { |
||
11 | /** @var string READONLY event name, objects must register against this name to see the event */ |
||
12 | public $name = ''; |
||
13 | /** @var mixed|null READWRITE data relevant to the event, no standardised format, refer to event docs */ |
||
14 | public $data = null; |
||
15 | /** |
||
16 | * @var mixed|null READWRITE the results of the event action, only relevant in "_AFTER" advise |
||
17 | * event handlers may modify this if they are preventing the default action |
||
18 | * to provide the after event handlers with event results |
||
19 | */ |
||
20 | public $result = null; |
||
21 | /** @var bool READONLY if true, event handlers can prevent the events default action */ |
||
22 | public $canPreventDefault = true; |
||
23 | |||
24 | /** @var bool whether or not to carry out the default action associated with the event */ |
||
25 | protected $runDefault = true; |
||
26 | /** @var bool whether or not to continue propagating the event to other handlers */ |
||
27 | protected $mayContinue = true; |
||
28 | |||
29 | /** |
||
30 | * event constructor |
||
31 | * |
||
32 | * @param string $name |
||
33 | * @param mixed $data |
||
34 | */ |
||
35 | public function __construct($name, &$data) |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | public function __toString() |
||
49 | |||
50 | /** |
||
51 | * advise all registered BEFORE handlers of this event |
||
52 | * |
||
53 | * if these methods are used by functions outside of this object, they must |
||
54 | * properly handle correct processing of any default action and issue an |
||
55 | * advise_after() signal. e.g. |
||
56 | * $evt = new dokuwiki\Plugin\Doku_Event(name, data); |
||
57 | * if ($evt->advise_before(canPreventDefault) { |
||
58 | * // default action code block |
||
59 | * } |
||
60 | * $evt->advise_after(); |
||
61 | * unset($evt); |
||
62 | * |
||
63 | * @param bool $enablePreventDefault |
||
64 | * @return bool results of processing the event, usually $this->runDefault |
||
65 | */ |
||
66 | public function advise_before($enablePreventDefault = true) |
||
79 | |||
80 | /** |
||
81 | * advise all registered AFTER handlers of this event |
||
82 | * |
||
83 | * @param bool $enablePreventDefault |
||
|
|||
84 | * @see advise_before() for details |
||
85 | */ |
||
86 | public function advise_after() |
||
98 | |||
99 | /** |
||
100 | * trigger |
||
101 | * |
||
102 | * - advise all registered (<event>_BEFORE) handlers that this event is about to take place |
||
103 | * - carry out the default action using $this->data based on $enablePrevent and |
||
104 | * $this->_default, all of which may have been modified by the event handlers. |
||
105 | * - advise all registered (<event>_AFTER) handlers that the event has taken place |
||
106 | * |
||
107 | * @param null|callable $action |
||
108 | * @param bool $enablePrevent |
||
109 | * @return mixed $event->results |
||
110 | * the value set by any <event>_before or <event> handlers if the default action is prevented |
||
111 | * or the results of the default action (as modified by <event>_after handlers) |
||
112 | * or NULL no action took place and no handler modified the value |
||
113 | */ |
||
114 | public function trigger($action = null, $enablePrevent = true) |
||
136 | |||
137 | /** |
||
138 | * stopPropagation |
||
139 | * |
||
140 | * stop any further processing of the event by event handlers |
||
141 | * this function does not prevent the default action taking place |
||
142 | */ |
||
143 | public function stopPropagation() |
||
147 | |||
148 | /** |
||
149 | * may the event propagate to the next handler? |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function mayPropagate() |
||
157 | |||
158 | /** |
||
159 | * preventDefault |
||
160 | * |
||
161 | * prevent the default action taking place |
||
162 | */ |
||
163 | public function preventDefault() |
||
167 | |||
168 | /** |
||
169 | * should the default action be executed? |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function mayRunDefault() |
||
177 | |||
178 | /** |
||
179 | * Convenience method to trigger an event |
||
180 | * |
||
181 | * Creates, triggers and destroys an event in one go |
||
182 | * |
||
183 | * @param string $name name for the event |
||
184 | * @param mixed $data event data |
||
185 | * @param callable $action (optional, default=NULL) default action, a php callback function |
||
186 | * @param bool $canPreventDefault (optional, default=true) can hooks prevent the default action |
||
187 | * |
||
188 | * @return mixed the event results value after all event processing is complete |
||
189 | * by default this is the return value of the default action however |
||
190 | * it can be set or modified by event handler hooks |
||
191 | */ |
||
192 | static public function createAndTrigger($name, &$data, $action = null, $canPreventDefault = true) |
||
197 | } |
||
198 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.