| 1 | <?php |
||
| 19 | class Result |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var \SebastianFeldmann\Cli\Command\Result |
||
| 23 | */ |
||
| 24 | private $cmdResult; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var iterable |
||
| 28 | */ |
||
| 29 | private $formatted; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Result constructor. |
||
| 33 | * |
||
| 34 | * @param \SebastianFeldmann\Cli\Command\Result $cmdResult |
||
| 35 | * @param iterable $formatted |
||
| 36 | */ |
||
| 37 | public function __construct(CommandResult $cmdResult, $formatted = []) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Get the raw command result. |
||
| 45 | * |
||
| 46 | * @return \SebastianFeldmann\Cli\Command\Result |
||
| 47 | */ |
||
| 48 | public function getCommandResult() : CommandResult |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Return true if command execution was successful. |
||
| 55 | * |
||
| 56 | * @return bool |
||
| 57 | */ |
||
| 58 | public function isSuccessful() : bool |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Return cmd output as array. |
||
| 65 | * |
||
| 66 | * @return array |
||
| 67 | */ |
||
| 68 | public function getOutput() : array |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Return formatted output. |
||
| 75 | * |
||
| 76 | * @return array |
||
| 77 | * @throws \Exception |
||
| 78 | */ |
||
| 79 | public function getFormattedOutput() |
||
| 83 | } |
||
| 84 |
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
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. 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.