Skip to content

Extend styleci config to check more code style rules #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2018
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
7 changes: 4 additions & 3 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
preset: psr2
preset: recommended

enabled:
- return
disabled:
- align_double_arrow
- no_multiline_whitespace_before_semicolons
14 changes: 7 additions & 7 deletions lib/Github/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function setPerPage($perPage)
*
* @return array|string
*/
protected function get($path, array $parameters = array(), array $requestHeaders = array())
protected function get($path, array $parameters = [], array $requestHeaders = [])
{
if (null !== $this->page && !isset($parameters['page'])) {
$parameters['page'] = $this->page;
Expand Down Expand Up @@ -120,7 +120,7 @@ protected function get($path, array $parameters = array(), array $requestHeaders
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function head($path, array $parameters = array(), array $requestHeaders = array())
protected function head($path, array $parameters = [], array $requestHeaders = [])
{
if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) {
unset($parameters['ref']);
Expand All @@ -140,7 +140,7 @@ protected function head($path, array $parameters = array(), array $requestHeader
*
* @return array|string
*/
protected function post($path, array $parameters = array(), array $requestHeaders = array())
protected function post($path, array $parameters = [], array $requestHeaders = [])
{
return $this->postRaw(
$path,
Expand All @@ -158,7 +158,7 @@ protected function post($path, array $parameters = array(), array $requestHeader
*
* @return array|string
*/
protected function postRaw($path, $body, array $requestHeaders = array())
protected function postRaw($path, $body, array $requestHeaders = [])
{
$response = $this->client->getHttpClient()->post(
$path,
Expand All @@ -178,7 +178,7 @@ protected function postRaw($path, $body, array $requestHeaders = array())
*
* @return array|string
*/
protected function patch($path, array $parameters = array(), array $requestHeaders = array())
protected function patch($path, array $parameters = [], array $requestHeaders = [])
{
$response = $this->client->getHttpClient()->patch(
$path,
Expand All @@ -198,7 +198,7 @@ protected function patch($path, array $parameters = array(), array $requestHeade
*
* @return array|string
*/
protected function put($path, array $parameters = array(), array $requestHeaders = array())
protected function put($path, array $parameters = [], array $requestHeaders = [])
{
$response = $this->client->getHttpClient()->put(
$path,
Expand All @@ -218,7 +218,7 @@ protected function put($path, array $parameters = array(), array $requestHeaders
*
* @return array|string
*/
protected function delete($path, array $parameters = array(), array $requestHeaders = array())
protected function delete($path, array $parameters = [], array $requestHeaders = [])
{
$response = $this->client->getHttpClient()->delete(
$path,
Expand Down
23 changes: 12 additions & 11 deletions lib/Github/Api/AcceptHeaderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,51 @@ trait AcceptHeaderTrait
{
protected $acceptHeaderValue = null;

protected function get($path, array $parameters = array(), array $requestHeaders = array())
protected function get($path, array $parameters = [], array $requestHeaders = [])
{
return parent::get($path, $parameters, $this->mergeHeaders($requestHeaders));
}

protected function head($path, array $parameters = array(), array $requestHeaders = array())
protected function head($path, array $parameters = [], array $requestHeaders = [])
{
return parent::head($path, $parameters, $this->mergeHeaders($requestHeaders));
}

protected function post($path, array $parameters = array(), array $requestHeaders = array())
protected function post($path, array $parameters = [], array $requestHeaders = [])
{
return parent::post($path, $parameters, $this->mergeHeaders($requestHeaders));
}

protected function postRaw($path, $body, array $requestHeaders = array())
protected function postRaw($path, $body, array $requestHeaders = [])
{
return parent::postRaw($path, $body, $this->mergeHeaders($requestHeaders));
}

protected function patch($path, array $parameters = array(), array $requestHeaders = array())
protected function patch($path, array $parameters = [], array $requestHeaders = [])
{
return parent::patch($path, $parameters, $this->mergeHeaders($requestHeaders));
}

protected function put($path, array $parameters = array(), array $requestHeaders = array())
protected function put($path, array $parameters = [], array $requestHeaders = [])
{
return parent::put($path, $parameters, $this->mergeHeaders($requestHeaders));
}

protected function delete($path, array $parameters = array(), array $requestHeaders = array())
protected function delete($path, array $parameters = [], array $requestHeaders = [])
{
return parent::delete($path, $parameters, $this->mergeHeaders($requestHeaders));
}

/**
* Append a new accept header on all requests
* Append a new accept header on all requests.
*
* @return array
*/
private function mergeHeaders(array $headers = array())
private function mergeHeaders(array $headers = [])
{
$default = array();
$default = [];
if ($this->acceptHeaderValue) {
$default = array('Accept' => $this->acceptHeaderValue);
$default = ['Accept' => $this->acceptHeaderValue];
}

return array_merge($default, $headers);
Expand Down
7 changes: 4 additions & 3 deletions lib/Github/Api/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

/**
* @link https://developer.github.com/v3/apps/
*
* @author Nils Adermann <[email protected]>
*/
class Apps extends AbstractApi
{
/**
* Create an access token for an installation
* Create an access token for an installation.
*
* @param int $installationId An integration installation id
* @param int $userId An optional user id on behalf of whom the
Expand All @@ -19,7 +20,7 @@ class Apps extends AbstractApi
*/
public function createInstallationToken($installationId, $userId = null)
{
$parameters = array();
$parameters = [];
if ($userId) {
$parameters['user_id'] = $userId;
}
Expand Down Expand Up @@ -50,7 +51,7 @@ public function findInstallations()
*/
public function listRepositories($userId = null)
{
$parameters = array();
$parameters = [];
if ($userId) {
$parameters['user_id'] = $userId;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Github/Api/Authorizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Creating, deleting and listing authorizations.
*
* @link http://developer.github.com/v3/oauth_authorizations/
*
* @author Evgeniy Guseletov <[email protected]>
*/
class Authorizations extends AbstractApi
Expand Down Expand Up @@ -36,13 +37,13 @@ public function show($clientId)
* Create an authorization.
*
* @param array $params
* @param null $OTPCode
* @param null $OTPCode
*
* @return array
*/
public function create(array $params, $OTPCode = null)
{
$headers = null === $OTPCode ? array() : array('X-GitHub-OTP' => $OTPCode);
$headers = null === $OTPCode ? [] : ['X-GitHub-OTP' => $OTPCode];

return $this->post('/authorizations', $params, $headers);
}
Expand Down
45 changes: 23 additions & 22 deletions lib/Github/Api/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

namespace Github\Api;

use Github\Api\CurrentUser\PublicKeys;
use Github\Api\CurrentUser\Emails;
use Github\Api\CurrentUser\Followers;
use Github\Api\CurrentUser\Memberships;
use Github\Api\CurrentUser\Notifications;
use Github\Api\CurrentUser\Watchers;
use Github\Api\CurrentUser\PublicKeys;
use Github\Api\CurrentUser\Starring;
use Github\Api\CurrentUser\Watchers;

/**
* @link http://developer.github.com/v3/users/
*
* @author Joseph Bielawski <[email protected]>
* @author Felipe Valtl de Mello <[email protected]>
*/
Expand Down Expand Up @@ -45,9 +46,9 @@ public function follow()

public function followers($page = 1)
{
return $this->get('/user/followers', array(
'page' => $page
));
return $this->get('/user/followers', [
'page' => $page,
]);
}

/**
Expand All @@ -58,9 +59,9 @@ public function followers($page = 1)
*
* @return array
*/
public function issues(array $params = array(), $includeOrgIssues = true)
public function issues(array $params = [], $includeOrgIssues = true)
{
return $this->get($includeOrgIssues ? '/issues' : '/user/issues', array_merge(array('page' => 1), $params));
return $this->get($includeOrgIssues ? '/issues' : '/user/issues', array_merge(['page' => 1], $params));
}

/**
Expand Down Expand Up @@ -118,11 +119,11 @@ public function teams()
*/
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc')
{
return $this->get('/user/repos', array(
return $this->get('/user/repos', [
'type' => $type,
'sort' => $sort,
'direction' => $direction
));
'direction' => $direction,
]);
}

/**
Expand All @@ -138,9 +139,9 @@ public function watchers()
*/
public function watched($page = 1)
{
return $this->get('/user/watched', array(
'page' => $page
));
return $this->get('/user/watched', [
'page' => $page,
]);
}

/**
Expand All @@ -156,9 +157,9 @@ public function starring()
*/
public function starred($page = 1)
{
return $this->get('/user/starred', array(
'page' => $page
));
return $this->get('/user/starred', [
'page' => $page,
]);
}

/**
Expand All @@ -174,19 +175,19 @@ public function subscriptions()
*
* @param array $params
*/
public function installations(array $params = array())
public function installations(array $params = [])
{
return $this->get('/user/installations', array_merge(array('page' => 1), $params));
return $this->get('/user/installations', array_merge(['page' => 1], $params));
}

/**
* @link https://developer.github.com/v3/integrations/installations/#list-repositories-accessible-to-the-user-for-an-installation
*
* @param string $installationId the ID of the Installation
* @param array $params
* @param string $installationId the ID of the Installation
* @param array $params
*/
public function repositoriesByInstallation($installationId, array $params = array())
public function repositoriesByInstallation($installationId, array $params = [])
{
return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(array('page' => 1), $params));
return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(['page' => 1], $params));
}
}
7 changes: 4 additions & 3 deletions lib/Github/Api/CurrentUser/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* @link http://developer.github.com/v3/users/emails/
*
* @author Joseph Bielawski <[email protected]>
*/
class Emails extends AbstractApi
Expand Down Expand Up @@ -49,7 +50,7 @@ public function allPublic()
public function add($emails)
{
if (is_string($emails)) {
$emails = array($emails);
$emails = [$emails];
} elseif (0 === count($emails)) {
throw new InvalidArgumentException();
}
Expand All @@ -71,7 +72,7 @@ public function add($emails)
public function remove($emails)
{
if (is_string($emails)) {
$emails = array($emails);
$emails = [$emails];
} elseif (0 === count($emails)) {
throw new InvalidArgumentException();
}
Expand All @@ -80,7 +81,7 @@ public function remove($emails)
}

/**
* Toggle primary email visibility
* Toggle primary email visibility.
*
* @link https://developer.github.com/v3/users/emails/#toggle-primary-email-visibility
*
Expand Down
7 changes: 4 additions & 3 deletions lib/Github/Api/CurrentUser/Followers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* @link http://developer.github.com/v3/users/followers/
*
* @author Joseph Bielawski <[email protected]>
*/
class Followers extends AbstractApi
Expand All @@ -21,9 +22,9 @@ class Followers extends AbstractApi
*/
public function all($page = 1)
{
return $this->get('/user/following', array(
'page' => $page
));
return $this->get('/user/following', [
'page' => $page,
]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Github/Api/CurrentUser/Memberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function organization($organization)
}

/**
* Edit your organization membership
* Edit your organization membership.
*
* @link https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
*
Expand All @@ -43,6 +43,6 @@ public function organization($organization)
*/
public function edit($organization)
{
return $this->patch('/user/memberships/orgs/'.rawurlencode($organization), array('state' => 'active'));
return $this->patch('/user/memberships/orgs/'.rawurlencode($organization), ['state' => 'active']);
}
}
Loading