@@ -16,7 +16,7 @@ class GitHub {
1616 */
1717 public static function get_project_milestones (
1818 $ project ,
19- $ args = array ()
19+ $ args = []
2020 ) {
2121 $ request_url = sprintf (
2222 self ::API_ROOT . 'repos/%s/milestones ' ,
@@ -42,7 +42,7 @@ public static function get_project_milestones(
4242 public static function get_release_by_tag (
4343 $ project ,
4444 $ tag ,
45- $ args = array ()
45+ $ args = []
4646 ) {
4747 $ request_url = sprintf (
4848 self ::API_ROOT . 'repos/%s/releases/tags/%s ' ,
@@ -69,7 +69,7 @@ public static function get_release_by_tag(
6969 public static function get_issues_by_label (
7070 $ project ,
7171 $ label ,
72- $ args = array ()
72+ $ args = []
7373 ) {
7474 $ request_url = sprintf (
7575 self ::API_ROOT . 'repos/%s/issues ' ,
@@ -98,7 +98,7 @@ public static function remove_label(
9898 $ project ,
9999 $ issue ,
100100 $ label ,
101- $ args = array ()
101+ $ args = []
102102 ) {
103103 $ request_url = sprintf (
104104 self ::API_ROOT . 'repos/%s/issues/%s/labels/%s ' ,
@@ -132,7 +132,7 @@ public static function add_label(
132132 $ project ,
133133 $ issue ,
134134 $ label ,
135- $ args = array ()
135+ $ args = []
136136 ) {
137137 $ request_url = sprintf (
138138 self ::API_ROOT . 'repos/%s/issues/%s/labels ' ,
@@ -143,7 +143,7 @@ public static function add_label(
143143
144144 $ headers ['http_verb ' ] = 'POST ' ;
145145
146- $ args = array ( $ label ) ;
146+ $ args = [ $ label ] ;
147147
148148 list ( $ body , $ headers ) = self ::request (
149149 $ request_url ,
@@ -166,7 +166,7 @@ public static function add_label(
166166 public static function delete_label (
167167 $ project ,
168168 $ label ,
169- $ args = array ()
169+ $ args = []
170170 ) {
171171 $ request_url = sprintf (
172172 self ::API_ROOT . 'repos/%s/labels/%s ' ,
@@ -198,21 +198,21 @@ public static function get_project_milestone_pull_requests(
198198 $ project
199199 );
200200
201- $ args = array (
201+ $ args = [
202202 'per_page ' => 100 ,
203203 'milestone ' => $ milestone_id ,
204204 'state ' => 'all ' ,
205- ) ;
205+ ] ;
206206
207- $ pull_requests = array () ;
207+ $ pull_requests = [] ;
208208 do {
209209 list ( $ body , $ headers ) = self ::request ( $ request_url , $ args );
210210 foreach ( $ body as $ issue ) {
211211 if ( ! empty ( $ issue ->pull_request ) ) {
212212 $ pull_requests [] = $ issue ;
213213 }
214214 }
215- $ args = array () ;
215+ $ args = [] ;
216216 $ request_url = false ;
217217 // Set $request_url to 'rel="next" if present'
218218 if ( ! empty ( $ headers ['Link ' ] ) ) {
@@ -240,7 +240,7 @@ public static function get_project_milestone_pull_requests(
240240 public static function parse_contributors_from_pull_requests (
241241 $ pull_requests
242242 ) {
243- $ contributors = array () ;
243+ $ contributors = [] ;
244244 foreach ( $ pull_requests as $ pull_request ) {
245245 if ( ! empty ( $ pull_request ->user ) ) {
246246 $ contributors [ $ pull_request ->user ->html_url ] = $ pull_request ->user ->login ;
@@ -261,17 +261,19 @@ public static function parse_contributors_from_pull_requests(
261261 */
262262 public static function request (
263263 $ url ,
264- $ args = array () ,
265- $ headers = array ()
264+ $ args = [] ,
265+ $ headers = []
266266 ) {
267267 $ headers = array_merge (
268268 $ headers ,
269- array (
269+ [
270270 'Accept ' => 'application/vnd.github.v3+json ' ,
271271 'User-Agent ' => 'WP-CLI ' ,
272- )
272+ ]
273273 );
274- if ( $ token = getenv ( 'GITHUB_TOKEN ' ) ) {
274+
275+ $ token = getenv ( 'GITHUB_TOKEN ' );
276+ if ( $ token ) {
275277 $ headers ['Authorization ' ] = 'token ' . $ token ;
276278 }
277279
@@ -287,7 +289,7 @@ public static function request(
287289
288290 $ response = Utils \http_request ( $ verb , $ url , $ args , $ headers );
289291
290- if ( 20 != substr ( $ response ->status_code , 0 , 2 ) ) {
292+ if ( 20 !== absint ( substr ( $ response ->status_code , 0 , 2 ) ) ) {
291293 if ( isset ( $ args ['throw_errors ' ] ) && false === $ args ['throw_errors ' ] ) {
292294 return false ;
293295 }
@@ -301,6 +303,6 @@ public static function request(
301303 );
302304 }
303305
304- return array ( json_decode ( $ response ->body ), $ response ->headers ) ;
306+ return [ json_decode ( $ response ->body ), $ response ->headers ] ;
305307 }
306308}
0 commit comments