1 | <?php |
||
9 | class EventHandler |
||
10 | { |
||
11 | |||
12 | // public properties: none |
||
13 | |||
14 | // private properties |
||
15 | protected $hooks = array(); // array of events and their registered handlers |
||
16 | |||
17 | /** |
||
18 | * event_handler |
||
19 | * |
||
20 | * constructor, loads all action plugins and calls their register() method giving them |
||
21 | * an opportunity to register any hooks they require |
||
22 | */ |
||
23 | public function __construct() |
||
37 | |||
38 | /** |
||
39 | * register_hook |
||
40 | * |
||
41 | * register a hook for an event |
||
42 | * |
||
43 | * @param string $event string name used by the event, (incl '_before' or '_after' for triggers) |
||
44 | * @param string $advise |
||
45 | * @param object $obj object in whose scope method is to be executed, |
||
46 | * if NULL, method is assumed to be a globally available function |
||
47 | * @param string $method event handler function |
||
48 | * @param mixed $param data passed to the event handler |
||
49 | * @param int $seq sequence number for ordering hook execution (ascending) |
||
50 | */ |
||
51 | public function register_hook($event, $advise, $obj, $method, $param = null, $seq = 0) |
||
61 | |||
62 | /** |
||
63 | * process the before/after event |
||
64 | * |
||
65 | * @param Event $event |
||
66 | * @param string $advise BEFORE or AFTER |
||
67 | */ |
||
68 | public function process_event($event, $advise = '') |
||
89 | |||
90 | /** |
||
91 | * Check if an event has any registered handlers |
||
92 | * |
||
93 | * When $advise is empty, both BEFORE and AFTER events will be considered, |
||
94 | * otherwise only the given advisory is checked |
||
95 | * |
||
96 | * @param string $name Name of the event |
||
97 | * @param string $advise BEFORE, AFTER or empty |
||
98 | * @return bool |
||
99 | */ |
||
100 | public function hasHandlerForEvent($name, $advise = '') |
||
108 | } |
||
109 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.