| Total Complexity | 1 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ApiResponse |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var null|array |
||
| 12 | */ |
||
| 13 | public $body; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var int |
||
| 17 | */ |
||
| 18 | public $status; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var null|array |
||
| 22 | */ |
||
| 23 | public $message; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var null|array |
||
| 27 | */ |
||
| 28 | public $exception; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param null|array|string $body |
||
| 32 | * @param int $status |
||
| 33 | * @param null|array $message |
||
| 34 | * @param null|array $exception |
||
| 35 | */ |
||
| 36 | public function __construct( $body, $status, $message, $exception) |
||
| 42 | } |
||
| 43 | } |
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.