From 1de34789936438c9c9e0dd3a0beeb6d6c9f277a2 Mon Sep 17 00:00:00 2001 From: Florian Sachs Date: Wed, 8 Jun 2016 14:43:59 +0200 Subject: [PATCH 1/5] fix warning setWatchers Method use String as Data PHP Catchable fatal error: Argument 3 passed to chobie\Jira\Api::api() must be an array, string given --- src/Jira/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Jira/Api.php b/src/Jira/Api.php index ee592d3..7c60b2f 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -691,7 +691,7 @@ public function createRemotelink( public function api( $method = self::REQUEST_GET, $url, - array $data = array(), + $data = array(), $return_as_json = false, $is_file = false, $debug = false From 9efd2cb528ec3cea5cbc2ddf14db6fe52d9df8d1 Mon Sep 17 00:00:00 2001 From: Florian Sachs Date: Wed, 8 Jun 2016 15:15:22 +0200 Subject: [PATCH 2/5] edit DocBlocks throw InvalidArgumentException --- src/Jira/Api.php | 2 +- src/Jira/Api/Client/CurlClient.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 7c60b2f..7bbf0c2 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -681,7 +681,7 @@ public function createRemotelink( * * @param string $method Request method. * @param string $url URL. - * @param array $data Data. + * @param array|string $data Data. * @param boolean $return_as_json Return results as JSON. * @param boolean $is_file Is file-related request. * @param boolean $debug Debug this request. diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index df57e68..78782ab 100644 --- a/src/Jira/Api/Client/CurlClient.php +++ b/src/Jira/Api/Client/CurlClient.php @@ -46,7 +46,7 @@ public function __construct() * * @param string $method Request method. * @param string $url URL. - * @param array $data Request data. + * @param array|string $data Request data. * @param string $endpoint Endpoint. * @param AuthenticationInterface $credential Credential. * @param boolean $is_file This is a file upload request. @@ -75,6 +75,10 @@ public function sendRequest( if ( $method == 'GET' ) { $url .= '?' . http_build_query($data); + + if ( !is_array($data) ) { + throw new \InvalidArgumentException('Data must be an array.'); + } } curl_setopt($curl, CURLOPT_URL, $endpoint . $url); From 4acb7c344c554c95a49c019ff73bb805039bd593 Mon Sep 17 00:00:00 2001 From: Florian Sachs Date: Wed, 8 Jun 2016 15:17:16 +0200 Subject: [PATCH 3/5] missing ClientInterface --- src/Jira/Api/Client/ClientInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Jira/Api/Client/ClientInterface.php b/src/Jira/Api/Client/ClientInterface.php index f69ff5a..88391be 100644 --- a/src/Jira/Api/Client/ClientInterface.php +++ b/src/Jira/Api/Client/ClientInterface.php @@ -35,7 +35,7 @@ interface ClientInterface * * @param string $method Request method. * @param string $url URL. - * @param array $data Request data. + * @param array|string $data Request data. * @param string $endpoint Endpoint. * @param AuthenticationInterface $credential Credential. * @param boolean $is_file This is a file upload request. From 651d469e8d6950878af14441d82ecdab2d1e0695 Mon Sep 17 00:00:00 2001 From: Florian Sachs Date: Wed, 8 Jun 2016 15:23:02 +0200 Subject: [PATCH 4/5] missed PHPClient --- src/Jira/Api/Client/CurlClient.php | 1 + src/Jira/Api/Client/PHPClient.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index 78782ab..4254297 100644 --- a/src/Jira/Api/Client/CurlClient.php +++ b/src/Jira/Api/Client/CurlClient.php @@ -57,6 +57,7 @@ public function __construct() * @throws Exception When request failed due CURL error. * @throws UnauthorizedException When request failed, because user can't be authorized properly. * @throws Exception When there was empty response instead of needed data. + * @throws \InvalidArgumentException When data is not an array and http method is GET. */ public function sendRequest( $method, diff --git a/src/Jira/Api/Client/PHPClient.php b/src/Jira/Api/Client/PHPClient.php index 8025b09..38b976e 100644 --- a/src/Jira/Api/Client/PHPClient.php +++ b/src/Jira/Api/Client/PHPClient.php @@ -68,7 +68,7 @@ protected function isHttpsSupported() * * @param string $method Request method. * @param string $url URL. - * @param array $data Request data. + * @param array|string $data Request data. * @param string $endpoint Endpoint. * @param AuthenticationInterface $credential Credential. * @param boolean $is_file This is a file upload request. From 9bd2b0507a887ad610563b2fb7caf544a6d52af2 Mon Sep 17 00:00:00 2001 From: Florian Sachs Date: Wed, 8 Jun 2016 15:26:28 +0200 Subject: [PATCH 5/5] reformat --- src/Jira/Api.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 7bbf0c2..cc7dd40 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -679,12 +679,12 @@ public function createRemotelink( /** * Send request to specified host. * - * @param string $method Request method. - * @param string $url URL. - * @param array|string $data Data. - * @param boolean $return_as_json Return results as JSON. - * @param boolean $is_file Is file-related request. - * @param boolean $debug Debug this request. + * @param string $method Request method. + * @param string $url URL. + * @param array|string $data Data. + * @param boolean $return_as_json Return results as JSON. + * @param boolean $is_file Is file-related request. + * @param boolean $debug Debug this request. * * @return array|Result|false */