1 | <?php |
||
21 | class PragmaResolver implements ResolverInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private const PARSER_RESOLVER = 'parser'; |
||
27 | |||
28 | /** |
||
29 | * @var array|ConfigResolver[] |
||
30 | */ |
||
31 | private $resolvers; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $configs = []; |
||
37 | |||
38 | /** |
||
39 | * PragmaResolver constructor. |
||
40 | */ |
||
41 | public function __construct() |
||
45 | |||
46 | /** |
||
47 | * @return void |
||
48 | */ |
||
49 | private function bootResolvers(): void |
||
59 | |||
60 | /** |
||
61 | * @param Readable $readable |
||
62 | * @param TokenInterface $token |
||
63 | * @throws \Railt\Io\Exception\ExternalFileException |
||
64 | */ |
||
65 | public function resolve(Readable $readable, TokenInterface $token): void |
||
77 | |||
78 | /** |
||
79 | * @param string $group |
||
80 | * @param string $name |
||
81 | * @param string $value |
||
82 | */ |
||
83 | private function set(string $group, string $name, string $value): void |
||
91 | |||
92 | /** |
||
93 | * @param Readable $readable |
||
94 | * @param TokenInterface $token |
||
95 | * @param null|string $name |
||
96 | * @return string |
||
97 | * @throws \Railt\Io\Exception\ExternalFileException |
||
98 | */ |
||
99 | private function resolvePragmaName(Readable $readable, TokenInterface $token, ?string $name): string |
||
112 | |||
113 | /** |
||
114 | * @param string $group |
||
115 | * @return iterable |
||
116 | */ |
||
117 | public function all(string $group): iterable |
||
121 | } |
||
122 |
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.