1 | <?php |
||
9 | class Route |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * Properties |
||
14 | * |
||
15 | */ |
||
16 | private $name; // A name for this route |
||
17 | private $rule; // The rule for this route |
||
18 | private $action; // The controller action to handle this route |
||
19 | |||
20 | |||
21 | |||
22 | /** |
||
23 | * Set values for route. |
||
24 | * |
||
25 | * @param string $rule for this route |
||
26 | * @param callable $action callable to implement a controller for the route |
||
27 | * |
||
28 | * @return $this |
||
29 | */ |
||
30 | 9 | public function set($rule, $action) |
|
37 | |||
38 | |||
39 | |||
40 | /** |
||
41 | * Check if the route matches a query |
||
42 | * |
||
43 | * @param string $query to match against |
||
44 | * |
||
45 | * @return boolean true if query matches the route |
||
46 | */ |
||
47 | 9 | public function match($query) |
|
83 | |||
84 | |||
85 | |||
86 | /** |
||
87 | * Handle the action for the route. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | 5 | public function handle() |
|
95 | |||
96 | |||
97 | |||
98 | /** |
||
99 | * Set the name of the route. |
||
100 | * |
||
101 | * @param string $name set a name for the route |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setName($name) |
||
110 | |||
111 | |||
112 | |||
113 | /** |
||
114 | * Get the rule for the route. |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getRule() |
||
122 | } |
||
123 |
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.