From 6b56e96b6cc838d111a5700b08bafef93d3df9bf Mon Sep 17 00:00:00 2001 From: KonstantinObuhov Date: Mon, 4 Dec 2017 15:58:40 +0300 Subject: [PATCH 1/4] Fix for API methods when return not obj. Fix for API methods which return no object and no array of object result. Methods like this https://vk.com/dev/photos.edit. --- src/getjump/Vk/Response/Api.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/getjump/Vk/Response/Api.php b/src/getjump/Vk/Response/Api.php index b052c5c..5de601c 100644 --- a/src/getjump/Vk/Response/Api.php +++ b/src/getjump/Vk/Response/Api.php @@ -22,7 +22,15 @@ class Api */ public function __construct($data, $callback = false) { - $this->response = !isset($data->response) ? false : new Response($data->response, $callback); + if (!isset($data->response)) { + $this->response = false; + } else { + if (!is_object($data->response) && !is_array($data->response)) { + $this->response = new Response($data, $callback); + } else { + $this->response = new Response($data->response, $callback); + } + } $this->error = !isset($data->error) ? false : new Error($data->error); } From 8aa53800fcb02003de8fe27ea5e5efb1f1bed779 Mon Sep 17 00:00:00 2001 From: KonstantinObuhov Date: Mon, 4 Dec 2017 16:51:29 +0300 Subject: [PATCH 2/4] Fixes for composer.json Fixes for composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3b1e6d9..3f8be6d 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload": { "psr-4": { - "getjump\\Vk\\": "src/getjump/Vk/" + "getjump\\Vk\\": "src/" } } } From 475c5c73105584f3772d0e20a264a2d52a0d09c9 Mon Sep 17 00:00:00 2001 From: KonstantinObuhov Date: Mon, 4 Dec 2017 18:53:17 +0300 Subject: [PATCH 3/4] Reset to 8aa53800fcb02003de8fe27ea5e5efb1f1bed779 Reset to 8aa53800fcb02003de8fe27ea5e5efb1f1bed779 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3f8be6d..3b1e6d9 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload": { "psr-4": { - "getjump\\Vk\\": "src/" + "getjump\\Vk\\": "src/getjump/Vk/" } } } From 6722a56fab4228dec315891a1df249b3f74500ed Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 25 Apr 2022 21:09:43 +0300 Subject: [PATCH 4/4] Update Response.php Count on stdClass fails fix it --- src/getjump/Vk/Response/Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getjump/Vk/Response/Response.php b/src/getjump/Vk/Response/Response.php index 6f6cf83..0b50f41 100644 --- a/src/getjump/Vk/Response/Response.php +++ b/src/getjump/Vk/Response/Response.php @@ -56,7 +56,7 @@ public function __construct($data, $callback = false) } $this->count = !isset($data->count) ? false : $data->count; if (is_array($data) || !isset($data->items)) { - $this->count = count($data); + $this->count = count((array) $data); if (is_array($data) && is_callable($callback)) { foreach ($data as $d) { $this->data[] = call_user_func_array($callback, [$d]);