These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Robo\Task\Docker; |
||
3 | |||
4 | use Robo\Common\CommandReceiver; |
||
5 | |||
6 | /** |
||
7 | * Executes command inside running Docker container |
||
8 | * |
||
9 | * ```php |
||
10 | * <?php |
||
11 | * $test = $this->taskDockerRun('test_env') |
||
12 | * ->detached() |
||
13 | * ->run(); |
||
14 | * |
||
15 | * $this->taskDockerExec($test) |
||
16 | * ->interactive() |
||
17 | * ->exec('./runtests') |
||
18 | * ->run(); |
||
19 | * |
||
20 | * // alternatively use commands from other tasks |
||
21 | * |
||
22 | * $this->taskDockerExec($test) |
||
23 | * ->interactive() |
||
24 | * ->exec($this->taskCodecept()->suite('acceptance')) |
||
25 | * ->run(); |
||
26 | * ?> |
||
27 | * ``` |
||
28 | * |
||
29 | */ |
||
30 | class Exec extends Base |
||
31 | { |
||
32 | use CommandReceiver; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $command = "docker exec"; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $cid; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $run = ''; |
||
48 | |||
49 | /** |
||
50 | * @param string|\Robo\Result $cidOrResult |
||
51 | */ |
||
52 | public function __construct($cidOrResult) |
||
53 | { |
||
54 | $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; |
||
0 ignored issues
–
show
|
|||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function detached() |
||
61 | { |
||
62 | $this->option('-d'); |
||
63 | return $this; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc)} |
||
68 | */ |
||
69 | public function interactive($interactive = true) |
||
70 | { |
||
71 | if ($interactive) { |
||
72 | $this->option('-i'); |
||
73 | } |
||
74 | return parent::interactive($interactive); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param string|\Robo\Contract\CommandInterface $command |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function exec($command) |
||
83 | { |
||
84 | $this->run = $this->receiveCommand($command); |
||
85 | return $this; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function getCommand() |
||
92 | { |
||
93 | return $this->command . ' ' . $this->arguments . ' ' . $this->cid.' '.$this->run; |
||
94 | } |
||
95 | } |
||
96 |
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.