| 1 | <?php |
||
| 13 | class ConfigDAO |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param string $templatePath |
||
| 17 | * @param string $key |
||
| 18 | * @throws \InvalidArgumentException |
||
| 19 | * @return array |
||
| 20 | */ |
||
| 21 | public function findConfig($templatePath, $key = null) |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param string $templatePath |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | private function getConfigPath($templatePath) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param string $templatePath |
||
| 55 | * @return array |
||
| 56 | */ |
||
| 57 | private function loadConfig($templatePath) |
||
| 61 | } |
||
| 62 |
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$xwould be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.