Skip to content

Commit a9c035d

Browse files
committed
Code cleanup, PHPStorm warnings
1 parent 67fcc79 commit a9c035d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

SourceGithub/SourceGithub.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function() use ( $t_app, $t_plugin ) {
9393
*/
9494
public function route_token_revoke( $p_request, $p_response, $p_args ) {
9595
# Make sure the given repository exists
96-
$t_repo_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' );
96+
$t_repo_id = $p_args['id'] ?? $p_request->getParam('id');
9797
if( !SourceRepo::exists( $t_repo_id ) ) {
9898
return $p_response->withStatus( HTTP_STATUS_BAD_REQUEST, 'Invalid Repository Id' );
9999
}
@@ -126,7 +126,7 @@ public function route_webhook( $p_request, $p_response, $p_args ) {
126126
plugin_push_current( 'Source' );
127127

128128
# Make sure the given repository exists
129-
$t_repo_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' );
129+
$t_repo_id = $p_args['id'] ?? $p_request->getParam('id');
130130
if( !SourceRepo::exists( $t_repo_id ) ) {
131131
return $p_response->withStatus( HTTP_STATUS_BAD_REQUEST, 'Invalid Repository Id' );
132132
}
@@ -287,11 +287,7 @@ public function update_repo_form( $p_repo ) {
287287
$t_hub_webhook_secret = $p_repo->info['hub_webhook_secret'];
288288
}
289289

290-
if ( isset( $p_repo->info['master_branch'] ) ) {
291-
$t_master_branch = $p_repo->info['master_branch'];
292-
} else {
293-
$t_master_branch = $this->get_default_primary_branches();
294-
}
290+
$t_master_branch = $p_repo->info['master_branch'] ?? $this->get_default_primary_branches();
295291
?>
296292

297293
<tr>
@@ -462,6 +458,8 @@ public function update_repo( $p_repo ) {
462458
*
463459
* @param SourceRepo $p_repo Repository
464460
* @return \GuzzleHttp\Client
461+
*
462+
* @noinspection PhpReturnValueOfMethodIsNeverUsedInspection
465463
*/
466464
private function api_init( $p_repo ) {
467465
# Initialize Guzzle client if not done already
@@ -538,7 +536,8 @@ private function api_get( $p_repo, $p_path, $p_member = '' ) {
538536
}
539537
}
540538

541-
private function api_json_url( $p_repo, $p_url, $p_member = null ) {
539+
/** @noinspection PhpSameParameterValueInspection */
540+
private function api_json_url($p_repo, $p_url, $p_member = null ) {
542541
static $t_start_time;
543542
if ( $t_start_time === null ) {
544543
$t_start_time = microtime( true );
@@ -561,12 +560,11 @@ private function api_json_url( $p_repo, $p_url, $p_member = null ) {
561560

562561
public function precommit() {
563562
# Legacy GitHub Service sends the payload via eponymous form variable
564-
/** @noinspection PhpRedundantOptionalArgumentInspection */
565563
$f_payload = gpc_get_string( 'payload', null );
566564
if ( is_null( $f_payload ) ) {
567565
# If empty, retrieve the webhook's payload from the body
568566
$f_payload = file_get_contents( 'php://input' );
569-
if ( is_null( $f_payload ) ) {
567+
if ( $f_payload === false ) {
570568
return null;
571569
}
572570
}
@@ -684,10 +682,10 @@ public function import_full( $p_repo ) {
684682
$t_changeset_table = plugin_table( 'changeset', 'Source' );
685683

686684
foreach( $t_branches as $t_branch ) {
687-
/** @noinspection SqlResolve */
685+
/** @noinspection SqlResolve DuplicatedCode */
688686
$t_query = "SELECT parent FROM $t_changeset_table
689687
WHERE repo_id=" . db_param() . ' AND branch=' . db_param() .
690-
' ORDER BY timestamp ASC';
688+
' ORDER BY timestamp';
691689
$t_result = db_query( $t_query, array( $p_repo->id, $t_branch ), 1 );
692690

693691
$t_commits = array( $t_branch );
@@ -817,7 +815,6 @@ private function json_commit_changeset( $p_repo, $p_json, $p_branch='' ) {
817815
private function oauth_authorize_uri( $p_repo ) {
818816
$t_hub_app_client_id = null;
819817
$t_hub_app_secret = null;
820-
$t_hub_app_access_token = null;
821818

822819
if ( isset( $p_repo->info['hub_app_client_id'] ) ) {
823820
$t_hub_app_client_id = $p_repo->info['hub_app_client_id'];

0 commit comments

Comments
 (0)