diff --git a/src/Jira/Api.php b/src/Jira/Api.php index ee592d3..cc7dd40 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -679,19 +679,19 @@ public function createRemotelink( /** * Send request to specified host. * - * @param string $method Request method. - * @param string $url URL. - * @param array $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 */ public function api( $method = self::REQUEST_GET, $url, - array $data = array(), + $data = array(), $return_as_json = false, $is_file = false, $debug = false 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. diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index df57e68..4254297 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. @@ -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, @@ -75,6 +76,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); 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.