| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | private function add(string $email) |
||
| 41 | { |
||
| 42 | if (array_key_exists($email, $this->dictionary)) { |
||
| 43 | return; |
||
| 44 | } |
||
| 45 | |||
| 46 | [$localPart] = explode('@', $email); |
||
|
|
|||
| 47 | |||
| 48 | while (in_array($localPart.'@'.$this->domain, $this->dictionary)) { |
||
| 49 | $localPart = $this->addOrUpdateIncrement($localPart); |
||
| 50 | } |
||
| 51 | |||
| 52 | $this->dictionary[$email] = $localPart.'@'.$this->domain; |
||
| 53 | } |
||
| 54 | |||
| 69 |
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.