Skip to content

Commit

Permalink
Merge branch 'release/0.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Tsivarev committed Mar 6, 2018
2 parents 87fcaab + df2ea2d commit 56d4398
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
14 changes: 7 additions & 7 deletions src/VK/CallbackApi/LongPoll/VKCallbackApiLongPollExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace VK\CallbackApi\LongPoll;

use VK\CallbackApi\VKCallbackApiHandler;
use VK\CallbackApi\LongPoll\Exceptions\VKLongPollServerKeyExpiredException;
use VK\CallbackApi\LongPoll\Exceptions\VKLongPollServerTsException;
use VK\CallbackApi\VKCallbackApiHandler;
use VK\Client\VKApiClient;
use VK\Exceptions\Api\VKApiException;
use VK\Exceptions\VKClientException;
Expand All @@ -13,6 +13,7 @@
use VK\TransportClient\TransportRequestException;

class VKCallbackApiLongPollExecutor {

protected const PARAM_GROUP_ID = 'group_id';
protected const PARAM_ACT = 'act';
protected const PARAM_KEY = 'key';
Expand Down Expand Up @@ -103,7 +104,9 @@ public function listen(?int $ts = null) {
}

/**
* @return mixed
* Get long poll server
*
* @return array
* @throws VKApiException
* @throws VKClientException
*/
Expand All @@ -127,7 +130,6 @@ protected function getLongPollServer() {
* @param string $host
* @param string $key
* @param int $ts
*
* @return mixed
* @throws VKLongPollServerKeyExpiredException
* @throws VKLongPollServerTsException
Expand Down Expand Up @@ -155,9 +157,7 @@ public function getEvents(string $host, string $key, int $ts) {
*
* @param array $params
* @param TransportClientResponse $response
*
* @return mixed
*
* @throws VKLongPollServerTsException
* @throws VKLongPollServerKeyExpiredException
* @throws VKClientException
Expand Down Expand Up @@ -190,7 +190,6 @@ private function parseResponse(array $params, TransportClientResponse $response)
* Decodes body.
*
* @param string $body
*
* @return mixed
*/
protected function decodeBody(string $body) {
Expand All @@ -204,8 +203,9 @@ protected function decodeBody(string $body) {
}

/**
* @param TransportClientResponse $response
* Check http status of response
*
* @param TransportClientResponse $response
* @throws VKClientException
*/
protected function checkHttpStatus(TransportClientResponse $response) {
Expand Down
1 change: 0 additions & 1 deletion src/VK/CallbackApi/Server/VKCallbackApiServerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ abstract class VKCallbackApiServerHandler extends VKCallbackApiHandler {
/**
* @param int $group_id
* @param null|string $secret
* @return mixed
*/
abstract function confirmation(int $group_id, ?string $secret);

Expand Down
57 changes: 36 additions & 21 deletions src/VK/Client/VKApiError.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace VK\Client;

class VKApiError {

protected const KEY_ERROR_CODE = 'error_code';
protected const KEY_ERROR_MSG = 'error_msg';
protected const KEY_CAPTCHA_SID = 'captcha_sid';
Expand All @@ -24,61 +25,75 @@ class VKApiError {
* @param array $error
*/
public function __construct(array $error) {
$this->error_code = isset($error[static::KEY_ERROR_CODE]) ? $error[static::KEY_ERROR_CODE] : null;
$this->error_msg = isset($error[static::KEY_ERROR_MSG]) ? $error[static::KEY_ERROR_MSG] : null;
$this->captcha_sid = isset($error[static::KEY_CAPTCHA_SID]) ? $error[static::KEY_CAPTCHA_SID] : null;
$this->captcha_img = isset($error[static::KEY_CAPTCHA_IMG]) ? $error[static::KEY_CAPTCHA_IMG] : null;
$this->confirmation_text = isset($error[static::KEY_CONFIRMATION_TEXT]) ? $error[static::KEY_CONFIRMATION_TEXT] : null;
$this->redirect_uri = isset($error[static::KEY_REDIRECT_URI]) ? $error[static::KEY_REDIRECT_URI] : null;
$this->request_params = isset($error[static::KEY_REQUEST_PARAMS]) ? $error[static::KEY_REQUEST_PARAMS] : null;
$this->error_code = isset($error[static::KEY_ERROR_CODE]) ? intval($error[static::KEY_ERROR_CODE]) : null;
$this->error_msg = isset($error[static::KEY_ERROR_MSG]) ? strval($error[static::KEY_ERROR_MSG]) : null;
$this->captcha_sid = isset($error[static::KEY_CAPTCHA_SID]) ? strval($error[static::KEY_CAPTCHA_SID]) : null;
$this->captcha_img = isset($error[static::KEY_CAPTCHA_IMG]) ? strval($error[static::KEY_CAPTCHA_IMG]) : null;
$this->confirmation_text = isset($error[static::KEY_CONFIRMATION_TEXT]) ? strval($error[static::KEY_CONFIRMATION_TEXT]) : null;
$this->redirect_uri = isset($error[static::KEY_REDIRECT_URI]) ? strval($error[static::KEY_REDIRECT_URI]) : null;
$this->request_params = isset($error[static::KEY_REQUEST_PARAMS]) ? ((array)$error[static::KEY_REQUEST_PARAMS]) : null;
}

/**
* @return mixed|null
* Error code
*
* @return int|null
*/
public function getErrorCode(): ?mixed {
public function getErrorCode(): ?int {
return $this->error_code;
}

/**
* @return mixed|null
* Error message
*
* @return string|null
*/
public function getErrorMsg(): ?mixed {
public function getErrorMsg(): ?string {
return $this->error_msg;
}

/**
* @return mixed|null
* Captcha SID
*
* @return string|null
*/
public function getCaptchaSid(): ?mixed {
public function getCaptchaSid(): ?string {
return $this->captcha_sid;
}

/**
* @return mixed|null
* Captcha image url
*
* @return string|null
*/
public function getCaptchaImg(): ?mixed {
public function getCaptchaImg(): ?string {
return $this->captcha_img;
}

/**
* @return mixed|null
* Confirmation text
*
* @return string|null
*/
public function getConfirmationText(): ?mixed {
public function getConfirmationText(): ?string {
return $this->confirmation_text;
}

/**
* @return mixed|null
* Redirect URI
*
* @return string|null
*/
public function getRedirectUri(): ?mixed {
public function getRedirectUri(): ?string {
return $this->redirect_uri;
}

/**
* @return mixed|null
* Request params
*
* @return array|null
*/
public function getRequestParams(): ?mixed {
public function getRequestParams(): ?array {
return $this->request_params;
}

Expand Down
4 changes: 2 additions & 2 deletions src/VK/OAuth/VKOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public function __construct(string $version = self::VERSION) {
* @param string $state
* @param int[] $group_ids
* @param bool $revoke
* @return mixed
* @return string
* @see VKOAuthResponseType
* @see VKOAuthDisplay
* @see VKOAuthGroupScope
* @see VKOAuthUserScope
*/
public function getAuthorizeUrl(string $response_type, int $client_id, string $redirect_uri, string $display,
?array $scope = null, ?string $state = null, ?array $group_ids = null, bool $revoke = false) {
?array $scope = null, ?string $state = null, ?array $group_ids = null, bool $revoke = false): string {
$scope_mask = 0;
foreach ($scope as $scope_setting) {
$scope_mask |= $scope_setting;
Expand Down

0 comments on commit 56d4398

Please sign in to comment.