Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
26 | public function resolve(Readable $readable, TokenInterface $token): void |
||
27 | { |
||
28 | [$name, $value] = [$token->value(1), $token->value(2)]; |
||
29 | |||
30 | foreach ($this->getResolvers() as $group => $resolver) { |
||
31 | if ($resolver->match($name)) { |
||
32 | $name = $this->verifyPragmaName($readable, $token, $resolver->resolve($name)); |
||
33 | |||
34 | $this->set($group, $name, $value); |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 |
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.