1 | <?php |
||
17 | class GecharlResponse |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $hasError; |
||
24 | |||
25 | /** |
||
26 | * @var string $title |
||
27 | */ |
||
28 | private $title; |
||
29 | |||
30 | /** |
||
31 | * Response Message as determined by status code |
||
32 | * @var string $message |
||
33 | */ |
||
34 | private $message; |
||
35 | |||
36 | /** |
||
37 | * Response Body from |
||
38 | * @var object|null $body |
||
39 | */ |
||
40 | private $body; |
||
41 | |||
42 | /** |
||
43 | * @var array $additionalStatusDetails |
||
44 | */ |
||
45 | private $additionalStatus; |
||
46 | |||
47 | /** |
||
48 | * GecharlResponse constructor. |
||
49 | * @param string $code |
||
50 | * @param object|array|null $responseBody |
||
51 | * @throws GecharlErrorException |
||
52 | */ |
||
53 | public function __construct(string $code, $responseBody = null) |
||
77 | |||
78 | /** |
||
79 | * Determine if this ise a success response object |
||
80 | * @return bool |
||
81 | */ |
||
82 | public function successful(): bool |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getTitle(): string |
||
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | */ |
||
98 | public function getMessage(): string |
||
102 | |||
103 | /** |
||
104 | * @return object|array|null |
||
105 | */ |
||
106 | public function getBody() |
||
110 | |||
111 | public function __toString() |
||
115 | |||
116 | } |
||
117 |
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.