1 | <?php namespace Comodojo\RpcClient; |
||
23 | class RpcRequest { |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $method; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private $parameters = []; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $special_types = []; |
||
39 | |||
40 | private static $supported_special_types = [ |
||
41 | "base64", |
||
42 | "datetime", |
||
43 | "cdata" |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * Request's id |
||
48 | * |
||
49 | * @var boolean|integer |
||
50 | */ |
||
51 | private $id = true; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | private $uid; |
||
57 | |||
58 | 63 | public function __construct() { |
|
63 | |||
64 | /** |
||
65 | * Get request's unique id |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | 12 | public function getUniqueId() { |
|
74 | |||
75 | /** |
||
76 | * Get rpc method |
||
77 | * |
||
78 | * @return string|null |
||
79 | */ |
||
80 | 63 | public function getMethod() { |
|
85 | |||
86 | /** |
||
87 | * Set rpc method |
||
88 | * |
||
89 | * @param string $method |
||
90 | * @return self |
||
91 | * @throws InvalidArgumentException |
||
92 | */ |
||
93 | 63 | public function setMethod($method) { |
|
102 | |||
103 | /** |
||
104 | * Get parameters |
||
105 | * |
||
106 | * @return array |
||
107 | */ |
||
108 | 63 | public function getParameters() { |
|
113 | |||
114 | /** |
||
115 | * Set parameters |
||
116 | * |
||
117 | * @param array $params |
||
118 | * @return self |
||
119 | */ |
||
120 | 63 | public function setParameters(array $params = []) { |
|
127 | |||
128 | /** |
||
129 | * Get values marked as special type |
||
130 | * |
||
131 | * @return array |
||
132 | */ |
||
133 | 39 | public function getSpecialTypes() { |
|
138 | |||
139 | /** |
||
140 | * Set values as special type |
||
141 | * |
||
142 | * @param string $value |
||
143 | * @param string $type |
||
144 | * @return self |
||
145 | * @throws InvalidArgumentException |
||
146 | */ |
||
147 | 9 | public function setSpecialType(&$value, $type) { |
|
160 | |||
161 | /** |
||
162 | * Get request's id |
||
163 | * |
||
164 | * @return int|bool|null |
||
165 | */ |
||
166 | 24 | public function getId() { |
|
171 | |||
172 | /** |
||
173 | * Set request's id |
||
174 | * |
||
175 | * @param int|bool|null $id |
||
176 | * @return self |
||
177 | * @throws InvalidArgumentException |
||
178 | */ |
||
179 | 63 | public function setId($id = null) { |
|
199 | |||
200 | /** |
||
201 | * Export request as an array |
||
202 | * |
||
203 | * @return array |
||
204 | */ |
||
205 | 36 | public function toArray() { |
|
216 | |||
217 | /** |
||
218 | * Static constructor |
||
219 | * |
||
220 | * @param string $method |
||
221 | * @param array $parameters |
||
222 | * @param int|bool|null $id |
||
223 | * @return RpcRequest |
||
224 | * @throws Exception |
||
225 | */ |
||
226 | 63 | public static function create($method, array $parameters = [], $id = true) { |
|
245 | |||
246 | } |
||
247 |
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.