| 1 | <?php |
||
| 5 | class Request |
||
| 6 | { |
||
| 7 | /** @var array decoded request payload */ |
||
| 8 | public $payload; |
||
| 9 | |||
| 10 | /** @var int id of the request */ |
||
| 11 | public $id; |
||
| 12 | |||
| 13 | /** @var string method name, such as <em>CreateTransaction</em> */ |
||
| 14 | public $method; |
||
| 15 | |||
| 16 | /** @var array request parameters, such as <em>amount</em>, <em>account</em> */ |
||
| 17 | public $params; |
||
| 18 | |||
| 19 | /** @var int amount value in coins */ |
||
| 20 | public $amount; |
||
| 21 | |||
| 22 | public $response; |
||
| 23 | /** |
||
| 24 | * Request constructor. |
||
| 25 | * Parses request payload and populates properties with values. |
||
| 26 | */ |
||
| 27 | public function __construct($response) |
||
| 49 | |||
| 50 | public function account($param) |
||
| 54 | |||
| 55 | } |
||
| 56 |
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.