Conditions | 1 |
Paths | 1 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | public function run($message, $user) |
||
8 | { |
||
9 | $game = $this->gameService->findGame($game); |
||
|
|||
10 | |||
11 | $this->botApi->sendMessage( |
||
12 | $game->chatId, |
||
13 | 'Ok, changing question.', |
||
14 | 'markdown' |
||
15 | ); |
||
16 | $this->gameService->em->persist($game); |
||
17 | $this->gameService->em->flush(); |
||
18 | $this->gameService->askQuestion($game); |
||
19 | } |
||
20 | } |
||
21 |
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.