possible assignment of non-compatible types.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PhpGitHooks\Infrastructure\Hook; |
||
4 | |||
5 | require_once __DIR__.'/../../../../app/AppKernel.php'; |
||
6 | |||
7 | use AppKernel; |
||
8 | use PhpGitHooks\Module\Git\Contract\Command\PreCommitToolCommand; |
||
9 | use PhpGitHooks\Module\Git\Contract\CommandHandler\PreCommitToolCommandHandler; |
||
10 | use Symfony\Component\Console\Application; |
||
11 | use Symfony\Component\Console\Input\InputInterface; |
||
12 | use Symfony\Component\Console\Output\OutputInterface; |
||
13 | |||
14 | /** |
||
15 | * Class PreCommit. |
||
16 | * |
||
17 | * @codingStandardsIgnoreFile |
||
18 | */ |
||
19 | View Code Duplication | class PreCommit extends Application |
|
20 | { |
||
21 | /** |
||
22 | * @var AppKernel |
||
23 | */ |
||
24 | private $container; |
||
25 | |||
26 | /** |
||
27 | * PreCommit constructor. |
||
28 | */ |
||
29 | public function __construct() |
||
30 | { |
||
31 | $appKernel = new AppKernel('dev', true); |
||
32 | $appKernel->boot(); |
||
33 | $this->container = $appKernel->getContainer(); |
||
0 ignored issues
–
show
|
|||
34 | parent::__construct('pre-commit'); |
||
35 | } |
||
36 | |||
37 | public function doRun(InputInterface $input, OutputInterface $output) |
||
38 | { |
||
39 | /** |
||
40 | * @var PreCommitToolCommandHandler |
||
41 | */ |
||
42 | $command = $this->container->get('bruli.command.bus'); |
||
43 | $command->handle(new PreCommitToolCommand()); |
||
44 | } |
||
45 | } |
||
46 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.