Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Jira/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Jira/Api/Client/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion src/Jira/Api/Client/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -75,6 +76,10 @@ public function sendRequest(

if ( $method == 'GET' ) {
$url .= '?' . http_build_query($data);

if ( !is_array($data) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be moved up. Otherwise you already get notice about wrong parameter usage in http_build_query call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And same part in PHPClient is still missing.

throw new \InvalidArgumentException('Data must be an array.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention in DocBlock via @throws tag, that this exception is being thrown.

}
}

curl_setopt($curl, CURLOPT_URL, $endpoint . $url);
Expand Down
2 changes: 1 addition & 1 deletion src/Jira/Api/Client/PHPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down