1 | <?php |
||
9 | class CDispatcherBasic implements \Anax\DI\IInjectionAware |
||
10 | { |
||
11 | use \Anax\DI\TInjectionAware; |
||
12 | |||
13 | |||
14 | |||
15 | /** |
||
16 | * Properties |
||
17 | * |
||
18 | */ |
||
19 | private $controllerName; // Name of controller |
||
20 | private $controller; // Actual controller |
||
21 | private $action; // Name of action |
||
22 | private $params; // Params |
||
23 | |||
24 | |||
25 | |||
26 | /** |
||
27 | * Prepare the name. |
||
28 | * |
||
29 | * @param string $name to prepare. |
||
30 | * |
||
31 | * @return string as the prepared name. |
||
32 | */ |
||
33 | public function prepareName($name) |
||
43 | |||
44 | |||
45 | |||
46 | /** |
||
47 | * Set the name of the controller. |
||
48 | * |
||
49 | * @param string $name of the controller, defaults to 'index'. |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function setControllerName($name = 'index') |
||
63 | |||
64 | |||
65 | |||
66 | /** |
||
67 | * Check if a controller exists with this name. |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | public function isValidController() |
||
75 | |||
76 | |||
77 | |||
78 | /** |
||
79 | * Set the name of the action. |
||
80 | * |
||
81 | * @param string $name of the action, defaults to 'index'. |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public function setActionName($name = 'index') |
||
89 | |||
90 | |||
91 | |||
92 | /** |
||
93 | * Set the params. |
||
94 | * |
||
95 | * @param array $params all parameters, defaults to empty. |
||
96 | * |
||
97 | * @return void |
||
98 | */ |
||
99 | public function setParams($params = []) |
||
103 | |||
104 | |||
105 | |||
106 | /** |
||
107 | * Dispatch to a controller, action with parameters. |
||
108 | * |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function isCallable() |
||
126 | |||
127 | |||
128 | |||
129 | /** |
||
130 | * Inspect if callable and throw exception if parts is not callable. |
||
131 | * |
||
132 | * @return void. |
||
133 | */ |
||
134 | public function isCallableOrException() |
||
176 | |||
177 | |||
178 | |||
179 | /** |
||
180 | * Dispatch to a controller, action with parameters. |
||
181 | * |
||
182 | * @return mixed result from dispatched controller action. |
||
183 | */ |
||
184 | public function dispatch() |
||
195 | |||
196 | |||
197 | /** |
||
198 | * Forward to a controller, action with parameters. |
||
199 | * |
||
200 | * @param array $forward with details for controller, action, parameters. |
||
201 | * |
||
202 | * @return mixed result from dispatched controller action. |
||
203 | */ |
||
204 | public function forward($forward = []) |
||
225 | } |
||
226 |
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.