1 | <?php |
||
21 | class View implements Renderable |
||
22 | { |
||
23 | /** |
||
24 | * @var string Name of the template. |
||
25 | */ |
||
26 | protected $template; |
||
27 | |||
28 | /** |
||
29 | * Contains the variables that are to be embedded in the template. |
||
30 | * |
||
31 | * @var \ArrayObject |
||
32 | */ |
||
33 | protected $data; |
||
34 | |||
35 | /** |
||
36 | * Path to templates - is framework restriction. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $path; |
||
41 | |||
42 | /** |
||
43 | * @param string $template |
||
44 | * @param array $data |
||
45 | * @param string $path Path to templates if you do not want to use PIMF framework restriction. |
||
46 | */ |
||
47 | public function __construct($template = 'default.phtml', array $data = array(), $path = null) |
||
53 | |||
54 | /** |
||
55 | * @param string $template |
||
56 | * |
||
57 | * @return View |
||
58 | */ |
||
59 | public function produce($template) |
||
66 | |||
67 | /** |
||
68 | * @param string $template |
||
69 | * @param array|Arrayable $model |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function partial($template, $model = array()) |
||
79 | |||
80 | /** |
||
81 | * @param string $template |
||
82 | * @param array $model |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function loop($template, array $model = array()) |
||
96 | |||
97 | /** |
||
98 | * Assigns a variable to a specific key for the template. |
||
99 | * |
||
100 | * @param string $key The key. |
||
101 | * @param mixed $value The Value. |
||
102 | * |
||
103 | * @return View |
||
104 | */ |
||
105 | public function assign($key, $value) |
||
111 | |||
112 | /** |
||
113 | * Exchange all variables. |
||
114 | * |
||
115 | * @param $model |
||
116 | * |
||
117 | * @return View |
||
118 | */ |
||
119 | public function pump($model) |
||
125 | |||
126 | /** |
||
127 | * @param string $name |
||
128 | * |
||
129 | * @return mixed |
||
130 | * @throws \OutOfBoundsException If undefined property at the template. |
||
131 | */ |
||
132 | public function __get($name) |
||
143 | |||
144 | /** |
||
145 | * @return string |
||
146 | */ |
||
147 | public function render() |
||
167 | |||
168 | /** |
||
169 | * Puts the template an the variables together. |
||
170 | */ |
||
171 | public function reunite() |
||
175 | |||
176 | /** |
||
177 | * Act when the view is treated like a string |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | public function __toString() |
||
185 | } |
||
186 |
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.