1 | <?php |
||
7 | class ShellExec |
||
8 | { |
||
9 | /** @var string */ |
||
10 | private $command; |
||
11 | |||
12 | /** @var string[] */ |
||
13 | private $output; |
||
14 | |||
15 | /** @var string */ |
||
16 | private $lastLine; |
||
17 | |||
18 | /** @var int */ |
||
19 | private $exitStatus; |
||
20 | |||
21 | /** |
||
22 | * ShellExec constructor. |
||
23 | * @param string $command |
||
24 | * @param string[] $output |
||
25 | * @param int $exitStatus |
||
26 | * @param string $lastLine |
||
27 | */ |
||
28 | 1 | public function __construct(string $command, array $output = [], int $exitStatus = -1, string $lastLine = '') |
|
35 | |||
36 | 1 | public function command(): string |
|
40 | |||
41 | 1 | public function output(): array |
|
45 | |||
46 | public function lastLine(): string |
||
50 | |||
51 | 1 | public function exitStatus(): int |
|
55 | |||
56 | 1 | public function exec() |
|
66 | |||
67 | 1 | public static function run(string $command): self |
|
73 | } |
||
74 |
Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.
To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.
The function can be called with either null or an array for the parameter
$needle
but will only accept an array as$haystack
.