1 | <?php |
||
25 | class ConfigCache |
||
26 | { |
||
27 | const DEFAULT_KEY = 'cache'; |
||
28 | |||
29 | protected $cache; |
||
30 | protected $loader; |
||
31 | protected $config = array(); |
||
32 | protected $arrayAccess; |
||
33 | protected $configuration; |
||
34 | protected $resources = array(); |
||
35 | protected $key; |
||
36 | protected $strict = true; |
||
37 | |||
38 | /** |
||
39 | * Constructor. |
||
40 | * |
||
41 | * @param Cache $cache |
||
42 | * @param LoaderInterface $loader |
||
43 | * @param array $config |
||
44 | */ |
||
45 | 2 | public function __construct(Cache $cache, LoaderInterface $loader, array $config = array()) |
|
51 | |||
52 | /** |
||
53 | * Sets a loader. |
||
54 | * |
||
55 | * @param LoaderInterface $loader |
||
56 | * |
||
57 | * @return ConfigCache |
||
58 | */ |
||
59 | 13 | public function setLoader(LoaderInterface $loader) |
|
65 | |||
66 | /** |
||
67 | * Sets a ArrayAccess to find array value using dotted key. |
||
68 | * |
||
69 | * @param ArrayAccessInterface $arrayAccess |
||
70 | * |
||
71 | * @return ConfigCache |
||
72 | */ |
||
73 | 4 | public function setArrayAccess(ArrayAccessInterface $arrayAccess) |
|
79 | |||
80 | /** |
||
81 | * Adds a resource. |
||
82 | * |
||
83 | * @param string $resource |
||
84 | * @param ConfigurationInterface|null $configuration |
||
85 | * |
||
86 | * @return ConfigCache |
||
87 | */ |
||
88 | 26 | public function addResource($resource, ConfigurationInterface $configuration = null) |
|
94 | |||
95 | /** |
||
96 | * Sets a configuration. |
||
97 | * |
||
98 | * @param ConfigurationInterface $configuration |
||
99 | * |
||
100 | * @return ConfigCache |
||
101 | */ |
||
102 | 1 | public function setConfiguration(ConfigurationInterface $configuration) |
|
108 | |||
109 | /** |
||
110 | * Sets a key (only once). |
||
111 | * |
||
112 | * @param string $key |
||
113 | * |
||
114 | * @return ConfigCache |
||
115 | * |
||
116 | * @throws \RuntimeException |
||
117 | */ |
||
118 | 1 | public function setKey($key) |
|
128 | |||
129 | /** |
||
130 | * Sets a strict mode. |
||
131 | * |
||
132 | * @param bool $strict |
||
133 | * |
||
134 | * @return ConfigCache |
||
135 | */ |
||
136 | 2 | public function setStrict($strict) |
|
142 | |||
143 | /** |
||
144 | * Finds cached array. |
||
145 | * |
||
146 | * @param string $key |
||
147 | * @param mixed $default |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | 1 | public function find($key, $default = array()) |
|
155 | |||
156 | /** |
||
157 | * Finds All cached array. |
||
158 | * |
||
159 | * @return array |
||
160 | */ |
||
161 | 9 | public function findAll() |
|
170 | |||
171 | /** |
||
172 | * Creates PHP cache file. |
||
173 | */ |
||
174 | 2 | public function create() |
|
180 | |||
181 | /** |
||
182 | * Creates PHP cache file internal processing. |
||
183 | * |
||
184 | * @return array |
||
185 | */ |
||
186 | 11 | protected function createInternal() |
|
193 | |||
194 | /** |
||
195 | * Gets a key. |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | 20 | protected function getKey() |
|
203 | |||
204 | /** |
||
205 | * Whether the mode is strict or not. |
||
206 | * |
||
207 | * @return bool |
||
208 | */ |
||
209 | 22 | protected function isStrict() |
|
213 | |||
214 | /** |
||
215 | * Finds cached array internal processing. |
||
216 | * |
||
217 | * @param array $data |
||
218 | * @param string $key |
||
219 | * @param mixed $default |
||
220 | * |
||
221 | * @return array |
||
222 | */ |
||
223 | 7 | protected function findInternal(array $data, $key, $default = array()) |
|
235 | |||
236 | /** |
||
237 | * Loads config files. |
||
238 | * |
||
239 | * @return array |
||
240 | */ |
||
241 | 22 | protected function load() |
|
264 | |||
265 | /** |
||
266 | * Loads a config file which is not strict mode. |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | 2 | protected function loadOne() |
|
274 | |||
275 | /** |
||
276 | * Processes an array of configurations. |
||
277 | * |
||
278 | * @param array $validated validated array |
||
279 | * @param array $validating validating array |
||
280 | * @param ConfigurationInterface $configuration configuration |
||
281 | * @param ArrayNode $masterNode master node |
||
282 | * |
||
283 | * @return array list of (array, ArrayNode) |
||
284 | */ |
||
285 | 23 | protected function processConfiguration( |
|
300 | |||
301 | /** |
||
302 | * Creates master node. |
||
303 | * |
||
304 | * @param ConfigurationInterface $configuration |
||
305 | * |
||
306 | * @return ArrayNode |
||
307 | */ |
||
308 | 22 | protected function createMasterNode() |
|
316 | } |
||
317 |
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.