1 | <?php |
||
8 | final class ConcealedEmailCollection implements IteratorAggregate |
||
9 | { |
||
10 | /** @var string */ |
||
11 | private $domain; |
||
12 | |||
13 | /** @var array */ |
||
14 | private $dictionary = []; |
||
15 | |||
16 | public function __construct(string $domain) |
||
20 | |||
21 | public static function make(string $domain): self |
||
25 | |||
26 | public function fill(iterable $emails): self |
||
34 | |||
35 | public function getIterator() |
||
39 | |||
40 | private function add(string $email) |
||
54 | |||
55 | private function addOrUpdateIncrement(string $string): string |
||
68 | } |
||
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,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.