1 | <?php |
||
15 | abstract class AbstractResponse implements ResponseInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var RequestInterface |
||
19 | */ |
||
20 | protected $request; |
||
21 | |||
22 | /** |
||
23 | * @var string response data. The property contains RAW response data |
||
24 | * @see decodeData() |
||
25 | * @see isDecoded |
||
26 | */ |
||
27 | protected $data; |
||
28 | |||
29 | /** |
||
30 | * @var bool whether response is already decoded |
||
31 | */ |
||
32 | protected $isDecoded = false; |
||
33 | |||
34 | public function getRequest() |
||
38 | |||
39 | 2 | public function getData() |
|
48 | |||
49 | 2 | public function decodeData() |
|
67 | |||
68 | /** |
||
69 | * Method returns RAW request data. |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | abstract public function getRawData(); |
||
74 | |||
75 | /** |
||
76 | * Whether the request is RAW and should not be decoded. |
||
77 | * @return bool |
||
78 | */ |
||
79 | 2 | public function isRaw() |
|
83 | |||
84 | /** |
||
85 | * Method checks whether response is a JSON response. |
||
86 | * @return bool |
||
87 | */ |
||
88 | 2 | public function isJson() |
|
97 | |||
98 | /** |
||
99 | * @param $name |
||
100 | * @return array |
||
101 | */ |
||
102 | abstract public function getHeader($name); |
||
103 | |||
104 | /** |
||
105 | * @param string $data JSON data |
||
106 | * @return array |
||
107 | */ |
||
108 | 2 | protected function decodeJson($data) |
|
112 | } |
||
113 |
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.