From 7cae851ec999ac7ab8fac4c6d553bd459cc3444d Mon Sep 17 00:00:00 2001 From: Nyholm Date: Thu, 13 May 2021 11:31:11 +0200 Subject: [PATCH 1/2] Added params argument for Labels and Search --- lib/Github/Api/Issue/Labels.php | 5 +++-- lib/Github/Api/Search.php | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/Github/Api/Issue/Labels.php b/lib/Github/Api/Issue/Labels.php index d719578d943..72ca5bb786d 100644 --- a/lib/Github/Api/Issue/Labels.php +++ b/lib/Github/Api/Issue/Labels.php @@ -21,10 +21,11 @@ class Labels extends AbstractApi * @param string $username * @param string $repository * @param int|null $issue + * @param array $params * * @return array */ - public function all($username, $repository, $issue = null) + public function all($username, $repository, $issue = null, array $params = []) { if ($issue === null) { $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels'; @@ -32,7 +33,7 @@ public function all($username, $repository, $issue = null) $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels'; } - return $this->get($path); + return $this->get($path, $params); } /** diff --git a/lib/Github/Api/Search.php b/lib/Github/Api/Search.php index 24bd59bbf83..5a2aef65269 100644 --- a/lib/Github/Api/Search.php +++ b/lib/Github/Api/Search.php @@ -21,12 +21,13 @@ class Search extends AbstractApi * @param string $q the filter * @param string $sort the sort field * @param string $order asc/desc + * @param array $params * * @return array list of repositories found */ - public function repositories($q, $sort = 'updated', $order = 'desc') + public function repositories($q, $sort = 'updated', $order = 'desc', array $params = []) { - return $this->get('/search/repositories', ['q' => $q, 'sort' => $sort, 'order' => $order]); + return $this->get('/search/repositories', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params)); } /** @@ -37,12 +38,13 @@ public function repositories($q, $sort = 'updated', $order = 'desc') * @param string $q the filter * @param string $sort the sort field * @param string $order asc/desc + * @param array $params * * @return array list of issues found */ - public function issues($q, $sort = 'updated', $order = 'desc') + public function issues($q, $sort = 'updated', $order = 'desc', array $params = []) { - return $this->get('/search/issues', ['q' => $q, 'sort' => $sort, 'order' => $order]); + return $this->get('/search/issues', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params)); } /** @@ -53,12 +55,13 @@ public function issues($q, $sort = 'updated', $order = 'desc') * @param string $q the filter * @param string $sort the sort field * @param string $order asc/desc + * @param array $params * * @return array list of code found */ - public function code($q, $sort = 'updated', $order = 'desc') + public function code($q, $sort = 'updated', $order = 'desc', array $params = []) { - return $this->get('/search/code', ['q' => $q, 'sort' => $sort, 'order' => $order]); + return $this->get('/search/code', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params)); } /** @@ -69,12 +72,13 @@ public function code($q, $sort = 'updated', $order = 'desc') * @param string $q the filter * @param string $sort the sort field * @param string $order asc/desc + * @param array $params * * @return array list of users found */ - public function users($q, $sort = 'updated', $order = 'desc') + public function users($q, $sort = 'updated', $order = 'desc', array $params = []) { - return $this->get('/search/users', ['q' => $q, 'sort' => $sort, 'order' => $order]); + return $this->get('/search/users', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params)); } /** @@ -85,15 +89,16 @@ public function users($q, $sort = 'updated', $order = 'desc') * @param string $q the filter * @param string $sort the sort field * @param string $order sort order. asc/desc + * @param array $params * * @return array */ - public function commits($q, $sort = null, $order = 'desc') + public function commits($q, $sort = null, $order = 'desc', array $params = []) { // This api is in preview mode, so set the correct accept-header $this->acceptHeaderValue = 'application/vnd.github.cloak-preview'; - return $this->get('/search/commits', ['q' => $q, 'sort' => $sort, 'order' => $order]); + return $this->get('/search/commits', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params)); } /** @@ -102,14 +107,15 @@ public function commits($q, $sort = null, $order = 'desc') * @link https://developer.github.com/v3/search/#search-topics * * @param string $q the filter + * @param array $params * * @return array */ - public function topics($q) + public function topics($q, array $params = []) { // This api is in preview mode, so set the correct accept-header $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - return $this->get('/search/topics', ['q' => $q]); + return $this->get('/search/topics', array_merge(['q' => $q], $params)); } } From 753338b49494053b562e17a293db8a2b7e5fae63 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 16 May 2021 16:47:31 +0200 Subject: [PATCH 2/2] cs --- lib/Github/Api/Issue/Labels.php | 2 +- lib/Github/Api/Search.php | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/Github/Api/Issue/Labels.php b/lib/Github/Api/Issue/Labels.php index 72ca5bb786d..88fc7ab6687 100644 --- a/lib/Github/Api/Issue/Labels.php +++ b/lib/Github/Api/Issue/Labels.php @@ -21,7 +21,7 @@ class Labels extends AbstractApi * @param string $username * @param string $repository * @param int|null $issue - * @param array $params + * @param array $params * * @return array */ diff --git a/lib/Github/Api/Search.php b/lib/Github/Api/Search.php index 5a2aef65269..42825b55f9c 100644 --- a/lib/Github/Api/Search.php +++ b/lib/Github/Api/Search.php @@ -18,9 +18,9 @@ class Search extends AbstractApi * * @link https://developer.github.com/v3/search/#search-repositories * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc + * @param string $q the filter + * @param string $sort the sort field + * @param string $order asc/desc * @param array $params * * @return array list of repositories found @@ -35,9 +35,9 @@ public function repositories($q, $sort = 'updated', $order = 'desc', array $para * * @link https://developer.github.com/v3/search/#search-issues * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc + * @param string $q the filter + * @param string $sort the sort field + * @param string $order asc/desc * @param array $params * * @return array list of issues found @@ -52,9 +52,9 @@ public function issues($q, $sort = 'updated', $order = 'desc', array $params = [ * * @link https://developer.github.com/v3/search/#search-code * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc + * @param string $q the filter + * @param string $sort the sort field + * @param string $order asc/desc * @param array $params * * @return array list of code found @@ -69,9 +69,9 @@ public function code($q, $sort = 'updated', $order = 'desc', array $params = []) * * @link https://developer.github.com/v3/search/#search-users * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc + * @param string $q the filter + * @param string $sort the sort field + * @param string $order asc/desc * @param array $params * * @return array list of users found @@ -86,9 +86,9 @@ public function users($q, $sort = 'updated', $order = 'desc', array $params = [] * * @link https://developer.github.com/v3/search/#search-commits * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order sort order. asc/desc + * @param string $q the filter + * @param string $sort the sort field + * @param string $order sort order. asc/desc * @param array $params * * @return array @@ -106,7 +106,7 @@ public function commits($q, $sort = null, $order = 'desc', array $params = []) * * @link https://developer.github.com/v3/search/#search-topics * - * @param string $q the filter + * @param string $q the filter * @param array $params * * @return array