X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-rpc-php.git/blobdiff_plain/bea99f3af0b12f206710d86a903e292b81a52ae6..65cc029518c695d21785172ac42701f067b0a885:/lib/Connection.php diff --git a/lib/Connection.php b/lib/Connection.php index ed927e0..3b0066c 100644 --- a/lib/Connection.php +++ b/lib/Connection.php @@ -9,7 +9,7 @@ class Connection { protected WebSocket\Client $connection; - public function __construct(string $uri, string $api_login, array $options = []) + public function __construct(string $uri, string $api_login, array $options = null) { $context = $options["context"] ?? stream_context_create(); @@ -34,11 +34,12 @@ class Connection * @note I'm not sure on the response type except that it may be either an object or array. * * @param string $method - * @param array $params + * @param array|null $params + * * @return object|array|bool * @throws Exception */ - public function query(string $method, array $params = []): object|array|bool + public function query(string $method, array|null $params = null): object|array|bool { $id = random_int(1, 99999); @@ -56,7 +57,7 @@ class Connection $reply = json_decode($reply); - if (property_exists($reply, 'response')) { + if (property_exists($reply, 'result')) { if($id !== $reply->id) { throw new Exception('Invalid ID. This is not the expected reply.'); }