@@ -18,7 +18,7 @@ public function isRequest(): bool{
18
18
return property_exists ($ this ->value ,'method ' ) || property_exists ($ this ->value ,'params ' );
19
19
}
20
20
21
- public function isNotification ($ strictId =true ): bool {
21
+ public function isNotification (bool $ strictId =true ): bool {
22
22
return $ this ->isRequest () && (!property_exists ($ this ->value ,'id ' ) || !($ strictId ?($ this ->value ->id !==null ):($ this ->value ->id )));
23
23
}
24
24
@@ -48,7 +48,6 @@ public static function createRequestMessageV1($id,string $method,array $params=[
48
48
}
49
49
50
50
/**
51
- * @param $id
52
51
* @param string $method
53
52
* @param array $params
54
53
* @return NotificationMessage
@@ -117,7 +116,7 @@ public static function decodeJSON(string $json){
117
116
}
118
117
119
118
/**
120
- * @param $object
119
+ * @param mixed $object
121
120
* @param bool $strictId
122
121
* @return Message
123
122
* @throws JSONRPCException
@@ -130,12 +129,12 @@ public static function parseObject($object,bool $strictId=true){
130
129
}
131
130
132
131
/**
133
- * @param $message
132
+ * @param object $message
134
133
* @param bool $strictId
135
134
* @return Message
136
135
* @throws JSONRPCException
137
136
*/
138
- private static function handleMessage ($ message ,bool $ strictId =true ){
137
+ private static function handleMessage (object $ message ,bool $ strictId =true ){
139
138
if (property_exists ($ message ,'jsonrpc ' )){
140
139
if ($ message ->jsonrpc ==='2.0 ' ){
141
140
return self ::handleMessageV2 ($ message ,$ strictId );
@@ -147,13 +146,14 @@ private static function handleMessage($message,bool $strictId=true){
147
146
}
148
147
149
148
/**
150
- * @param $message
149
+ * @param object $message
151
150
* @param bool $strictId
152
151
* @return null
153
152
* @throws JSONRPCException
154
153
*/
155
- private static function handleMessageV2 ($ message ,bool $ strictId =true ){
154
+ private static function handleMessageV2 (object $ message ,bool $ strictId =true ){
156
155
if (self ::isRequestMessage ($ message )){
156
+ self ::validateMethodPropertyV1 ($ message );
157
157
return null ;
158
158
}elseif (self ::isResponseMessage ($ message )){
159
159
return null ;
@@ -163,11 +163,19 @@ private static function handleMessageV2($message,bool $strictId=true){
163
163
}
164
164
165
165
166
- private static function isRequestMessage ($ message ): bool {
166
+ /**
167
+ * @param object $message
168
+ * @return bool
169
+ */
170
+ private static function isRequestMessage (object $ message ): bool {
167
171
return property_exists ($ message ,'method ' ) || property_exists ($ message ,'params ' );
168
172
}
169
173
170
- private static function isResponseMessage ($ message ): bool {
174
+ /**
175
+ * @param object $message
176
+ * @return bool
177
+ */
178
+ private static function isResponseMessage (object $ message ): bool {
171
179
return property_exists ($ message ,'result ' ) || property_exists ($ message ,'error ' );
172
180
}
173
181
@@ -186,11 +194,11 @@ private static function validateMethodPropertyV1(object $message){
186
194
}
187
195
188
196
/**
189
- * @param $message
197
+ * @param object $message
190
198
* @return void
191
199
* @throws JSONRPCException
192
200
*/
193
- private static function validateParamsPropertyV1 ($ message ){
201
+ private static function validateParamsPropertyV1 (object $ message ){
194
202
if (!property_exists ($ message ,'params ' )){
195
203
throw new JSONRPCException ('[V1] Missing "params" property in request. ' );
196
204
}
@@ -200,22 +208,22 @@ private static function validateParamsPropertyV1($message){
200
208
}
201
209
202
210
/**
203
- * @param $message
211
+ * @param object $message
204
212
* @return void
205
213
* @throws JSONRPCException
206
214
*/
207
- private static function validateResultPropertyV1 ($ message ){
215
+ private static function validateResultPropertyV1 (object $ message ){
208
216
if (!property_exists ($ message ,'result ' )){
209
217
throw new JSONRPCException ('[V1] Missing "result" property in request. ' );
210
218
}
211
219
}
212
220
213
221
/**
214
- * @param $message
222
+ * @param object $message
215
223
* @return void
216
224
* @throws JSONRPCException
217
225
*/
218
- private static function validateErrorPropertyV1 ($ message ){
226
+ private static function validateErrorPropertyV1 (object $ message ){
219
227
if (!property_exists ($ message ,'error ' )){
220
228
throw new JSONRPCException ('[V1] Missing "error" property in request. ' );
221
229
}
@@ -225,12 +233,12 @@ private static function validateErrorPropertyV1($message){
225
233
}
226
234
227
235
/**
228
- * @param $message
236
+ * @param object $message
229
237
* @param bool $strictId
230
238
* @return Message
231
239
* @throws JSONRPCException
232
240
*/
233
- private static function handleMessageV1 ($ message ,bool $ strictId =true ){
241
+ private static function handleMessageV1 (object $ message ,bool $ strictId =true ){
234
242
if (self ::isRequestMessage ($ message )){
235
243
self ::validateMethodPropertyV1 ($ message );
236
244
self ::validateParamsPropertyV1 ($ message );
0 commit comments