Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
53 | public function await(ContextInterface $ctx, \Generator $process): array |
||
54 | { |
||
55 | while ($process->valid()) { |
||
56 | [$ctx, $value] = $this->factory->resolve($ctx, $process->current()); |
||
|
|||
57 | |||
58 | $process->send($value); |
||
59 | } |
||
60 | |||
61 | if ($value = $process->getReturn()) { |
||
62 | return $this->factory->resolve($ctx, $value); |
||
63 | } |
||
64 | |||
65 | return [$ctx, $value]; |
||
66 | } |
||
67 | } |
||
68 |
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.