diff --git a/.styleci.yml b/.styleci.yml index 731de4d858d..504456e7afa 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,4 +1,5 @@ -preset: psr2 +preset: recommended -enabled: - - return +disabled: + - align_double_arrow + - no_multiline_whitespace_before_semicolons diff --git a/lib/Github/Api/AbstractApi.php b/lib/Github/Api/AbstractApi.php index 19f8ce4d653..135ac2b22be 100644 --- a/lib/Github/Api/AbstractApi.php +++ b/lib/Github/Api/AbstractApi.php @@ -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; @@ -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']); @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/lib/Github/Api/AcceptHeaderTrait.php b/lib/Github/Api/AcceptHeaderTrait.php index 387a6e68be8..4a7e7a4668d 100644 --- a/lib/Github/Api/AcceptHeaderTrait.php +++ b/lib/Github/Api/AcceptHeaderTrait.php @@ -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); diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index dc11ff0b3cf..8ef0833875e 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -4,12 +4,13 @@ /** * @link https://developer.github.com/v3/apps/ + * * @author Nils Adermann */ 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 @@ -19,7 +20,7 @@ class Apps extends AbstractApi */ public function createInstallationToken($installationId, $userId = null) { - $parameters = array(); + $parameters = []; if ($userId) { $parameters['user_id'] = $userId; } @@ -50,7 +51,7 @@ public function findInstallations() */ public function listRepositories($userId = null) { - $parameters = array(); + $parameters = []; if ($userId) { $parameters['user_id'] = $userId; } diff --git a/lib/Github/Api/Authorizations.php b/lib/Github/Api/Authorizations.php index 5e6853fd773..fd8e9b23f50 100644 --- a/lib/Github/Api/Authorizations.php +++ b/lib/Github/Api/Authorizations.php @@ -6,6 +6,7 @@ * Creating, deleting and listing authorizations. * * @link http://developer.github.com/v3/oauth_authorizations/ + * * @author Evgeniy Guseletov */ class Authorizations extends AbstractApi @@ -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); } diff --git a/lib/Github/Api/CurrentUser.php b/lib/Github/Api/CurrentUser.php index 53dfb0dc226..8718673746c 100644 --- a/lib/Github/Api/CurrentUser.php +++ b/lib/Github/Api/CurrentUser.php @@ -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 * @author Felipe Valtl de Mello */ @@ -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, + ]); } /** @@ -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)); } /** @@ -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, + ]); } /** @@ -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, + ]); } /** @@ -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, + ]); } /** @@ -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)); } } diff --git a/lib/Github/Api/CurrentUser/Emails.php b/lib/Github/Api/CurrentUser/Emails.php index 98dae634efb..15d4fad023e 100644 --- a/lib/Github/Api/CurrentUser/Emails.php +++ b/lib/Github/Api/CurrentUser/Emails.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/users/emails/ + * * @author Joseph Bielawski */ class Emails extends AbstractApi @@ -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(); } @@ -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(); } @@ -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 * diff --git a/lib/Github/Api/CurrentUser/Followers.php b/lib/Github/Api/CurrentUser/Followers.php index 19a8e2d37c8..52a712ca99e 100644 --- a/lib/Github/Api/CurrentUser/Followers.php +++ b/lib/Github/Api/CurrentUser/Followers.php @@ -6,6 +6,7 @@ /** * @link http://developer.github.com/v3/users/followers/ + * * @author Joseph Bielawski */ class Followers extends AbstractApi @@ -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, + ]); } /** diff --git a/lib/Github/Api/CurrentUser/Memberships.php b/lib/Github/Api/CurrentUser/Memberships.php index df87596c38a..da727397407 100644 --- a/lib/Github/Api/CurrentUser/Memberships.php +++ b/lib/Github/Api/CurrentUser/Memberships.php @@ -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 * @@ -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']); } } diff --git a/lib/Github/Api/CurrentUser/Notifications.php b/lib/Github/Api/CurrentUser/Notifications.php index 0e9f4c2d278..36dfb57ef8f 100644 --- a/lib/Github/Api/CurrentUser/Notifications.php +++ b/lib/Github/Api/CurrentUser/Notifications.php @@ -6,6 +6,7 @@ /** * @link http://developer.github.com/v3/activity/notifications/ + * * @author Joseph Bielawski */ class Notifications extends AbstractApi @@ -19,7 +20,7 @@ class Notifications extends AbstractApi * * @return array */ - public function all(array $params = array()) + public function all(array $params = []) { return $this->get('/notifications', $params); } @@ -35,7 +36,7 @@ public function all(array $params = array()) * * @return array */ - public function allInRepository($username, $repository, array $params = array()) + public function allInRepository($username, $repository, array $params = []) { return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/notifications', $params); } @@ -49,7 +50,7 @@ public function allInRepository($username, $repository, array $params = array()) * * @return array */ - public function markAsReadAll(array $params = array()) + public function markAsReadAll(array $params = []) { return $this->put('/notifications', $params); } @@ -65,7 +66,7 @@ public function markAsReadAll(array $params = array()) * * @return array */ - public function markAsReadInRepository($username, $repository, array $params = array()) + public function markAsReadInRepository($username, $repository, array $params = []) { return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/notifications', $params); } diff --git a/lib/Github/Api/CurrentUser/PublicKeys.php b/lib/Github/Api/CurrentUser/PublicKeys.php index a09a08305ac..706e14051ba 100644 --- a/lib/Github/Api/CurrentUser/PublicKeys.php +++ b/lib/Github/Api/CurrentUser/PublicKeys.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/users/keys/ + * * @author Joseph Bielawski */ class PublicKeys extends AbstractApi @@ -51,7 +52,7 @@ public function show($id) public function create(array $params) { if (!isset($params['title'], $params['key'])) { - throw new MissingArgumentException(array('title', 'key')); + throw new MissingArgumentException(['title', 'key']); } return $this->post('/user/keys', $params); diff --git a/lib/Github/Api/CurrentUser/Starring.php b/lib/Github/Api/CurrentUser/Starring.php index 39de729fe99..d823c0bf0f1 100644 --- a/lib/Github/Api/CurrentUser/Starring.php +++ b/lib/Github/Api/CurrentUser/Starring.php @@ -23,10 +23,10 @@ class Starring extends AbstractApi */ public function all($page = 1, $perPage = 30) { - return $this->get('/user/starred', array( + return $this->get('/user/starred', [ 'page' => $page, 'per_page' => $perPage, - )); + ]); } /** diff --git a/lib/Github/Api/CurrentUser/Watchers.php b/lib/Github/Api/CurrentUser/Watchers.php index a5a6d9b46f0..1ef35972c3f 100644 --- a/lib/Github/Api/CurrentUser/Watchers.php +++ b/lib/Github/Api/CurrentUser/Watchers.php @@ -6,6 +6,7 @@ /** * @link https://developer.github.com/v3/activity/watching/ + * * @author Joseph Bielawski * @revised Felipe Valtl de Mello */ @@ -22,9 +23,9 @@ class Watchers extends AbstractApi */ public function all($page = 1) { - return $this->get('/user/subscriptions', array( - 'page' => $page - )); + return $this->get('/user/subscriptions', [ + 'page' => $page, + ]); } /** diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php index e7d4c95b5e2..a6e9bacd755 100644 --- a/lib/Github/Api/Deployment.php +++ b/lib/Github/Api/Deployment.php @@ -12,15 +12,17 @@ class Deployment extends AbstractApi { /** - * List deployments for a particular repository + * List deployments for a particular repository. + * * @link https://developer.github.com/v3/repos/deployments/#list-deployments * - * @param string $username the username of the user who owns the repository - * @param string $repository the name of the repository - * @param array $params query parameters to filter deployments by (see link) - * @return array the deployments requested + * @param string $username the username of the user who owns the repository + * @param string $repository the name of the repository + * @param array $params query parameters to filter deployments by (see link) + * + * @return array the deployments requested */ - public function all($username, $repository, array $params = array()) + public function all($username, $repository, array $params = []) { return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params); } @@ -41,22 +43,24 @@ public function show($username, $repository, $id) /** * Create a new deployment for the given username and repo. + * * @link https://developer.github.com/v3/repos/deployments/#create-a-deployment * * Important: Once a deployment is created, it cannot be updated. Changes are indicated by creating new statuses. * @see updateStatus * - * @param string $username the username - * @param string $repository the repository - * @param array $params the new deployment data - * @return array information about the deployment + * @param string $username the username + * @param string $repository the repository + * @param array $params the new deployment data * * @throws MissingArgumentException + * + * @return array information about the deployment */ public function create($username, $repository, array $params) { if (!isset($params['ref'])) { - throw new MissingArgumentException(array('ref')); + throw new MissingArgumentException(['ref']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params); @@ -64,22 +68,24 @@ public function create($username, $repository, array $params) /** * Updates a deployment by creating a new status update. + * * @link https://developer.github.com/v3/repos/deployments/#create-a-deployment-status * - * @param string $username the username + * @param string $username the username * @param string $repository the repository - * @param int $id the deployment number - * @param array $params The information about the deployment update. - * Must include a "state" field of pending, success, error, or failure. - * May also be given a target_url and description, ßee link for more details. - * @return array information about the deployment + * @param int $id the deployment number + * @param array $params The information about the deployment update. + * Must include a "state" field of pending, success, error, or failure. + * May also be given a target_url and description, ßee link for more details. * * @throws MissingArgumentException + * + * @return array information about the deployment */ public function updateStatus($username, $repository, $id, array $params) { if (!isset($params['state'])) { - throw new MissingArgumentException(array('state')); + throw new MissingArgumentException(['state']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id).'/statuses', $params); @@ -88,9 +94,10 @@ public function updateStatus($username, $repository, $id, array $params) /** * Gets all of the status updates tied to a given deployment. * - * @param string $username the username - * @param string $repository the repository - * @param int $id the deployment identifier + * @param string $username the username + * @param string $repository the repository + * @param int $id the deployment identifier + * * @return array the deployment statuses */ public function getStatuses($username, $repository, $id) diff --git a/lib/Github/Api/Enterprise.php b/lib/Github/Api/Enterprise.php index c23171a6614..3dbbee3ea2b 100644 --- a/lib/Github/Api/Enterprise.php +++ b/lib/Github/Api/Enterprise.php @@ -2,15 +2,16 @@ namespace Github\Api; +use Github\Api\Enterprise\License; use Github\Api\Enterprise\ManagementConsole; use Github\Api\Enterprise\Stats; -use Github\Api\Enterprise\License; use Github\Api\Enterprise\UserAdmin; /** * Getting information about a GitHub Enterprise instance. * * @link https://developer.github.com/v3/enterprise/ + * * @author Joseph Bielawski * @author Guillermo A. Fisher */ diff --git a/lib/Github/Api/Enterprise/ManagementConsole.php b/lib/Github/Api/Enterprise/ManagementConsole.php index bc25e53466f..f11c47643eb 100644 --- a/lib/Github/Api/Enterprise/ManagementConsole.php +++ b/lib/Github/Api/Enterprise/ManagementConsole.php @@ -72,6 +72,6 @@ public function keys($hash) */ protected function getWithLicenseHash($uri, $hash) { - return $this->get($uri, array('license_md5' => rawurlencode($hash))); + return $this->get($uri, ['license_md5' => rawurlencode($hash)]); } } diff --git a/lib/Github/Api/Enterprise/Stats.php b/lib/Github/Api/Enterprise/Stats.php index 7d3b1953892..78ba42565e9 100644 --- a/lib/Github/Api/Enterprise/Stats.php +++ b/lib/Github/Api/Enterprise/Stats.php @@ -123,6 +123,6 @@ public function all() */ public function show($type) { - return $this->get('/enterprise/stats/' . rawurlencode($type)); + return $this->get('/enterprise/stats/'.rawurlencode($type)); } } diff --git a/lib/Github/Api/Enterprise/UserAdmin.php b/lib/Github/Api/Enterprise/UserAdmin.php index 8f6ad10d91a..0cd55a38c53 100644 --- a/lib/Github/Api/Enterprise/UserAdmin.php +++ b/lib/Github/Api/Enterprise/UserAdmin.php @@ -17,7 +17,7 @@ class UserAdmin extends AbstractApi */ public function suspend($username) { - return $this->put('/users/'.rawurldecode($username).'/suspended', array('Content-Length' => 0)); + return $this->put('/users/'.rawurldecode($username).'/suspended', ['Content-Length' => 0]); } /** diff --git a/lib/Github/Api/Gist/Comments.php b/lib/Github/Api/Gist/Comments.php index e77428c1a53..0e022622ed8 100644 --- a/lib/Github/Api/Gist/Comments.php +++ b/lib/Github/Api/Gist/Comments.php @@ -7,6 +7,7 @@ /** * @link https://developer.github.com/v3/gists/comments/ + * * @author Kayla Daniels */ class Comments extends AbstractApi @@ -17,13 +18,14 @@ class Comments extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/gists/comments/#custom-media-types + * * @param string|null $bodyType * * @return self */ public function configure($bodyType = null) { - if (!in_array($bodyType, array('text', 'html', 'full'))) { + if (!in_array($bodyType, ['text', 'html', 'full'])) { $bodyType = 'raw'; } @@ -67,7 +69,7 @@ public function show($gist, $comment) */ public function create($gist, $body) { - return $this->post('/gists/'.rawurlencode($gist).'/comments', array('body' => $body)); + return $this->post('/gists/'.rawurlencode($gist).'/comments', ['body' => $body]); } /** @@ -81,7 +83,7 @@ public function create($gist, $body) */ public function update($gist, $comment_id, $body) { - return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment_id), array('body' => $body)); + return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment_id), ['body' => $body]); } /** diff --git a/lib/Github/Api/Gists.php b/lib/Github/Api/Gists.php index c661dfebbc2..e6bdc430640 100644 --- a/lib/Github/Api/Gists.php +++ b/lib/Github/Api/Gists.php @@ -2,13 +2,14 @@ namespace Github\Api; -use Github\Exception\MissingArgumentException; use Github\Api\Gist\Comments; +use Github\Exception\MissingArgumentException; /** * Creating, editing, deleting and listing gists. * * @link http://developer.github.com/v3/gists/ + * * @author Joseph Bielawski * @author Edoardo Rivello */ @@ -20,13 +21,14 @@ class Gists extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/gists/#custom-media-types + * * @param string|null $bodyType * * @return self */ public function configure($bodyType = null) { - if (!in_array($bodyType, array('base64'))) { + if (!in_array($bodyType, ['base64'])) { $bodyType = 'raw'; } @@ -37,7 +39,7 @@ public function configure($bodyType = null) public function all($type = null) { - if (!in_array($type, array('public', 'starred'))) { + if (!in_array($type, ['public', 'starred'])) { return $this->get('/gists'); } diff --git a/lib/Github/Api/GitData.php b/lib/Github/Api/GitData.php index 21395a8ba7a..d431b788704 100644 --- a/lib/Github/Api/GitData.php +++ b/lib/Github/Api/GitData.php @@ -12,6 +12,7 @@ * Getting full versions of specific files and trees in your Git repositories. * * @link http://developer.github.com/v3/git/ + * * @author Joseph Bielawski */ class GitData extends AbstractApi diff --git a/lib/Github/Api/GitData/Blobs.php b/lib/Github/Api/GitData/Blobs.php index 0cc980fef14..be68771d9bd 100644 --- a/lib/Github/Api/GitData/Blobs.php +++ b/lib/Github/Api/GitData/Blobs.php @@ -8,6 +8,7 @@ /** * @link http://developer.github.com/v3/git/blobs/ + * * @author Joseph Bielawski * @author Tobias Nyholm */ @@ -54,14 +55,14 @@ public function show($username, $repository, $sha) * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { if (!isset($params['content'], $params['encoding'])) { - throw new MissingArgumentException(array('content', 'encoding')); + throw new MissingArgumentException(['content', 'encoding']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs', $params); diff --git a/lib/Github/Api/GitData/Commits.php b/lib/Github/Api/GitData/Commits.php index e8d1bfe9d30..4205931f408 100644 --- a/lib/Github/Api/GitData/Commits.php +++ b/lib/Github/Api/GitData/Commits.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/git/commits/ + * * @author Joseph Bielawski */ class Commits extends AbstractApi @@ -32,14 +33,14 @@ public function show($username, $repository, $sha) * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { if (!isset($params['message'], $params['tree'], $params['parents'])) { - throw new MissingArgumentException(array('message', 'tree', 'parents')); + throw new MissingArgumentException(['message', 'tree', 'parents']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/commits', $params); diff --git a/lib/Github/Api/GitData/References.php b/lib/Github/Api/GitData/References.php index 906a6ffc117..c54c0c8aad0 100644 --- a/lib/Github/Api/GitData/References.php +++ b/lib/Github/Api/GitData/References.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/git/references/ + * * @author Joseph Bielawski */ class References extends AbstractApi @@ -73,14 +74,14 @@ public function show($username, $repository, $reference) * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { if (!isset($params['ref'], $params['sha'])) { - throw new MissingArgumentException(array('ref', 'sha')); + throw new MissingArgumentException(['ref', 'sha']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs', $params); @@ -94,9 +95,9 @@ public function create($username, $repository, array $params) * @param string $reference * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function update($username, $repository, $reference, array $params) { diff --git a/lib/Github/Api/GitData/Tags.php b/lib/Github/Api/GitData/Tags.php index d1caefe91f1..09f48bc0a80 100644 --- a/lib/Github/Api/GitData/Tags.php +++ b/lib/Github/Api/GitData/Tags.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/git/tags/ + * * @author Joseph Bielawski */ class Tags extends AbstractApi @@ -45,14 +46,14 @@ public function show($username, $repository, $sha) * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { if (!isset($params['tag'], $params['message'], $params['object'], $params['type'])) { - throw new MissingArgumentException(array('tag', 'message', 'object', 'type')); + throw new MissingArgumentException(['tag', 'message', 'object', 'type']); } if (!isset($params['tagger'])) { @@ -60,7 +61,7 @@ public function create($username, $repository, array $params) } if (!isset($params['tagger']['name'], $params['tagger']['email'], $params['tagger']['date'])) { - throw new MissingArgumentException(array('tagger.name', 'tagger.email', 'tagger.date')); + throw new MissingArgumentException(['tagger.name', 'tagger.email', 'tagger.date']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/tags', $params); diff --git a/lib/Github/Api/GitData/Trees.php b/lib/Github/Api/GitData/Trees.php index 80885682232..d514d9f8205 100644 --- a/lib/Github/Api/GitData/Trees.php +++ b/lib/Github/Api/GitData/Trees.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/git/trees/ + * * @author Joseph Bielawski */ class Trees extends AbstractApi @@ -23,7 +24,7 @@ class Trees extends AbstractApi */ public function show($username, $repository, $sha, $recursive = false) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/trees/'.rawurlencode($sha), $recursive ? array('recursive' => 1) : array()); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/trees/'.rawurlencode($sha), $recursive ? ['recursive' => 1] : []); } /** @@ -33,9 +34,9 @@ public function show($username, $repository, $sha, $recursive = false) * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { @@ -44,12 +45,12 @@ public function create($username, $repository, array $params) } if (!isset($params['tree'][0])) { - $params['tree'] = array($params['tree']); + $params['tree'] = [$params['tree']]; } foreach ($params['tree'] as $key => $tree) { if (!isset($tree['path'], $tree['mode'], $tree['type'])) { - throw new MissingArgumentException(array("tree.$key.path", "tree.$key.mode", "tree.$key.type")); + throw new MissingArgumentException(["tree.$key.path", "tree.$key.mode", "tree.$key.type"]); } // If `sha` is not set, `content` is required diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index eee542f3ad5..9d66b5123fb 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -8,38 +8,39 @@ * Part of the Github v4 API * * @link https://developer.github.com/v4/ + * * @author Miguel Piedrafita */ class GraphQL extends AbstractApi { use AcceptHeaderTrait; - + /** * @param string $query - * @param array $variables + * @param array $variables * * @return array */ - public function execute($query, array $variables = array()) + public function execute($query, array $variables = []) { $this->acceptHeaderValue = 'application/vnd.github.v4+json'; - $params = array( - 'query' => $query - ); + $params = [ + 'query' => $query, + ]; if (!empty($variables)) { $params['variables'] = json_encode($variables); } return $this->post('/graphql', $params); } - + /** * @param string $file - * @param array $variables + * @param array $variables * * @return array */ - public function fromFile($file, array $variables = array()) + public function fromFile($file, array $variables = []) { return $this->execute(file_get_contents($file), $variables); } diff --git a/lib/Github/Api/Integrations.php b/lib/Github/Api/Integrations.php index ef6ed557d82..bd4f78a4f07 100644 --- a/lib/Github/Api/Integrations.php +++ b/lib/Github/Api/Integrations.php @@ -7,6 +7,7 @@ /** * @deprecated Use the Apps class * @link https://developer.github.com/v3/apps/ + * * @author Nils Adermann */ class Integrations extends Apps @@ -14,7 +15,6 @@ class Integrations extends Apps /** * @deprecated * Configure the accept header for Early Access to the integrations api (DEPRECATED) - * * @see https://developer.github.com/v3/apps/ * * @return self diff --git a/lib/Github/Api/Issue.php b/lib/Github/Api/Issue.php index f77d4e4a22d..9b7d1d043ed 100644 --- a/lib/Github/Api/Issue.php +++ b/lib/Github/Api/Issue.php @@ -26,13 +26,14 @@ class Issue extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/issues/#custom-media-types + * * @param string|null $bodyType * * @return self */ public function configure($bodyType = null) { - if (!in_array($bodyType, array('text', 'html', 'full'))) { + if (!in_array($bodyType, ['text', 'html', 'full'])) { $bodyType = 'raw'; } @@ -52,16 +53,15 @@ public function configure($bodyType = null) * * @return array list of issues found */ - public function all($username, $repository, array $params = array()) + public function all($username, $repository, array $params = []) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', array_merge(array('page' => 1), $params)); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', array_merge(['page' => 1], $params)); } /** * Search issues by username, repo, state and keyword. * * @deprecated This method is deprecated use the Search api instead. See https://developer.github.com/v3/search/legacy/#legacy-search-api-is-deprecated - * * @link http://developer.github.com/v3/search/#search-issues * * @param string $username the username @@ -73,7 +73,7 @@ public function all($username, $repository, array $params = array()) */ public function find($username, $repository, $state, $keyword) { - if (!in_array($state, array('open', 'closed'))) { + if (!in_array($state, ['open', 'closed'])) { $state = 'open'; } @@ -91,13 +91,13 @@ public function find($username, $repository, $state, $keyword) * * @return array list of issues found */ - public function org($organization, $state, array $params = array()) + public function org($organization, $state, array $params = []) { - if (!in_array($state, array('open', 'closed'))) { + if (!in_array($state, ['open', 'closed'])) { $state = 'open'; } - return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(array('page' => 1, 'state' => $state), $params)); + return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(['page' => 1, 'state' => $state], $params)); } /** @@ -133,7 +133,7 @@ public function show($username, $repository, $id) public function create($username, $repository, array $params) { if (!isset($params['title'])) { - throw new MissingArgumentException(array('title')); + throw new MissingArgumentException(['title']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', $params); diff --git a/lib/Github/Api/Issue/Assignees.php b/lib/Github/Api/Issue/Assignees.php index f304f7ab05a..31d6ac9d999 100644 --- a/lib/Github/Api/Issue/Assignees.php +++ b/lib/Github/Api/Issue/Assignees.php @@ -16,7 +16,7 @@ class Assignees extends AbstractApi * * @return array */ - public function listAvailable($username, $repository, array $parameters = array()) + public function listAvailable($username, $repository, array $parameters = []) { return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees', $parameters); } @@ -34,11 +34,11 @@ public function listAvailable($username, $repository, array $parameters = array( */ public function check($username, $repository, $assignee) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees/' . rawurlencode($assignee)); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees/'.rawurlencode($assignee)); } /** - * Add assignees to an Issue + * Add assignees to an Issue. * * @link https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue * @@ -47,8 +47,9 @@ public function check($username, $repository, $assignee) * @param string $issue * @param array $parameters * - * @return string * @throws MissingArgumentException + * + * @return string */ public function add($username, $repository, $issue, array $parameters) { @@ -60,7 +61,7 @@ public function add($username, $repository, $issue, array $parameters) } /** - * Remove assignees from an Issue + * Remove assignees from an Issue. * * @link https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue * @@ -69,8 +70,9 @@ public function add($username, $repository, $issue, array $parameters) * @param string $issue * @param array $parameters * - * @return string * @throws MissingArgumentException + * + * @return string */ public function remove($username, $repository, $issue, array $parameters) { diff --git a/lib/Github/Api/Issue/Comments.php b/lib/Github/Api/Issue/Comments.php index c860c74d64e..a664d533274 100644 --- a/lib/Github/Api/Issue/Comments.php +++ b/lib/Github/Api/Issue/Comments.php @@ -8,6 +8,7 @@ /** * @link http://developer.github.com/v3/issues/comments/ + * * @author Joseph Bielawski * @author Tobias Nyholm */ @@ -19,13 +20,14 @@ class Comments extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/issues/comments/#custom-media-types + * * @param string|null $bodyType * * @return self */ public function configure($bodyType = null) { - if (!in_array($bodyType, array('raw', 'text', 'html'))) { + if (!in_array($bodyType, ['raw', 'text', 'html'])) { $bodyType = 'full'; } @@ -38,6 +40,7 @@ public function configure($bodyType = null) * Get all comments for an issue. * * @link https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + * * @param string $username * @param string $repository * @param int $issue @@ -47,15 +50,16 @@ public function configure($bodyType = null) */ public function all($username, $repository, $issue, $page = 1) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/comments', array( - 'page' => $page - )); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/comments', [ + 'page' => $page, + ]); } /** * Get a comment for an issue. * * @link https://developer.github.com/v3/issues/comments/#get-a-single-comment + * * @param string $username * @param string $repository * @param int $comment @@ -71,12 +75,14 @@ public function show($username, $repository, $comment) * Create a comment for an issue. * * @link https://developer.github.com/v3/issues/comments/#create-a-comment + * * @param string $username * @param string $repository * @param int $issue * @param array $params * * @throws \Github\Exception\MissingArgumentException + * * @return array */ public function create($username, $repository, $issue, array $params) @@ -92,12 +98,14 @@ public function create($username, $repository, $issue, array $params) * Update a comment for an issue. * * @link https://developer.github.com/v3/issues/comments/#edit-a-comment + * * @param string $username * @param string $repository * @param int $comment * @param array $params * * @throws \Github\Exception\MissingArgumentException + * * @return array */ public function update($username, $repository, $comment, array $params) @@ -113,6 +121,7 @@ public function update($username, $repository, $comment, array $params) * Delete a comment for an issue. * * @link https://developer.github.com/v3/issues/comments/#delete-a-comment + * * @param string $username * @param string $repository * @param int $comment diff --git a/lib/Github/Api/Issue/Events.php b/lib/Github/Api/Issue/Events.php index adfcde83e5e..8b70ec79e09 100644 --- a/lib/Github/Api/Issue/Events.php +++ b/lib/Github/Api/Issue/Events.php @@ -6,6 +6,7 @@ /** * @link http://developer.github.com/v3/issues/events/ + * * @author Joseph Bielawski */ class Events extends AbstractApi @@ -14,10 +15,12 @@ class Events extends AbstractApi * Get all events for an issue. * * @link https://developer.github.com/v3/issues/events/#list-events-for-an-issue + * * @param string $username * @param string $repository * @param int|null $issue * @param int $page + * * @return array */ public function all($username, $repository, $issue = null, $page = 1) @@ -28,18 +31,20 @@ public function all($username, $repository, $issue = null, $page = 1) $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/events'; } - return $this->get($path, array( - 'page' => $page - )); + return $this->get($path, [ + 'page' => $page, + ]); } /** * Display an event for an issue. * * @link https://developer.github.com/v3/issues/events/#get-a-single-event + * * @param $username * @param $repository * @param $event + * * @return array */ public function show($username, $repository, $event) diff --git a/lib/Github/Api/Issue/Labels.php b/lib/Github/Api/Issue/Labels.php index fb0f52362e3..1159e153ff0 100644 --- a/lib/Github/Api/Issue/Labels.php +++ b/lib/Github/Api/Issue/Labels.php @@ -8,6 +8,7 @@ /** * @link http://developer.github.com/v3/issues/labels/ + * * @author Joseph Bielawski */ class Labels extends AbstractApi @@ -16,6 +17,7 @@ class Labels extends AbstractApi * Get all labels for a repository or the labels for a specific issue. * * @link https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue + * * @param string $username * @param string $repository * @param int|null $issue @@ -53,13 +55,14 @@ public function show($username, $repository, $label) * Create a label for a repository. * * @link https://developer.github.com/v3/issues/labels/#create-a-label + * * @param string $username * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { @@ -77,6 +80,7 @@ public function create($username, $repository, array $params) * Delete a label for a repository. * * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue + * * @param string $username * @param string $repository * @param string $label @@ -89,9 +93,10 @@ public function deleteLabel($username, $repository, $label) } /** - * Edit a label for a repository + * Edit a label for a repository. * * @link https://developer.github.com/v3/issues/labels/#update-a-label + * * @param string $username * @param string $repository * @param string $label @@ -102,10 +107,10 @@ public function deleteLabel($username, $repository, $label) */ public function update($username, $repository, $label, $newName, $color) { - $params = array( + $params = [ 'name' => $newName, 'color' => $color, - ); + ]; return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params); } @@ -114,6 +119,7 @@ public function update($username, $repository, $label, $newName, $color) * Add a label to an issue. * * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue + * * @param string $username * @param string $repository * @param int $issue @@ -126,7 +132,7 @@ public function update($username, $repository, $label, $newName, $color) public function add($username, $repository, $issue, $labels) { if (is_string($labels)) { - $labels = array($labels); + $labels = [$labels]; } elseif (0 === count($labels)) { throw new InvalidArgumentException(); } @@ -138,6 +144,7 @@ public function add($username, $repository, $issue, $labels) * Replace labels for an issue. * * @link https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue + * * @param string $username * @param string $repository * @param int $issue @@ -151,9 +158,10 @@ public function replace($username, $repository, $issue, array $params) } /** - * Remove a label for an issue + * Remove a label for an issue. * * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue + * * @param string $username * @param string $repository * @param string $issue @@ -170,6 +178,7 @@ public function remove($username, $repository, $issue, $label) * Remove all labels from an issue. * * @link https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue + * * @param string $username * @param string $repository * @param string $issue diff --git a/lib/Github/Api/Issue/Milestones.php b/lib/Github/Api/Issue/Milestones.php index c7ac0f4bd3f..11f0e94c6b1 100644 --- a/lib/Github/Api/Issue/Milestones.php +++ b/lib/Github/Api/Issue/Milestones.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/issues/milestones/ + * * @author Joseph Bielawski */ class Milestones extends AbstractApi @@ -15,36 +16,38 @@ class Milestones extends AbstractApi * Get all milestones for a repository. * * @link https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository + * * @param string $username * @param string $repository * @param array $params * * @return array */ - public function all($username, $repository, array $params = array()) + public function all($username, $repository, array $params = []) { - if (isset($params['state']) && !in_array($params['state'], array('open', 'closed', 'all'))) { + if (isset($params['state']) && !in_array($params['state'], ['open', 'closed', 'all'])) { $params['state'] = 'open'; } - if (isset($params['sort']) && !in_array($params['sort'], array('due_date', 'completeness'))) { + if (isset($params['sort']) && !in_array($params['sort'], ['due_date', 'completeness'])) { $params['sort'] = 'due_date'; } - if (isset($params['direction']) && !in_array($params['direction'], array('asc', 'desc'))) { + if (isset($params['direction']) && !in_array($params['direction'], ['asc', 'desc'])) { $params['direction'] = 'asc'; } - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones', array_merge(array( + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones', array_merge([ 'page' => 1, 'state' => 'open', 'sort' => 'due_date', - 'direction' => 'asc' - ), $params)); + 'direction' => 'asc', + ], $params)); } /** * Get a milestone for a repository. * * @link https://developer.github.com/v3/issues/milestones/#get-a-single-milestone + * * @param string $username * @param string $repository * @param int $id @@ -60,20 +63,21 @@ public function show($username, $repository, $id) * Create a milestone for a repository. * * @link https://developer.github.com/v3/issues/milestones/#create-a-milestone + * * @param string $username * @param string $repository * @param array $params * - * @return array - * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($username, $repository, array $params) { if (!isset($params['title'])) { throw new MissingArgumentException('title'); } - if (isset($params['state']) && !in_array($params['state'], array('open', 'closed'))) { + if (isset($params['state']) && !in_array($params['state'], ['open', 'closed'])) { $params['state'] = 'open'; } @@ -84,6 +88,7 @@ public function create($username, $repository, array $params) * Update a milestone for a repository. * * @link https://developer.github.com/v3/issues/milestones/#update-a-milestone + * * @param string $username * @param string $repository * @param int $id @@ -93,7 +98,7 @@ public function create($username, $repository, array $params) */ public function update($username, $repository, $id, array $params) { - if (isset($params['state']) && !in_array($params['state'], array('open', 'closed'))) { + if (isset($params['state']) && !in_array($params['state'], ['open', 'closed'])) { $params['state'] = 'open'; } @@ -104,6 +109,7 @@ public function update($username, $repository, $id, array $params) * Delete a milestone for a repository. * * @link https://developer.github.com/v3/issues/milestones/#delete-a-milestone + * * @param string $username * @param string $repository * @param int $id @@ -116,9 +122,10 @@ public function remove($username, $repository, $id) } /** - * Get the labels of a milestone + * Get the labels of a milestone. * * @link https://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone + * * @param string $username * @param string $repository * @param int $id diff --git a/lib/Github/Api/Issue/Timeline.php b/lib/Github/Api/Issue/Timeline.php index 1a076641024..c0f76f2f761 100644 --- a/lib/Github/Api/Issue/Timeline.php +++ b/lib/Github/Api/Issue/Timeline.php @@ -20,6 +20,7 @@ public function configure() * Get all events for a specific issue. * * @link https://developer.github.com/v3/issues/timeline/#list-events-for-an-issue + * * @param string $username * @param string $repository * @param int $issue diff --git a/lib/Github/Api/Markdown.php b/lib/Github/Api/Markdown.php index 82d2ac55b6c..977b1d048e0 100644 --- a/lib/Github/Api/Markdown.php +++ b/lib/Github/Api/Markdown.php @@ -6,6 +6,7 @@ * Markdown Rendering API. * * @link http://developer.github.com/v3/markdown/ + * * @author Joseph Bielawski */ class Markdown extends AbstractApi @@ -19,14 +20,14 @@ class Markdown extends AbstractApi */ public function render($text, $mode = 'markdown', $context = null) { - if (!in_array($mode, array('gfm', 'markdown'))) { + if (!in_array($mode, ['gfm', 'markdown'])) { $mode = 'markdown'; } - $params = array( + $params = [ 'text' => $text, - 'mode' => $mode - ); + 'mode' => $mode, + ]; if (null !== $context && 'gfm' === $mode) { $params['context'] = $context; } @@ -41,8 +42,8 @@ public function render($text, $mode = 'markdown', $context = null) */ public function renderRaw($file) { - return $this->post('/markdown/raw', array( - 'file' => $file - )); + return $this->post('/markdown/raw', [ + 'file' => $file, + ]); } } diff --git a/lib/Github/Api/Meta.php b/lib/Github/Api/Meta.php index 076b3dc501e..0ec81f65ef9 100644 --- a/lib/Github/Api/Meta.php +++ b/lib/Github/Api/Meta.php @@ -6,6 +6,7 @@ * Getting GitHub service information. * * @link https://developer.github.com/v3/meta/ + * * @author Claude Dioudonnat */ class Meta extends AbstractApi diff --git a/lib/Github/Api/Miscellaneous/CodeOfConduct.php b/lib/Github/Api/Miscellaneous/CodeOfConduct.php index 7d3c69ff469..64bfaa8b420 100644 --- a/lib/Github/Api/Miscellaneous/CodeOfConduct.php +++ b/lib/Github/Api/Miscellaneous/CodeOfConduct.php @@ -29,7 +29,7 @@ public function all() } /** - * Get an individual code of conduct + * Get an individual code of conduct. * * @link https://developer.github.com/v3/codes_of_conduct/#get-an-individual-code-of-conduct * @@ -39,6 +39,6 @@ public function all() */ public function show($key) { - return $this->get('/codes_of_conduct/' . rawurlencode($key)); + return $this->get('/codes_of_conduct/'.rawurlencode($key)); } } diff --git a/lib/Github/Api/Miscellaneous/Gitignore.php b/lib/Github/Api/Miscellaneous/Gitignore.php index c7306110ee5..c5f03e7e0e0 100644 --- a/lib/Github/Api/Miscellaneous/Gitignore.php +++ b/lib/Github/Api/Miscellaneous/Gitignore.php @@ -29,6 +29,6 @@ public function all() */ public function show($template) { - return $this->get('/gitignore/templates/' . rawurlencode($template)); + return $this->get('/gitignore/templates/'.rawurlencode($template)); } } diff --git a/lib/Github/Api/Notification.php b/lib/Github/Api/Notification.php index e8d5d8f7810..fbaed083518 100644 --- a/lib/Github/Api/Notification.php +++ b/lib/Github/Api/Notification.php @@ -10,6 +10,7 @@ * Important! You have to be authenticated to perform these methods * * @link https://developer.github.com/v3/activity/notifications/ + * * @author Dennis de Greef */ class Notification extends AbstractApi @@ -27,10 +28,10 @@ class Notification extends AbstractApi */ public function all($includingRead = false, $participating = false, DateTime $since = null) { - $parameters = array( + $parameters = [ 'all' => $includingRead, - 'participating' => $participating - ); + 'participating' => $participating, + ]; if ($since !== null) { $parameters['since'] = $since->format(DateTime::ISO8601); @@ -49,7 +50,7 @@ public function all($includingRead = false, $participating = false, DateTime $si */ public function markRead(DateTime $since = null) { - $parameters = array(); + $parameters = []; if ($since !== null) { $parameters['last_read_at'] = $since->format(DateTime::ISO8601); @@ -57,8 +58,9 @@ public function markRead(DateTime $since = null) $this->put('/notifications', $parameters); } + /** - * Gets a single notification using his ID + * Gets a single notification using his ID. * * @link https://developer.github.com/v3/activity/notifications/#view-a-single-thread * diff --git a/lib/Github/Api/Organization.php b/lib/Github/Api/Organization.php index 077211a4987..49ca5c91f03 100644 --- a/lib/Github/Api/Organization.php +++ b/lib/Github/Api/Organization.php @@ -10,6 +10,7 @@ * Getting organization information and managing authenticated organization account information. * * @link http://developer.github.com/v3/orgs/ + * * @author Antoine Berranger * @author Joseph Bielawski */ @@ -57,10 +58,10 @@ public function update($organization, array $params) */ public function repositories($organization, $type = 'all', $page = 1) { - return $this->get('/orgs/'.rawurlencode($organization).'/repos', array( + return $this->get('/orgs/'.rawurlencode($organization).'/repos', [ 'type' => $type, 'page' => $page, - )); + ]); } /** @@ -92,12 +93,12 @@ public function teams() * * @param $organization * @param array $params - * @param int $page + * @param int $page * * @return array */ - public function issues($organization, array $params = array(), $page = 1) + public function issues($organization, array $params = [], $page = 1) { - return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(array('page' => $page), $params)); + return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(['page' => $page], $params)); } } diff --git a/lib/Github/Api/Organization/Hooks.php b/lib/Github/Api/Organization/Hooks.php index e137dee1ab7..b68a43bc3a6 100644 --- a/lib/Github/Api/Organization/Hooks.php +++ b/lib/Github/Api/Organization/Hooks.php @@ -11,7 +11,9 @@ class Hooks extends AbstractApi * List hooks. * * @link https://developer.github.com/v3/orgs/hooks/#list-hooks + * * @param string $organization + * * @return array */ public function all($organization) @@ -21,10 +23,12 @@ public function all($organization) /** * Get a single hook. + * * @link https://developer.github.com/v3/orgs/hooks/#get-single-hook * * @param string $organization * @param int $id + * * @return array */ public function show($organization, $id) @@ -36,15 +40,18 @@ public function show($organization, $id) * Create a hook. * * @link https://developer.github.com/v3/orgs/hooks/#create-a-hook + * * @param string $organization * @param array $params - * @return array + * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function create($organization, array $params) { if (!isset($params['name'], $params['config'])) { - throw new MissingArgumentException(array('name', 'config')); + throw new MissingArgumentException(['name', 'config']); } return $this->post('/orgs/'.rawurlencode($organization).'/hooks', $params); @@ -54,16 +61,19 @@ public function create($organization, array $params) * Edit a hook. * * @link https://developer.github.com/v3/orgs/hooks/#edit-a-hook + * * @param string $organization * @param int $id * @param array $params - * @return array + * * @throws \Github\Exception\MissingArgumentException + * + * @return array */ public function update($organization, $id, array $params) { if (!isset($params['config'])) { - throw new MissingArgumentException(array('config')); + throw new MissingArgumentException(['config']); } return $this->patch('/orgs/'.rawurlencode($organization).'/hooks/'.rawurlencode($id), $params); @@ -73,8 +83,10 @@ public function update($organization, $id, array $params) * Ping a hook. * * @link https://developer.github.com/v3/orgs/hooks/#ping-a-hook + * * @param string $organization * @param int $id + * * @return null */ public function ping($organization, $id) @@ -86,8 +98,10 @@ public function ping($organization, $id) * Delete a hook. * * @link https://developer.github.com/v3/orgs/hooks/#delete-a-hook + * * @param string $organization * @param int $id + * * @return null */ public function remove($organization, $id) diff --git a/lib/Github/Api/Organization/Members.php b/lib/Github/Api/Organization/Members.php index 13bda339eb2..3639e3ba57d 100644 --- a/lib/Github/Api/Organization/Members.php +++ b/lib/Github/Api/Organization/Members.php @@ -6,13 +6,14 @@ /** * @link http://developer.github.com/v3/orgs/members/ + * * @author Joseph Bielawski */ class Members extends AbstractApi { public function all($organization, $type = null, $filter = 'all', $role = null) { - $parameters = array(); + $parameters = []; $path = '/orgs/'.rawurlencode($organization).'/'; if (null === $type) { $path .= 'members'; diff --git a/lib/Github/Api/Organization/Projects.php b/lib/Github/Api/Organization/Projects.php index dcff9c86c98..2bb7196e95a 100644 --- a/lib/Github/Api/Organization/Projects.php +++ b/lib/Github/Api/Organization/Projects.php @@ -7,15 +7,15 @@ class Projects extends AbstractProjectApi { - public function all($organization, array $params = array()) + public function all($organization, array $params = []) { - return $this->get('/orgs/'.rawurlencode($organization).'/projects', array_merge(array('page' => 1), $params)); + return $this->get('/orgs/'.rawurlencode($organization).'/projects', array_merge(['page' => 1], $params)); } public function create($organization, array $params) { if (!isset($params['name'])) { - throw new MissingArgumentException(array('name')); + throw new MissingArgumentException(['name']); } return $this->post('/orgs/'.rawurlencode($organization).'/projects', $params); diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php index b6b0b72eb5e..401dbe4f116 100644 --- a/lib/Github/Api/Organization/Teams.php +++ b/lib/Github/Api/Organization/Teams.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/orgs/teams/ + * * @author Joseph Bielawski */ class Teams extends AbstractApi @@ -22,9 +23,9 @@ public function create($organization, array $params) throw new MissingArgumentException('name'); } if (isset($params['repo_names']) && !is_array($params['repo_names'])) { - $params['repo_names'] = array($params['repo_names']); + $params['repo_names'] = [$params['repo_names']]; } - if (isset($params['permission']) && !in_array($params['permission'], array('pull', 'push', 'admin'))) { + if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) { $params['permission'] = 'pull'; } @@ -41,7 +42,7 @@ public function update($team, array $params) if (!isset($params['name'])) { throw new MissingArgumentException('name'); } - if (isset($params['permission']) && !in_array($params['permission'], array('pull', 'push', 'admin'))) { + if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) { $params['permission'] = 'pull'; } @@ -83,9 +84,9 @@ public function repository($team, $organization, $repository) return $this->get('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); } - public function addRepository($team, $organization, $repository, $params = array()) + public function addRepository($team, $organization, $repository, $params = []) { - if (isset($params['permission']) && !in_array($params['permission'], array('pull', 'push', 'admin'))) { + if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) { $params['permission'] = 'pull'; } diff --git a/lib/Github/Api/Project/AbstractProjectApi.php b/lib/Github/Api/Project/AbstractProjectApi.php index b64f1ca19b1..15274d7dbc4 100644 --- a/lib/Github/Api/Project/AbstractProjectApi.php +++ b/lib/Github/Api/Project/AbstractProjectApi.php @@ -10,7 +10,7 @@ abstract class AbstractProjectApi extends AbstractApi use AcceptHeaderTrait; /** - * Configure the accept header for Early Access to the projects api + * Configure the accept header for Early Access to the projects api. * * @see https://developer.github.com/v3/repos/projects/#projects * @@ -23,9 +23,9 @@ public function configure() return $this; } - public function show($id, array $params = array()) + public function show($id, array $params = []) { - return $this->get('/projects/' . rawurlencode($id), array_merge(array('page' => 1), $params)); + return $this->get('/projects/'.rawurlencode($id), array_merge(['page' => 1], $params)); } public function update($id, array $params) diff --git a/lib/Github/Api/Project/Cards.php b/lib/Github/Api/Project/Cards.php index 61eca191040..758e7708b08 100644 --- a/lib/Github/Api/Project/Cards.php +++ b/lib/Github/Api/Project/Cards.php @@ -11,7 +11,7 @@ class Cards extends AbstractApi use AcceptHeaderTrait; /** - * Configure the accept header for Early Access to the projects api + * Configure the accept header for Early Access to the projects api. * * @see https://developer.github.com/v3/repos/projects/#projects * @@ -24,9 +24,9 @@ public function configure() return $this; } - public function all($columnId, array $params = array()) + public function all($columnId, array $params = []) { - return $this->get('/projects/columns/' . rawurlencode($columnId) . '/cards', array_merge(array('page' => 1), $params)); + return $this->get('/projects/columns/'.rawurlencode($columnId).'/cards', array_merge(['page' => 1], $params)); } public function show($id) @@ -36,12 +36,12 @@ public function show($id) public function create($columnId, array $params) { - return $this->post('/projects/columns/' . rawurlencode($columnId) . '/cards', $params); + return $this->post('/projects/columns/'.rawurlencode($columnId).'/cards', $params); } public function update($id, array $params) { - return $this->patch('/projects/columns/cards/' . rawurlencode($id), $params); + return $this->patch('/projects/columns/cards/'.rawurlencode($id), $params); } public function deleteCard($id) @@ -52,9 +52,9 @@ public function deleteCard($id) public function move($id, array $params) { if (!isset($params['position'])) { - throw new MissingArgumentException(array('position')); + throw new MissingArgumentException(['position']); } - return $this->post('/projects/columns/cards/' . rawurlencode($id) . '/moves', $params); + return $this->post('/projects/columns/cards/'.rawurlencode($id).'/moves', $params); } } diff --git a/lib/Github/Api/Project/Columns.php b/lib/Github/Api/Project/Columns.php index 76c555979bd..22e5cbafcb8 100644 --- a/lib/Github/Api/Project/Columns.php +++ b/lib/Github/Api/Project/Columns.php @@ -11,7 +11,7 @@ class Columns extends AbstractApi use AcceptHeaderTrait; /** - * Configure the accept header for Early Access to the projects api + * Configure the accept header for Early Access to the projects api. * * @see https://developer.github.com/v3/repos/projects/#projects * @@ -24,9 +24,9 @@ public function configure() return $this; } - public function all($projectId, array $params = array()) + public function all($projectId, array $params = []) { - return $this->get('/projects/' . rawurlencode($projectId) . '/columns', array_merge(array('page' => 1), $params)); + return $this->get('/projects/'.rawurlencode($projectId).'/columns', array_merge(['page' => 1], $params)); } public function show($id) @@ -37,19 +37,19 @@ public function show($id) public function create($projectId, array $params) { if (!isset($params['name'])) { - throw new MissingArgumentException(array('name')); + throw new MissingArgumentException(['name']); } - return $this->post('/projects/' . rawurlencode($projectId) . '/columns', $params); + return $this->post('/projects/'.rawurlencode($projectId).'/columns', $params); } public function update($id, array $params) { if (!isset($params['name'])) { - throw new MissingArgumentException(array('name')); + throw new MissingArgumentException(['name']); } - return $this->patch('/projects/columns/' . rawurlencode($id), $params); + return $this->patch('/projects/columns/'.rawurlencode($id), $params); } public function deleteColumn($id) @@ -60,10 +60,10 @@ public function deleteColumn($id) public function move($id, array $params) { if (!isset($params['position'])) { - throw new MissingArgumentException(array('position')); + throw new MissingArgumentException(['position']); } - return $this->post('/projects/columns/' . rawurlencode($id) . '/moves', $params); + return $this->post('/projects/columns/'.rawurlencode($id).'/moves', $params); } public function cards() diff --git a/lib/Github/Api/PullRequest.php b/lib/Github/Api/PullRequest.php index 89a48c7c9d3..933dd7b1a97 100644 --- a/lib/Github/Api/PullRequest.php +++ b/lib/Github/Api/PullRequest.php @@ -23,6 +23,7 @@ class PullRequest extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/pulls/#custom-media-types + * * @param string|null $bodyType * @param string|null $apiVersion * @@ -30,15 +31,15 @@ class PullRequest extends AbstractApi */ public function configure($bodyType = null, $apiVersion = null) { - if (!in_array($apiVersion, array())) { + if (!in_array($apiVersion, [])) { $apiVersion = $this->client->getApiVersion(); } - if (!in_array($bodyType, array('text', 'html', 'full', 'diff', 'patch'))) { + if (!in_array($bodyType, ['text', 'html', 'full', 'diff', 'patch'])) { $bodyType = 'raw'; } - if (!in_array($bodyType, array('diff', 'patch'))) { + if (!in_array($bodyType, ['diff', 'patch'])) { $bodyType .= '+json'; } @@ -58,12 +59,12 @@ public function configure($bodyType = null, $apiVersion = null) * * @return array array of pull requests for the project */ - public function all($username, $repository, array $params = array()) + public function all($username, $repository, array $params = []) { - $parameters = array_merge(array( + $parameters = array_merge([ 'page' => 1, 'per_page' => 30, - ), $params); + ], $params); return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls', $parameters); } @@ -148,16 +149,16 @@ public function create($username, $repository, array $params) { // Two ways to create PR, using issue or title if (!isset($params['issue']) && !isset($params['title'])) { - throw new MissingArgumentException(array('issue', 'title')); + throw new MissingArgumentException(['issue', 'title']); } if (!isset($params['base'], $params['head'])) { - throw new MissingArgumentException(array('base', 'head')); + throw new MissingArgumentException(['base', 'head']); } // If `issue` is not sent, then `body` must be sent if (!isset($params['issue']) && !isset($params['body'])) { - throw new MissingArgumentException(array('issue', 'body')); + throw new MissingArgumentException(['issue', 'body']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls', $params); @@ -165,7 +166,7 @@ public function create($username, $repository, array $params) public function update($username, $repository, $id, array $params) { - if (isset($params['state']) && !in_array($params['state'], array('open', 'closed'))) { + if (isset($params['state']) && !in_array($params['state'], ['open', 'closed'])) { $params['state'] = 'open'; } @@ -183,15 +184,15 @@ public function merge($username, $repository, $id, $message, $sha, $mergeMethod $mergeMethod = $mergeMethod ? 'squash' : 'merge'; } - if (!in_array($mergeMethod, array('merge', 'squash', 'rebase'), true)) { + if (!in_array($mergeMethod, ['merge', 'squash', 'rebase'], true)) { throw new InvalidArgumentException(sprintf('"$mergeMethod" must be one of ["merge", "squash", "rebase"] ("%s" given).', $mergeMethod)); } - $params = array( + $params = [ 'commit_message' => $message, 'sha' => $sha, 'merge_method' => $mergeMethod, - ); + ]; if (is_string($title)) { $params['commit_title'] = $title; diff --git a/lib/Github/Api/PullRequest/Comments.php b/lib/Github/Api/PullRequest/Comments.php index 18679ca133e..183bfbe06ef 100644 --- a/lib/Github/Api/PullRequest/Comments.php +++ b/lib/Github/Api/PullRequest/Comments.php @@ -8,6 +8,7 @@ /** * @link http://developer.github.com/v3/pulls/comments/ + * * @author Joseph Bielawski */ class Comments extends AbstractApi @@ -18,6 +19,7 @@ class Comments extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/pulls/comments/#custom-media-types + * * @param string|null $bodyType * @param string|null @apiVersion * @@ -25,11 +27,11 @@ class Comments extends AbstractApi */ public function configure($bodyType = null, $apiVersion = null) { - if (!in_array($apiVersion, array('squirrel-girl-preview'))) { + if (!in_array($apiVersion, ['squirrel-girl-preview'])) { $apiVersion = $this->client->getApiVersion(); } - if (!in_array($bodyType, array('text', 'html', 'full'))) { + if (!in_array($bodyType, ['text', 'html', 'full'])) { $bodyType = 'raw'; } @@ -60,7 +62,7 @@ public function all($username, $repository, $pullRequest = null, array $params = $parameters = array_merge([ 'page' => 1, - 'per_page' => 30 + 'per_page' => 30, ], $params); return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments', $parameters); @@ -104,7 +106,7 @@ public function create($username, $repository, $pullRequest, array $params) // If `in_reply_to` is set, other options are not necessary anymore if (!isset($params['in_reply_to']) && !isset($params['commit_id'], $params['path'], $params['position'])) { - throw new MissingArgumentException(array('commit_id', 'path', 'position')); + throw new MissingArgumentException(['commit_id', 'path', 'position']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($pullRequest).'/comments', $params); diff --git a/lib/Github/Api/PullRequest/Review.php b/lib/Github/Api/PullRequest/Review.php index 83182ad3c76..04d5fb766ac 100644 --- a/lib/Github/Api/PullRequest/Review.php +++ b/lib/Github/Api/PullRequest/Review.php @@ -11,6 +11,7 @@ * API for accessing Pull Request Reviews from your Git/Github repositories. * * @link https://developer.github.com/v3/pulls/reviews/ + * * @author Christian Flothmann */ class Review extends AbstractApi @@ -38,7 +39,7 @@ public function all($username, $repository, $pullRequest, array $params = []) { $parameters = array_merge([ 'page' => 1, - 'per_page' => 30 + 'per_page' => 30, ], $params); return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews', $parameters); @@ -115,7 +116,7 @@ public function create($username, $repository, $pullRequest, array $params = []) throw new MissingArgumentException('event'); } - if (!in_array($params['event'], ["APPROVE", "REQUEST_CHANGES", "COMMENT"], true)) { + if (!in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) { throw new InvalidArgumentException(sprintf('"event" must be one of ["APPROVE", "REQUEST_CHANGES", "COMMENT"] ("%s" given).', $params['event'])); } @@ -143,7 +144,7 @@ public function submit($username, $repository, $pullRequest, $id, array $params throw new MissingArgumentException('event'); } - if (!in_array($params['event'], ["APPROVE", "REQUEST_CHANGES", "COMMENT"], true)) { + if (!in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) { throw new InvalidArgumentException(sprintf('"event" must be one of ["APPROVE", "REQUEST_CHANGES", "COMMENT"] ("%s" given).', $params['event'])); } @@ -159,7 +160,7 @@ public function submit($username, $repository, $pullRequest, $id, array $params * @param string $repository the repository * @param int $pullRequest the pull request number * @param int $id the review id - * @param string $message a mandatory dismissal message + * @param string $message a mandatory dismissal message * * @return array|string */ @@ -174,7 +175,7 @@ public function dismiss($username, $repository, $pullRequest, $id, $message) } return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id.'/dismissals', [ - 'message' => $message + 'message' => $message, ]); } } diff --git a/lib/Github/Api/RateLimit.php b/lib/Github/Api/RateLimit.php index bfa42ae8288..ba5301dffd6 100644 --- a/lib/Github/Api/RateLimit.php +++ b/lib/Github/Api/RateLimit.php @@ -3,15 +3,16 @@ namespace Github\Api; /** - * Get rate limits + * Get rate limits. * * @link https://developer.github.com/v3/rate_limit/ + * * @author Jeff Finley */ class RateLimit extends AbstractApi { /** - * Get rate limits + * Get rate limits. * * @return array */ @@ -21,9 +22,9 @@ public function getRateLimits() } /** - * Get core rate limit + * Get core rate limit. * - * @return integer + * @return int */ public function getCoreLimit() { @@ -33,9 +34,9 @@ public function getCoreLimit() } /** - * Get search rate limit + * Get search rate limit. * - * @return integer + * @return int */ public function getSearchLimit() { diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index b00f12ded48..cc2bc109972 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -8,12 +8,12 @@ use Github\Api\Repository\Contents; use Github\Api\Repository\DeployKeys; use Github\Api\Repository\Downloads; -use Github\Api\Repository\Projects; -use Github\Api\Repository\Protection; -use Github\Api\Repository\Releases; use Github\Api\Repository\Forks; use Github\Api\Repository\Hooks; use Github\Api\Repository\Labels; +use Github\Api\Repository\Projects; +use Github\Api\Repository\Protection; +use Github\Api\Repository\Releases; use Github\Api\Repository\Stargazers; use Github\Api\Repository\Statuses; use Github\Api\Repository\Traffic; @@ -23,6 +23,7 @@ * and managing repository information for authenticated users. * * @link http://developer.github.com/v3/repos/ + * * @author Joseph Bielawski * @author Thibault Duplessis */ @@ -34,7 +35,6 @@ class Repo extends AbstractApi * Search repositories by keyword. * * @deprecated This method is deprecated use the Search api instead. See https://developer.github.com/v3/search/legacy/#legacy-search-api-is-deprecated - * * @link http://developer.github.com/v3/search/#search-repositories * * @param string $keyword the search query @@ -42,9 +42,9 @@ class Repo extends AbstractApi * * @return array list of found repositories */ - public function find($keyword, array $params = array()) + public function find($keyword, array $params = []) { - return $this->get('/legacy/repos/search/'.rawurlencode($keyword), array_merge(array('start_page' => 1), $params)); + return $this->get('/legacy/repos/search/'.rawurlencode($keyword), array_merge(['start_page' => 1], $params)); } /** @@ -62,7 +62,7 @@ public function all($id = null) return $this->get('/repositories'); } - return $this->get('/repositories?since=' . rawurldecode($id)); + return $this->get('/repositories?since='.rawurldecode($id)); } /** @@ -135,9 +135,9 @@ public function participation($username, $repository) * * @return array list of organization repositories */ - public function org($organization, array $params = array()) + public function org($organization, array $params = []) { - return $this->get('/orgs/'.$organization.'/repos', array_merge(array('start_page' => 1), $params)); + return $this->get('/orgs/'.$organization.'/repos', array_merge(['start_page' => 1], $params)); } /** @@ -163,7 +163,7 @@ public function show($username, $repository) * @link https://github.com/piotrmurach/github/issues/283 * @link https://github.com/piotrmurach/github/issues/282 * - * @param int $id the id of the repository + * @param int $id the id of the repository * * @return array information about the repository */ @@ -204,7 +204,7 @@ public function create( ) { $path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos'; - $parameters = array( + $parameters = [ 'name' => $name, 'description' => $description, 'homepage' => $homepage, @@ -212,8 +212,8 @@ public function create( 'has_issues' => $hasIssues, 'has_wiki' => $hasWiki, 'has_downloads' => $hasDownloads, - 'auto_init' => $autoInit - ); + 'auto_init' => $autoInit, + ]; if ($organization && $teamId) { $parameters['team_id'] = $teamId; @@ -462,9 +462,9 @@ public function protection() */ public function contributors($username, $repository, $includingAnonymous = false) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contributors', array( - 'anon' => $includingAnonymous ?: null - )); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contributors', [ + 'anon' => $includingAnonymous ?: null, + ]); } /** @@ -524,9 +524,9 @@ public function teams($username, $repository) */ public function watchers($username, $repository, $page = 1) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/watchers', array( - 'page' => $page - )); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/watchers', [ + 'page' => $page, + ]); } /** @@ -538,9 +538,9 @@ public function watchers($username, $repository, $page = 1) */ public function subscribers($username, $repository, $page = 1) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/subscribers', array( - 'page' => $page - )); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/subscribers', [ + 'page' => $page, + ]); } /** @@ -558,10 +558,10 @@ public function subscribers($username, $repository, $page = 1) */ public function merge($username, $repository, $base, $head, $message = null) { - $parameters = array( + $parameters = [ 'base' => $base, 'head' => $head, - ); + ]; if (is_string($message)) { $parameters['commit_message'] = $message; @@ -573,6 +573,7 @@ public function merge($username, $repository, $base, $head, $message = null) /** * @param string $username * @param string $repository + * * @return array */ public function milestones($username, $repository) @@ -605,7 +606,7 @@ public function events($username, $repository, $page = 1) } /** - * Get the contents of a repository's code of conduct + * Get the contents of a repository's code of conduct. * * @link https://developer.github.com/v3/codes_of_conduct/#get-the-contents-of-a-repositorys-code-of-conduct * @@ -623,7 +624,7 @@ public function codeOfConduct($username, $repository) } /** - * List all topics for a repository + * List all topics for a repository. * * @link https://developer.github.com/v3/repos/#list-all-topics-for-a-repository * @@ -641,7 +642,7 @@ public function topics($username, $repository) } /** - * Replace all topics for a repository + * Replace all topics for a repository. * * @link https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository * diff --git a/lib/Github/Api/Repository/Assets.php b/lib/Github/Api/Repository/Assets.php index 21b5a08cc5d..dbe6da2251a 100644 --- a/lib/Github/Api/Repository/Assets.php +++ b/lib/Github/Api/Repository/Assets.php @@ -8,6 +8,7 @@ /** * @link http://developer.github.com/v3/repos/releases/ + * * @author Evgeniy Guseletov */ class Assets extends AbstractApi @@ -73,7 +74,7 @@ public function create($username, $repository, $id, $name, $contentType, $conten // Asset creation requires a separate endpoint, uploads.github.com. // Change the base url for the HTTP client temporarily while we execute // this request. - $response = $this->postRaw('https://uploads.github.com/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id).'/assets?name='.$name, $content, array('Content-Type' => $contentType)); + $response = $this->postRaw('https://uploads.github.com/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id).'/assets?name='.$name, $content, ['Content-Type' => $contentType]); return $response; } diff --git a/lib/Github/Api/Repository/Collaborators.php b/lib/Github/Api/Repository/Collaborators.php index 86812be9538..b9467ed1949 100644 --- a/lib/Github/Api/Repository/Collaborators.php +++ b/lib/Github/Api/Repository/Collaborators.php @@ -6,6 +6,7 @@ /** * @link http://developer.github.com/v3/repos/collaborators/ + * * @author Joseph Bielawski */ class Collaborators extends AbstractApi @@ -16,6 +17,7 @@ class Collaborators extends AbstractApi * @param $username * @param $repository * @param array $params + * * @return array|string */ public function all($username, $repository, array $params = []) @@ -29,6 +31,7 @@ public function all($username, $repository, array $params = []) * @param $username * @param $repository * @param $collaborator + * * @return array|string */ public function check($username, $repository, $collaborator) @@ -43,6 +46,7 @@ public function check($username, $repository, $collaborator) * @param $repository * @param $collaborator * @param array $params + * * @return array|string */ public function add($username, $repository, $collaborator, array $params = []) @@ -56,6 +60,7 @@ public function add($username, $repository, $collaborator, array $params = []) * @param $username * @param $repository * @param $collaborator + * * @return array|string */ public function remove($username, $repository, $collaborator) diff --git a/lib/Github/Api/Repository/Comments.php b/lib/Github/Api/Repository/Comments.php index 4e993720296..53feb72cd31 100644 --- a/lib/Github/Api/Repository/Comments.php +++ b/lib/Github/Api/Repository/Comments.php @@ -8,6 +8,7 @@ /** * @link http://developer.github.com/v3/repos/comments/ + * * @author Joseph Bielawski * @author Tobias Nyholm */ @@ -19,13 +20,14 @@ class Comments extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/repos/comments/#custom-media-types + * * @param string|null $bodyType * * @return self */ public function configure($bodyType = null) { - if (!in_array($bodyType, array('raw', 'text', 'html'))) { + if (!in_array($bodyType, ['raw', 'text', 'html'])) { $bodyType = 'full'; } diff --git a/lib/Github/Api/Repository/Commits.php b/lib/Github/Api/Repository/Commits.php index 3aaa460d6c2..8195e4baf0f 100644 --- a/lib/Github/Api/Repository/Commits.php +++ b/lib/Github/Api/Repository/Commits.php @@ -6,6 +6,7 @@ /** * @link http://developer.github.com/v3/repos/commits/ + * * @author Joseph Bielawski */ class Commits extends AbstractApi @@ -17,12 +18,12 @@ public function all($username, $repository, array $params) public function compare($username, $repository, $base, $head, $mediaType = null) { - $headers = array(); + $headers = []; if (null !== $mediaType) { $headers['Accept'] = $mediaType; } - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/compare/'.rawurlencode($base).'...'.rawurlencode($head), array(), $headers); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/compare/'.rawurlencode($base).'...'.rawurlencode($head), [], $headers); } public function show($username, $repository, $sha) diff --git a/lib/Github/Api/Repository/Contents.php b/lib/Github/Api/Repository/Contents.php index 6722bb3c7e0..4c8124fb114 100644 --- a/lib/Github/Api/Repository/Contents.php +++ b/lib/Github/Api/Repository/Contents.php @@ -4,13 +4,14 @@ use Github\Api\AbstractApi; use Github\Api\AcceptHeaderTrait; -use Github\Exception\InvalidArgumentException; use Github\Exception\ErrorException; +use Github\Exception\InvalidArgumentException; use Github\Exception\MissingArgumentException; use Github\Exception\TwoFactorAuthenticationRequiredException; /** * @link http://developer.github.com/v3/repos/contents/ + * * @author Joseph Bielawski */ class Contents extends AbstractApi @@ -21,13 +22,14 @@ class Contents extends AbstractApi * Configure the body type. * * @link https://developer.github.com/v3/repo/contents/#custom-media-types + * * @param string|null $bodyType * * @return self */ public function configure($bodyType = null) { - if (!in_array($bodyType, array('html', 'object'))) { + if (!in_array($bodyType, ['html', 'object'])) { $bodyType = 'raw'; } @@ -49,9 +51,9 @@ public function configure($bodyType = null) */ public function readme($username, $repository, $reference = null) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme', array( - 'ref' => $reference - )); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme', [ + 'ref' => $reference, + ]); } /** @@ -73,9 +75,9 @@ public function show($username, $repository, $path = null, $reference = null) $url .= '/'.rawurlencode($path); } - return $this->get($url, array( - 'ref' => $reference - )); + return $this->get($url, [ + 'ref' => $reference, + ]); } /** @@ -99,10 +101,10 @@ public function create($username, $repository, $path, $content, $message, $branc { $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path); - $parameters = array( + $parameters = [ 'content' => base64_encode($content), 'message' => $message, - ); + ]; if (null !== $branch) { $parameters['branch'] = $branch; @@ -110,7 +112,7 @@ public function create($username, $repository, $path, $content, $message, $branc if (null !== $committer) { if (!isset($committer['name'], $committer['email'])) { - throw new MissingArgumentException(array('name', 'email')); + throw new MissingArgumentException(['name', 'email']); } $parameters['committer'] = $committer; } @@ -137,9 +139,9 @@ public function exists($username, $repository, $path, $reference = null) } try { - $response = $this->head($url, array( - 'ref' => $reference - )); + $response = $this->head($url, [ + 'ref' => $reference, + ]); if ($response->getStatusCode() != 200) { return false; @@ -175,11 +177,11 @@ public function update($username, $repository, $path, $content, $message, $sha, { $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path); - $parameters = array( + $parameters = [ 'content' => base64_encode($content), 'message' => $message, 'sha' => $sha, - ); + ]; if (null !== $branch) { $parameters['branch'] = $branch; @@ -187,7 +189,7 @@ public function update($username, $repository, $path, $content, $message, $sha, if (null !== $committer) { if (!isset($committer['name'], $committer['email'])) { - throw new MissingArgumentException(array('name', 'email')); + throw new MissingArgumentException(['name', 'email']); } $parameters['committer'] = $committer; } @@ -216,10 +218,10 @@ public function rm($username, $repository, $path, $message, $sha, $branch = null { $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path); - $parameters = array( + $parameters = [ 'message' => $message, 'sha' => $sha, - ); + ]; if (null !== $branch) { $parameters['branch'] = $branch; @@ -227,7 +229,7 @@ public function rm($username, $repository, $path, $message, $sha, $branch = null if (null !== $committer) { if (!isset($committer['name'], $committer['email'])) { - throw new MissingArgumentException(array('name', 'email')); + throw new MissingArgumentException(['name', 'email']); } $parameters['committer'] = $committer; } @@ -249,7 +251,7 @@ public function rm($username, $repository, $path, $message, $sha, $branch = null */ public function archive($username, $repository, $format, $reference = null) { - if (!in_array($format, array('tarball', 'zipball'))) { + if (!in_array($format, ['tarball', 'zipball'])) { $format = 'tarball'; } diff --git a/lib/Github/Api/Repository/DeployKeys.php b/lib/Github/Api/Repository/DeployKeys.php index 2c25542dfc3..c6c8a2ce3b1 100644 --- a/lib/Github/Api/Repository/DeployKeys.php +++ b/lib/Github/Api/Repository/DeployKeys.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/repos/keys/ + * * @author Joseph Bielawski */ class DeployKeys extends AbstractApi @@ -24,7 +25,7 @@ public function show($username, $repository, $id) public function create($username, $repository, array $params) { if (!isset($params['title'], $params['key'])) { - throw new MissingArgumentException(array('title', 'key')); + throw new MissingArgumentException(['title', 'key']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys', $params); @@ -33,7 +34,7 @@ public function create($username, $repository, array $params) public function update($username, $repository, $id, array $params) { if (!isset($params['title'], $params['key'])) { - throw new MissingArgumentException(array('title', 'key')); + throw new MissingArgumentException(['title', 'key']); } return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys/'.rawurlencode($id), $params); diff --git a/lib/Github/Api/Repository/Downloads.php b/lib/Github/Api/Repository/Downloads.php index bfde5b3ea5e..ed4c42f27d4 100644 --- a/lib/Github/Api/Repository/Downloads.php +++ b/lib/Github/Api/Repository/Downloads.php @@ -6,6 +6,7 @@ /** * @link http://developer.github.com/v3/repos/downloads/ + * * @author Joseph Bielawski */ class Downloads extends AbstractApi diff --git a/lib/Github/Api/Repository/Forks.php b/lib/Github/Api/Repository/Forks.php index dbd4f3d3785..961dc64944a 100644 --- a/lib/Github/Api/Repository/Forks.php +++ b/lib/Github/Api/Repository/Forks.php @@ -6,20 +6,21 @@ /** * @link http://developer.github.com/v3/repos/forks/ + * * @author Joseph Bielawski */ class Forks extends AbstractApi { - public function all($username, $repository, array $params = array()) + public function all($username, $repository, array $params = []) { - if (isset($params['sort']) && !in_array($params['sort'], array('newest', 'oldest', 'watchers'))) { + if (isset($params['sort']) && !in_array($params['sort'], ['newest', 'oldest', 'watchers'])) { $params['sort'] = 'newest'; } - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/forks', array_merge(array('page' => 1), $params)); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/forks', array_merge(['page' => 1], $params)); } - public function create($username, $repository, array $params = array()) + public function create($username, $repository, array $params = []) { return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/forks', $params); } diff --git a/lib/Github/Api/Repository/Hooks.php b/lib/Github/Api/Repository/Hooks.php index a44a01a9f29..db67f40270e 100644 --- a/lib/Github/Api/Repository/Hooks.php +++ b/lib/Github/Api/Repository/Hooks.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/repos/hooks/ + * * @author Joseph Bielawski */ class Hooks extends AbstractApi @@ -24,7 +25,7 @@ public function show($username, $repository, $id) public function create($username, $repository, array $params) { if (!isset($params['name'], $params['config'])) { - throw new MissingArgumentException(array('name', 'config')); + throw new MissingArgumentException(['name', 'config']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks', $params); @@ -33,7 +34,7 @@ public function create($username, $repository, array $params) public function update($username, $repository, $id, array $params) { if (!isset($params['config'])) { - throw new MissingArgumentException(array('config')); + throw new MissingArgumentException(['config']); } return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id), $params); diff --git a/lib/Github/Api/Repository/Labels.php b/lib/Github/Api/Repository/Labels.php index 34535e8e1c9..7829e551e25 100644 --- a/lib/Github/Api/Repository/Labels.php +++ b/lib/Github/Api/Repository/Labels.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/issues/labels/ + * * @author Joseph Bielawski */ class Labels extends AbstractApi @@ -24,7 +25,7 @@ public function show($username, $repository, $label) public function create($username, $repository, array $params) { if (!isset($params['name'], $params['color'])) { - throw new MissingArgumentException(array('name', 'color')); + throw new MissingArgumentException(['name', 'color']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels', $params); @@ -33,7 +34,7 @@ public function create($username, $repository, array $params) public function update($username, $repository, $label, array $params) { if (!isset($params['name'], $params['color'])) { - throw new MissingArgumentException(array('name', 'color')); + throw new MissingArgumentException(['name', 'color']); } return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params); diff --git a/lib/Github/Api/Repository/Projects.php b/lib/Github/Api/Repository/Projects.php index 279a1d45f92..9db29f5578d 100644 --- a/lib/Github/Api/Repository/Projects.php +++ b/lib/Github/Api/Repository/Projects.php @@ -7,15 +7,15 @@ class Projects extends AbstractProjectApi { - public function all($username, $repository, array $params = array()) + public function all($username, $repository, array $params = []) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', array_merge(array('page' => 1), $params)); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', array_merge(['page' => 1], $params)); } public function create($username, $repository, array $params) { if (!isset($params['name'])) { - throw new MissingArgumentException(array('name')); + throw new MissingArgumentException(['name']); } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', $params); diff --git a/lib/Github/Api/Repository/Protection.php b/lib/Github/Api/Repository/Protection.php index 3c96e668933..73d1e6b5897 100644 --- a/lib/Github/Api/Repository/Protection.php +++ b/lib/Github/Api/Repository/Protection.php @@ -7,6 +7,7 @@ /** * @link https://developer.github.com/v3/repos/branches/ + * * @author Brandon Bloodgood */ class Protection extends AbstractApi @@ -21,15 +22,15 @@ public function configure() } /** - * Retrieves configured protection for the provided branch + * Retrieves configured protection for the provided branch. * * @link https://developer.github.com/v3/repos/branches/#get-branch-protection * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The branch protection information + * @return array The branch protection information */ public function show($username, $repository, $branch) { @@ -37,30 +38,30 @@ public function show($username, $repository, $branch) } /** - * Updates the repo's branch protection + * Updates the repo's branch protection. * * @link https://developer.github.com/v3/repos/branches/#update-branch-protection * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch protection information + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The branch protection information * - * @return array The updated branch protection information + * @return array The updated branch protection information */ - public function update($username, $repository, $branch, array $params = array()) + public function update($username, $repository, $branch, array $params = []) { return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection', $params); } /** - * Remove the repo's branch protection + * Remove the repo's branch protection. * * @link https://developer.github.com/v3/repos/branches/#remove-branch-protection * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch */ public function remove($username, $repository, $branch) { @@ -68,15 +69,15 @@ public function remove($username, $repository, $branch) } /** - * Get required status checks of protected branch + * Get required status checks of protected branch. * * @link https://developer.github.com/v3/repos/branches/#get-required-status-checks-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The required status checks information + * @return array The required status checks information */ public function showStatusChecks($username, $repository, $branch) { @@ -84,30 +85,30 @@ public function showStatusChecks($username, $repository, $branch) } /** - * Update required status checks of protected branch + * Update required status checks of protected branch. * * @link https://developer.github.com/v3/repos/branches/#update-required-status-checks-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks information + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The branch status checks information * - * @return array The updated branch status checks information + * @return array The updated branch status checks information */ - public function updateStatusChecks($username, $repository, $branch, array $params = array()) + public function updateStatusChecks($username, $repository, $branch, array $params = []) { return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks', $params); } /** - * Remove required status checks of protected branch + * Remove required status checks of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-required-status-checks-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch */ public function removeStatusChecks($username, $repository, $branch) { @@ -115,15 +116,15 @@ public function removeStatusChecks($username, $repository, $branch) } /** - * List required status checks contexts of protected branch + * List required status checks contexts of protected branch. * * @link https://developer.github.com/v3/repos/branches/#list-required-status-checks-contexts-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The required status checks contexts information + * @return array The required status checks contexts information */ public function showStatusChecksContexts($username, $repository, $branch) { @@ -131,66 +132,66 @@ public function showStatusChecksContexts($username, $repository, $branch) } /** - * Replace required status checks contexts of protected branch + * Replace required status checks contexts of protected branch. * * @link https://developer.github.com/v3/repos/branches/#replace-required-status-checks-contexts-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks contexts information + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The branch status checks contexts information * - * @return array The new branch status checks contexts information + * @return array The new branch status checks contexts information */ - public function replaceStatusChecksContexts($username, $repository, $branch, array $params = array()) + public function replaceStatusChecksContexts($username, $repository, $branch, array $params = []) { return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params); } /** - * Add required status checks contexts of protected branch + * Add required status checks contexts of protected branch. * * @link https://developer.github.com/v3/repos/branches/#add-required-status-checks-contexts-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks contexts information + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The branch status checks contexts information * - * @return array The updated branch status checks contexts information + * @return array The updated branch status checks contexts information */ - public function addStatusChecksContexts($username, $repository, $branch, array $params = array()) + public function addStatusChecksContexts($username, $repository, $branch, array $params = []) { return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params); } /** - * Remove required status checks contexts of protected branch + * Remove required status checks contexts of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-required-status-checks-contexts-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks contexts information + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The branch status checks contexts information * - * @return array The updated branch status checks contexts information + * @return array The updated branch status checks contexts information */ - public function removeStatusChecksContexts($username, $repository, $branch, array $params = array()) + public function removeStatusChecksContexts($username, $repository, $branch, array $params = []) { return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params); } /** - * Get pull request review enforcement of protected branch + * Get pull request review enforcement of protected branch. * * @link https://developer.github.com/v3/repos/branches/#get-pull-request-review-enforcement-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The pull request review enforcement information + * @return array The pull request review enforcement information */ public function showPullRequestReviewEnforcement($username, $repository, $branch) { @@ -198,30 +199,30 @@ public function showPullRequestReviewEnforcement($username, $repository, $branch } /** - * Update pull request review enforcement of protected branch + * Update pull request review enforcement of protected branch. * * @link https://developer.github.com/v3/repos/branches/#update-pull-request-review-enforcement-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks information + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The branch status checks information * - * @return array The updated branch status checks information + * @return array The updated branch status checks information */ - public function updatePullRequestReviewEnforcement($username, $repository, $branch, array $params = array()) + public function updatePullRequestReviewEnforcement($username, $repository, $branch, array $params = []) { return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews', $params); } /** - * Remove pull request review enforcement of protected branch + * Remove pull request review enforcement of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-pull-request-review-enforcement-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch */ public function removePullRequestReviewEnforcement($username, $repository, $branch) { @@ -229,15 +230,15 @@ public function removePullRequestReviewEnforcement($username, $repository, $bran } /** - * Get admin enforcement of protected branch + * Get admin enforcement of protected branch. * * @link https://developer.github.com/v3/repos/branches/#get-admin-enforcement-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The admin enforcement information + * @return array The admin enforcement information */ public function showAdminEnforcement($username, $repository, $branch) { @@ -245,15 +246,15 @@ public function showAdminEnforcement($username, $repository, $branch) } /** - * Add admin enforcement of protected branch + * Add admin enforcement of protected branch. * * @link https://developer.github.com/v3/repos/branches/#add-admin-enforcement-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The updated admin enforcement information + * @return array The updated admin enforcement information */ public function addAdminEnforcement($username, $repository, $branch) { @@ -261,13 +262,13 @@ public function addAdminEnforcement($username, $repository, $branch) } /** - * Remove admin enforcement of protected branch + * Remove admin enforcement of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch */ public function removeAdminEnforcement($username, $repository, $branch) { @@ -275,15 +276,15 @@ public function removeAdminEnforcement($username, $repository, $branch) } /** - * Get restrictions of protected branch + * Get restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#get-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The branch restrictions information + * @return array The branch restrictions information */ public function showRestrictions($username, $repository, $branch) { @@ -291,13 +292,13 @@ public function showRestrictions($username, $repository, $branch) } /** - * Remove restrictions of protected branch + * Remove restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch */ public function removeRestrictions($username, $repository, $branch) { @@ -305,15 +306,15 @@ public function removeRestrictions($username, $repository, $branch) } /** - * List team restrictions of protected branch + * List team restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#list-team-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The branch team restrictions information + * @return array The branch team restrictions information */ public function showTeamRestrictions($username, $repository, $branch) { @@ -321,66 +322,66 @@ public function showTeamRestrictions($username, $repository, $branch) } /** - * Replace team restrictions of protected branch + * Replace team restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#replace-team-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of team slugs with push access + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The list of team slugs with push access * - * @return array The new branch team restrictions information + * @return array The new branch team restrictions information */ - public function replaceTeamRestrictions($username, $repository, $branch, array $params = array()) + public function replaceTeamRestrictions($username, $repository, $branch, array $params = []) { return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params); } /** - * Add team restrictions of protected branch + * Add team restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#add-team-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of team slugs with push access + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The list of team slugs with push access * - * @return array The branch team restrictions information + * @return array The branch team restrictions information */ - public function addTeamRestrictions($username, $repository, $branch, array $params = array()) + public function addTeamRestrictions($username, $repository, $branch, array $params = []) { return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params); } /** - * Remove team restrictions of protected branch + * Remove team restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-team-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of team slugs with push access + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The list of team slugs with push access * - * @return array The updated branch team restrictions information + * @return array The updated branch team restrictions information */ - public function removeTeamRestrictions($username, $repository, $branch, array $params = array()) + public function removeTeamRestrictions($username, $repository, $branch, array $params = []) { return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params); } /** - * List user restrictions of protected branch + * List user restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#list-user-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch * - * @return array The branch user restrictions information + * @return array The branch user restrictions information */ public function showUserRestrictions($username, $repository, $branch) { @@ -388,52 +389,52 @@ public function showUserRestrictions($username, $repository, $branch) } /** - * Replace user restrictions of protected branch + * Replace user restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#replace-user-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of user logins with push access + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The list of user logins with push access * - * @return array The new branch user restrictions information + * @return array The new branch user restrictions information */ - public function replaceUserRestrictions($username, $repository, $branch, array $params = array()) + public function replaceUserRestrictions($username, $repository, $branch, array $params = []) { return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params); } /** - * Add user restrictions of protected branch + * Add user restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#add-user-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of user logins with push access + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The list of user logins with push access * - * @return array The branch user restrictions information + * @return array The branch user restrictions information */ - public function addUserRestrictions($username, $repository, $branch, array $params = array()) + public function addUserRestrictions($username, $repository, $branch, array $params = []) { return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params); } /** - * Remove user restrictions of protected branch + * Remove user restrictions of protected branch. * * @link https://developer.github.com/v3/repos/branches/#remove-user-restrictions-of-protected-branch * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of user logins with push access + * @param string $username The user who owns the repository + * @param string $repository The name of the repo + * @param string $branch The name of the branch + * @param array $params The list of user logins with push access * - * @return array The updated branch user restrictions information + * @return array The updated branch user restrictions information */ - public function removeUserRestrictions($username, $repository, $branch, array $params = array()) + public function removeUserRestrictions($username, $repository, $branch, array $params = []) { return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params); } diff --git a/lib/Github/Api/Repository/Releases.php b/lib/Github/Api/Repository/Releases.php index 4d59318fe07..73fd080b42f 100644 --- a/lib/Github/Api/Repository/Releases.php +++ b/lib/Github/Api/Repository/Releases.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/repos/releases/ + * * @author Matthew Simo * @author Evgeniy Guseletov */ diff --git a/lib/Github/Api/Repository/Stargazers.php b/lib/Github/Api/Repository/Stargazers.php index 5a298b717db..e71777741c7 100644 --- a/lib/Github/Api/Repository/Stargazers.php +++ b/lib/Github/Api/Repository/Stargazers.php @@ -7,6 +7,7 @@ /** * @link https://developer.github.com/v3/activity/starring/#list-stargazers + * * @author Nicolas Dupont * @author Tobias Nyholm */ @@ -15,7 +16,7 @@ class Stargazers extends AbstractApi use AcceptHeaderTrait; /** - * Configure the body type + * Configure the body type. * * @see https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps * diff --git a/lib/Github/Api/Repository/Statuses.php b/lib/Github/Api/Repository/Statuses.php index 728d1305f28..c62f4edd8b6 100644 --- a/lib/Github/Api/Repository/Statuses.php +++ b/lib/Github/Api/Repository/Statuses.php @@ -7,6 +7,7 @@ /** * @link http://developer.github.com/v3/repos/statuses/ + * * @author Joseph Bielawski */ class Statuses extends AbstractApi @@ -51,7 +52,7 @@ public function combined($username, $repository, $sha) * * @return array */ - public function create($username, $repository, $sha, array $params = array()) + public function create($username, $repository, $sha, array $params = []) { if (!isset($params['state'])) { throw new MissingArgumentException('state'); diff --git a/lib/Github/Api/Repository/Traffic.php b/lib/Github/Api/Repository/Traffic.php index 304dd899b0c..d5b550c8521 100644 --- a/lib/Github/Api/Repository/Traffic.php +++ b/lib/Github/Api/Repository/Traffic.php @@ -1,11 +1,12 @@ */ class Traffic extends AbstractApi @@ -22,6 +23,7 @@ public function referers($owner, $repository) { return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/popular/referrers'); } + /** * @link https://developer.github.com/v3/repos/traffic/#list-paths * @@ -34,6 +36,7 @@ public function paths($owner, $repository) { return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/popular/paths'); } + /** * @link https://developer.github.com/v3/repos/traffic/#views * @@ -47,6 +50,7 @@ public function views($owner, $repository, $per = 'day') { return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/views?per='.rawurlencode($per)); } + /** * @link https://developer.github.com/v3/repos/traffic/#clones * diff --git a/lib/Github/Api/Search.php b/lib/Github/Api/Search.php index 857ef9eb7b9..dfc4c24718b 100644 --- a/lib/Github/Api/Search.php +++ b/lib/Github/Api/Search.php @@ -6,6 +6,7 @@ * Implement the Search API. * * @link https://developer.github.com/v3/search/ + * * @author Greg Payne */ class Search extends AbstractApi @@ -25,7 +26,7 @@ class Search extends AbstractApi */ public function repositories($q, $sort = 'updated', $order = 'desc') { - return $this->get('/search/repositories', array('q' => $q, 'sort' => $sort, 'order' => $order)); + return $this->get('/search/repositories', ['q' => $q, 'sort' => $sort, 'order' => $order]); } /** @@ -41,7 +42,7 @@ public function repositories($q, $sort = 'updated', $order = 'desc') */ public function issues($q, $sort = 'updated', $order = 'desc') { - return $this->get('/search/issues', array('q' => $q, 'sort' => $sort, 'order' => $order)); + return $this->get('/search/issues', ['q' => $q, 'sort' => $sort, 'order' => $order]); } /** @@ -57,7 +58,7 @@ public function issues($q, $sort = 'updated', $order = 'desc') */ public function code($q, $sort = 'updated', $order = 'desc') { - return $this->get('/search/code', array('q' => $q, 'sort' => $sort, 'order' => $order)); + return $this->get('/search/code', ['q' => $q, 'sort' => $sort, 'order' => $order]); } /** @@ -73,7 +74,7 @@ public function code($q, $sort = 'updated', $order = 'desc') */ public function users($q, $sort = 'updated', $order = 'desc') { - return $this->get('/search/users', array('q' => $q, 'sort' => $sort, 'order' => $order)); + return $this->get('/search/users', ['q' => $q, 'sort' => $sort, 'order' => $order]); } /** @@ -92,6 +93,6 @@ public function commits($q, $sort = null, $order = 'desc') //This api is in preview mode, so set the correct accept-header $this->acceptHeaderValue = 'application/vnd.github.cloak-preview'; - return $this->get('/search/commits', array('q' => $q, 'sort' => $sort, 'order' => $order)); + return $this->get('/search/commits', ['q' => $q, 'sort' => $sort, 'order' => $order]); } } diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 570b3c0c719..2c3b807b9bf 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -6,6 +6,7 @@ * Searching users, getting user information. * * @link http://developer.github.com/v3/users/ + * * @author Joseph Bielawski * @author Thibault Duplessis */ @@ -15,7 +16,6 @@ class User extends AbstractApi * Search users by username. * * @deprecated This method is deprecated use the Search api instead. See https://developer.github.com/v3/search/legacy/#legacy-search-api-is-deprecated - * * @link http://developer.github.com/v3/search/#search-users * * @param string $keyword the keyword to search @@ -74,7 +74,7 @@ public function organizations($username) } /** - * Get user organizations + * Get user organizations. * * @link https://developer.github.com/v3/orgs/#list-your-organizations * @@ -84,14 +84,15 @@ public function orgs() { return $this->get('/user/orgs'); } + /** * Request the users that a specific user is following. * * @link http://developer.github.com/v3/users/followers/ * - * @param string $username the username - * @param array $parameters parameters for the query string - * @param array $requestHeaders additional headers to set in the request + * @param string $username the username + * @param array $parameters parameters for the query string + * @param array $requestHeaders additional headers to set in the request * * @return array list of followed users */ @@ -105,9 +106,9 @@ public function following($username, array $parameters = [], array $requestHeade * * @link http://developer.github.com/v3/users/followers/ * - * @param string $username the username - * @param array $parameters parameters for the query string - * @param array $requestHeaders additional headers to set in the request + * @param string $username the username + * @param array $parameters parameters for the query string + * @param array $requestHeaders additional headers to set in the request * * @return array list of following users */ @@ -145,12 +146,12 @@ public function watched($username) */ public function starred($username, $page = 1, $perPage = 30, $sort = 'created', $direction = 'desc') { - return $this->get('/users/'.rawurlencode($username).'/starred', array( + return $this->get('/users/'.rawurlencode($username).'/starred', [ 'page' => $page, 'per_page' => $perPage, 'sort' => $sort, 'direction' => $direction, - )); + ]); } /** @@ -241,6 +242,6 @@ public function keys($username) */ public function publicEvents($username) { - return $this->get('/users/'.rawurlencode($username) . '/events/public'); + return $this->get('/users/'.rawurlencode($username).'/events/public'); } } diff --git a/lib/Github/Client.php b/lib/Github/Client.php index ea22b512a6c..8e2ea275502 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -3,8 +3,8 @@ namespace Github; use Github\Api\ApiInterface; -use Github\Exception\InvalidArgumentException; use Github\Exception\BadMethodCallException; +use Github\Exception\InvalidArgumentException; use Github\HttpClient\Builder; use Github\HttpClient\Plugin\Authentication; use Github\HttpClient\Plugin\GithubExceptionThrower; @@ -129,9 +129,9 @@ public function __construct(Builder $httpClientBuilder = null, $apiVersion = nul $builder->addPlugin(new Plugin\HistoryPlugin($this->responseHistory)); $builder->addPlugin(new Plugin\RedirectPlugin()); $builder->addPlugin(new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri('https://api.github.com'))); - $builder->addPlugin(new Plugin\HeaderDefaultsPlugin(array( + $builder->addPlugin(new Plugin\HeaderDefaultsPlugin([ 'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)', - ))); + ])); $this->apiVersion = $apiVersion ?: 'v3'; $builder->addHeaderValue('Accept', sprintf('application/vnd.github.%s+json', $this->apiVersion)); @@ -317,7 +317,7 @@ public function authenticate($tokenOrLogin, $password = null, $authMethod = null throw new InvalidArgumentException('You need to specify authentication method!'); } - if (null === $authMethod && in_array($password, array(self::AUTH_URL_TOKEN, self::AUTH_URL_CLIENT_ID, self::AUTH_HTTP_PASSWORD, self::AUTH_HTTP_TOKEN, self::AUTH_JWT))) { + if (null === $authMethod && in_array($password, [self::AUTH_URL_TOKEN, self::AUTH_URL_CLIENT_ID, self::AUTH_HTTP_PASSWORD, self::AUTH_HTTP_TOKEN, self::AUTH_JWT])) { $authMethod = $password; $password = null; } diff --git a/lib/Github/Exception/MissingArgumentException.php b/lib/Github/Exception/MissingArgumentException.php index 4a7e372e97c..96e217acde7 100644 --- a/lib/Github/Exception/MissingArgumentException.php +++ b/lib/Github/Exception/MissingArgumentException.php @@ -12,7 +12,7 @@ class MissingArgumentException extends ErrorException public function __construct($required, $code = 0, $previous = null) { if (is_string($required)) { - $required = array($required); + $required = [$required]; } parent::__construct(sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code, $previous); diff --git a/lib/Github/HttpClient/Builder.php b/lib/Github/HttpClient/Builder.php index 218749b43ae..fe9499b29e8 100644 --- a/lib/Github/HttpClient/Builder.php +++ b/lib/Github/HttpClient/Builder.php @@ -4,6 +4,7 @@ use Http\Client\Common\HttpMethodsClient; use Http\Client\Common\Plugin; +use Http\Client\Common\Plugin\Cache\Generator\HeaderCacheKeyGenerator; use Http\Client\Common\PluginClient; use Http\Client\HttpClient; use Http\Discovery\HttpClientDiscovery; @@ -13,7 +14,6 @@ use Http\Message\RequestFactory; use Http\Message\StreamFactory; use Psr\Cache\CacheItemPoolInterface; -use Http\Client\Common\Plugin\Cache\Generator\HeaderCacheKeyGenerator; /** * A builder that builds the API client. @@ -167,7 +167,7 @@ public function addHeaderValue($header, $headerValue) if (!isset($this->headers[$header])) { $this->headers[$header] = $headerValue; } else { - $this->headers[$header] = array_merge((array)$this->headers[$header], array($headerValue)); + $this->headers[$header] = array_merge((array) $this->headers[$header], [$headerValue]); } $this->removePlugin(Plugin\HeaderAppendPlugin::class); diff --git a/lib/Github/HttpClient/Message/ResponseMediator.php b/lib/Github/HttpClient/Message/ResponseMediator.php index c841d21269d..6b944165f9f 100644 --- a/lib/Github/HttpClient/Message/ResponseMediator.php +++ b/lib/Github/HttpClient/Message/ResponseMediator.php @@ -33,11 +33,11 @@ public static function getContent(ResponseInterface $response) public static function getPagination(ResponseInterface $response) { if (!$response->hasHeader('Link')) { - return null; + return; } $header = self::getHeader($response, 'Link'); - $pagination = array(); + $pagination = []; foreach (explode(',', $header) as $link) { preg_match('/<(.*)>; rel="(.*)"/i', trim($link, ','), $match); @@ -61,14 +61,15 @@ public static function getApiLimit(ResponseInterface $response) if (null !== $remainingCalls && 1 > $remainingCalls) { throw new ApiLimitExceedException($remainingCalls); } - + return $remainingCalls; } - + /** - * Get the value for a single header + * Get the value for a single header. + * * @param ResponseInterface $response - * @param string $name + * @param string $name * * @return string|null */ diff --git a/lib/Github/HttpClient/Plugin/Authentication.php b/lib/Github/HttpClient/Plugin/Authentication.php index 9601eb12c67..920d65722c6 100644 --- a/lib/Github/HttpClient/Plugin/Authentication.php +++ b/lib/Github/HttpClient/Plugin/Authentication.php @@ -18,7 +18,7 @@ class Authentication implements Plugin private $password; private $method; - public function __construct($tokenOrLogin, $password = null, $method) + public function __construct($tokenOrLogin, $password, $method) { $this->tokenOrLogin = $tokenOrLogin; $this->password = $password; @@ -46,10 +46,10 @@ public function handleRequest(RequestInterface $request, callable $next, callabl $uri = $request->getUri(); $query = $uri->getQuery(); - $parameters = array( + $parameters = [ 'client_id' => $this->tokenOrLogin, 'client_secret' => $this->password, - ); + ]; $query .= empty($query) ? '' : '&'; $query .= utf8_encode(http_build_query($parameters, '', '&')); @@ -62,7 +62,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl $uri = $request->getUri(); $query = $uri->getQuery(); - $parameters = array('access_token' => $this->tokenOrLogin); + $parameters = ['access_token' => $this->tokenOrLogin]; $query .= empty($query) ? '' : '&'; $query .= utf8_encode(http_build_query($parameters, '', '&')); diff --git a/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php b/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php index cc9581e9c61..7d46fe9c2e5 100644 --- a/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php +++ b/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php @@ -2,14 +2,14 @@ namespace Github\HttpClient\Plugin; -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Github\Exception\TwoFactorAuthenticationRequiredException; -use Github\HttpClient\Message\ResponseMediator; use Github\Exception\ApiLimitExceedException; use Github\Exception\ErrorException; use Github\Exception\RuntimeException; +use Github\Exception\TwoFactorAuthenticationRequiredException; use Github\Exception\ValidationFailedException; +use Github\HttpClient\Message\ResponseMediator; +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; /** @@ -33,7 +33,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl if (null != $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) { $limit = ResponseMediator::getHeader($response, 'X-RateLimit-Limit'); $reset = ResponseMediator::getHeader($response, 'X-RateLimit-Reset'); - + throw new ApiLimitExceedException($limit, $reset); } @@ -50,7 +50,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl if (400 == $response->getStatusCode()) { throw new ErrorException($content['message'], 400); } elseif (422 == $response->getStatusCode() && isset($content['errors'])) { - $errors = array(); + $errors = []; foreach ($content['errors'] as $error) { switch ($error['code']) { case 'missing': diff --git a/lib/Github/ResultPager.php b/lib/Github/ResultPager.php index b63ffd676ec..7e872d85925 100644 --- a/lib/Github/ResultPager.php +++ b/lib/Github/ResultPager.php @@ -57,7 +57,7 @@ public function getPagination() /** * {@inheritdoc} */ - public function fetch(ApiInterface $api, $method, array $parameters = array()) + public function fetch(ApiInterface $api, $method, array $parameters = []) { $result = $this->callApi($api, $method, $parameters); $this->postFetch(); @@ -68,7 +68,7 @@ public function fetch(ApiInterface $api, $method, array $parameters = array()) /** * {@inheritdoc} */ - public function fetchAll(ApiInterface $api, $method, array $parameters = array()) + public function fetchAll(ApiInterface $api, $method, array $parameters = []) { $isSearch = $api instanceof Search; @@ -187,6 +187,6 @@ protected function get($key) */ protected function callApi(ApiInterface $api, $method, array $parameters) { - return call_user_func_array(array($api, $method), $parameters); + return call_user_func_array([$api, $method], $parameters); } } diff --git a/lib/Github/ResultPagerInterface.php b/lib/Github/ResultPagerInterface.php index 1130e8ec409..c5add903648 100644 --- a/lib/Github/ResultPagerInterface.php +++ b/lib/Github/ResultPagerInterface.php @@ -26,7 +26,7 @@ public function getPagination(); * * @return array returns the result of the Api::$method() call */ - public function fetch(ApiInterface $api, $method, array $parameters = array()); + public function fetch(ApiInterface $api, $method, array $parameters = []); /** * Fetch all results (pages) from an api call. @@ -39,7 +39,7 @@ public function fetch(ApiInterface $api, $method, array $parameters = array()); * * @return array returns a merge of the results of the Api::$method() call */ - public function fetchAll(ApiInterface $api, $method, array $parameters = array()); + public function fetchAll(ApiInterface $api, $method, array $parameters = []); /** * Method that performs the actual work to refresh the pagination property. diff --git a/test/Github/Tests/Api/AbstractApiTest.php b/test/Github/Tests/Api/AbstractApiTest.php index 1c66a693ac7..e4ce3ae9171 100644 --- a/test/Github/Tests/Api/AbstractApiTest.php +++ b/test/Github/Tests/Api/AbstractApiTest.php @@ -12,16 +12,16 @@ class AbstractApiTest extends TestCase */ public function shouldPassGETRequestToClient() { - $expectedArray = array('value'); + $expectedArray = ['value']; - $httpClient = $this->getHttpMethodsMock(array('get')); + $httpClient = $this->getHttpMethodsMock(['get']); $httpClient ->expects($this->any()) ->method('get') - ->with('/path?param1=param1value', array('header1' => 'header1value')) + ->with('/path?param1=param1value', ['header1' => 'header1value']) ->will($this->returnValue($this->getPSR7Response($expectedArray))); $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(array('getHttpClient')) + ->setMethods(['getHttpClient']) ->getMock(); $client->expects($this->any()) ->method('getHttpClient') @@ -40,17 +40,17 @@ public function shouldPassGETRequestToClient() */ public function shouldPassPOSTRequestToClient() { - $expectedArray = array('value'); + $expectedArray = ['value']; - $httpClient = $this->getHttpMethodsMock(array('post')); + $httpClient = $this->getHttpMethodsMock(['post']); $httpClient ->expects($this->once()) ->method('post') - ->with('/path', array('option1' => 'option1value'), json_encode(array('param1' => 'param1value'))) + ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) ->will($this->returnValue($this->getPSR7Response($expectedArray))); $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(array('getHttpClient')) + ->setMethods(['getHttpClient']) ->getMock(); $client->expects($this->any()) ->method('getHttpClient') @@ -68,17 +68,17 @@ public function shouldPassPOSTRequestToClient() */ public function shouldPassPATCHRequestToClient() { - $expectedArray = array('value'); + $expectedArray = ['value']; - $httpClient = $this->getHttpMethodsMock(array('patch')); + $httpClient = $this->getHttpMethodsMock(['patch']); $httpClient ->expects($this->once()) ->method('patch') - ->with('/path', array('option1' => 'option1value'), json_encode(array('param1' => 'param1value'))) + ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) ->will($this->returnValue($this->getPSR7Response($expectedArray))); $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(array('getHttpClient')) + ->setMethods(['getHttpClient']) ->getMock(); $client->expects($this->any()) ->method('getHttpClient') @@ -96,17 +96,17 @@ public function shouldPassPATCHRequestToClient() */ public function shouldPassPUTRequestToClient() { - $expectedArray = array('value'); + $expectedArray = ['value']; - $httpClient = $this->getHttpMethodsMock(array('put')); + $httpClient = $this->getHttpMethodsMock(['put']); $httpClient ->expects($this->once()) ->method('put') - ->with('/path', array('option1' => 'option1value'), json_encode(array('param1' => 'param1value'))) + ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) ->will($this->returnValue($this->getPSR7Response($expectedArray))); $client = $this->getMockBuilder('Github\Client') - ->setMethods(array('getHttpClient')) + ->setMethods(['getHttpClient']) ->getMock(); $client->expects($this->any()) ->method('getHttpClient') @@ -124,23 +124,22 @@ public function shouldPassPUTRequestToClient() */ public function shouldPassDELETERequestToClient() { - $expectedArray = array('value'); + $expectedArray = ['value']; - $httpClient = $this->getHttpMethodsMock(array('delete')); + $httpClient = $this->getHttpMethodsMock(['delete']); $httpClient ->expects($this->once()) ->method('delete') - ->with('/path', array('option1' => 'option1value'), json_encode(array('param1' => 'param1value'))) + ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) ->will($this->returnValue($this->getPSR7Response($expectedArray))); $client = $this->getMockBuilder('Github\Client') - ->setMethods(array('getHttpClient')) + ->setMethods(['getHttpClient']) ->getMock(); $client->expects($this->any()) ->method('getHttpClient') ->willReturn($httpClient); - $api = $this->getAbstractApiObject($client); $actual = $this->getMethod($api, 'delete') ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]); @@ -153,17 +152,17 @@ public function shouldPassDELETERequestToClient() */ public function shouldNotPassEmptyRefToClient() { - $expectedArray = array('value'); + $expectedArray = ['value']; - $httpClient = $this->getHttpMethodsMock(array('get')); + $httpClient = $this->getHttpMethodsMock(['get']); $httpClient ->expects($this->any()) ->method('get') - ->with('/path', array()) + ->with('/path', []) ->will($this->returnValue($this->getPSR7Response($expectedArray))); $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(array('getHttpClient')) + ->setMethods(['getHttpClient']) ->getMock(); $client->expects($this->any()) ->method('getHttpClient') @@ -177,6 +176,7 @@ public function shouldNotPassEmptyRefToClient() /** * @param $client + * * @return \PHPUnit_Framework_MockObject_MockObject */ protected function getAbstractApiObject($client) @@ -204,14 +204,15 @@ protected function getClientMock() } /** - * Return a HttpMethods client mock + * Return a HttpMethods client mock. * * @param array $methods + * * @return \Http\Client\Common\HttpMethodsClient */ - protected function getHttpMethodsMock(array $methods = array()) + protected function getHttpMethodsMock(array $methods = []) { - $methods = array_merge(array('sendRequest'), $methods); + $methods = array_merge(['sendRequest'], $methods); $mock = $this->getMockBuilder(\Http\Client\Common\HttpMethodsClient::class) ->disableOriginalConstructor() ->setMethods($methods) @@ -222,13 +223,14 @@ protected function getHttpMethodsMock(array $methods = array()) return $mock; } + /** * @return \Http\Client\HttpClient */ protected function getHttpClientMock() { $mock = $this->getMockBuilder(\Http\Client\HttpClient::class) - ->setMethods(array('sendRequest')) + ->setMethods(['sendRequest']) ->getMock(); $mock ->expects($this->any()) @@ -246,7 +248,7 @@ private function getPSR7Response($expectedArray) { return new Response( 200, - array('Content-Type' => 'application/json'), + ['Content-Type' => 'application/json'], \GuzzleHttp\Psr7\stream_for(json_encode($expectedArray)) ); } diff --git a/test/Github/Tests/Api/AppTest.php b/test/Github/Tests/Api/AppTest.php index 51679175725..75e028dbfcf 100644 --- a/test/Github/Tests/Api/AppTest.php +++ b/test/Github/Tests/Api/AppTest.php @@ -62,7 +62,6 @@ public function shouldRemoveRepositoryToInstallation() $api->removeRepository('1234', '5678'); } - /** * @return string */ diff --git a/test/Github/Tests/Api/AuthorizationsTest.php b/test/Github/Tests/Api/AuthorizationsTest.php index 62ca0222c0c..a8170827484 100644 --- a/test/Github/Tests/Api/AuthorizationsTest.php +++ b/test/Github/Tests/Api/AuthorizationsTest.php @@ -9,7 +9,7 @@ class AuthorizationsTest extends TestCase */ public function shouldGetAllAuthorizations() { - $expectedArray = array(array('id' => '123')); + $expectedArray = [['id' => '123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -26,7 +26,7 @@ public function shouldGetAllAuthorizations() public function shouldShowAuthorization() { $id = 123; - $expectedArray = array('id' => $id); + $expectedArray = ['id' => $id]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -42,9 +42,9 @@ public function shouldShowAuthorization() */ public function shouldAuthorization() { - $input = array( + $input = [ 'note' => '', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,9 +60,9 @@ public function shouldAuthorization() public function shouldUpdateAuthorization() { $id = 123; - $input = array( + $input = [ 'note' => '', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -93,7 +93,7 @@ public function shouldCheckAuthorization() { $id = 123; $token = 'abc'; - $expectedArray = array('id' => $id); + $expectedArray = ['id' => $id]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php b/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php index bb03fa70339..7b1abd37923 100644 --- a/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php +++ b/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php @@ -9,7 +9,7 @@ class DeployKeysTest extends TestCase */ public function shouldShowKey() { - $expectedValue = array('id' => '12', 'key' => 'ssh-rsa ...'); + $expectedValue = ['id' => '12', 'key' => 'ssh-rsa ...']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,7 +25,7 @@ public function shouldShowKey() */ public function shouldGetKeys() { - $expectedValue = array(array('id' => '12', 'key' => 'ssh-rsa ...')); + $expectedValue = [['id' => '12', 'key' => 'ssh-rsa ...']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -41,8 +41,8 @@ public function shouldGetKeys() */ public function shouldCreateKey() { - $expectedValue = array('id' => '123', 'key' => 'ssh-rsa ...'); - $data = array('title' => 'my key', 'key' => 'ssh-rsa ...'); + $expectedValue = ['id' => '123', 'key' => 'ssh-rsa ...']; + $data = ['title' => 'my key', 'key' => 'ssh-rsa ...']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -59,7 +59,7 @@ public function shouldCreateKey() */ public function shouldNotCreateKeyWithoutTitleParam() { - $data = array('key' => 'ssh-rsa ...'); + $data = ['key' => 'ssh-rsa ...']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -74,7 +74,7 @@ public function shouldNotCreateKeyWithoutTitleParam() */ public function shouldNotCreateKeyWithoutKeyParam() { - $data = array('title' => 'my key'); + $data = ['title' => 'my key']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -88,7 +88,7 @@ public function shouldNotCreateKeyWithoutKeyParam() */ public function shouldRemoveKey() { - $expectedValue = array('some value'); + $expectedValue = ['some value']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUser/EmailsTest.php b/test/Github/Tests/Api/CurrentUser/EmailsTest.php index cd15eb2c2ee..2cc4c746712 100644 --- a/test/Github/Tests/Api/CurrentUser/EmailsTest.php +++ b/test/Github/Tests/Api/CurrentUser/EmailsTest.php @@ -9,7 +9,7 @@ class EmailsTest extends TestCase */ public function shouldGetEmails() { - $expectedValue = array(array('email@example.com')); + $expectedValue = [['email@example.com']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,12 +25,12 @@ public function shouldGetEmails() */ public function shouldRemoveEmail() { - $expectedValue = array('some value'); + $expectedValue = ['some value']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('delete') - ->with('/user/emails', array('email@example.com')) + ->with('/user/emails', ['email@example.com']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->remove('email@example.com')); @@ -41,15 +41,15 @@ public function shouldRemoveEmail() */ public function shouldRemoveEmails() { - $expectedValue = array('some value'); + $expectedValue = ['some value']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('delete') - ->with('/user/emails', array('email@example.com', 'email2@example.com')) + ->with('/user/emails', ['email@example.com', 'email2@example.com']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->remove(array('email@example.com', 'email2@example.com'))); + $this->assertEquals($expectedValue, $api->remove(['email@example.com', 'email2@example.com'])); } /** @@ -62,7 +62,7 @@ public function shouldNotRemoveEmailsWhenAreNotPass() $api->expects($this->any()) ->method('delete'); - $api->remove(array()); + $api->remove([]); } /** @@ -70,12 +70,12 @@ public function shouldNotRemoveEmailsWhenAreNotPass() */ public function shouldAddEmail() { - $expectedValue = array('some value'); + $expectedValue = ['some value']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/user/emails', array('email@example.com')) + ->with('/user/emails', ['email@example.com']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->add('email@example.com')); @@ -86,15 +86,15 @@ public function shouldAddEmail() */ public function shouldAddEmails() { - $expectedValue = array('some value'); + $expectedValue = ['some value']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/user/emails', array('email@example.com', 'email2@example.com')) + ->with('/user/emails', ['email@example.com', 'email2@example.com']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->add(array('email@example.com', 'email2@example.com'))); + $this->assertEquals($expectedValue, $api->add(['email@example.com', 'email2@example.com'])); } /** @@ -107,7 +107,7 @@ public function shouldNotAddEmailsWhenAreNotPass() $api->expects($this->any()) ->method('post'); - $api->add(array()); + $api->add([]); } /** @@ -115,7 +115,7 @@ public function shouldNotAddEmailsWhenAreNotPass() */ public function shouldToggleVisibility() { - $expectedValue = array('primary email info'); + $expectedValue = ['primary email info']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUser/FollowersTest.php b/test/Github/Tests/Api/CurrentUser/FollowersTest.php index 6ea021f201f..0ad32693008 100644 --- a/test/Github/Tests/Api/CurrentUser/FollowersTest.php +++ b/test/Github/Tests/Api/CurrentUser/FollowersTest.php @@ -9,10 +9,10 @@ class FollowersTest extends TestCase */ public function shouldGetFollowers() { - $expectedValue = array( - array('login' => 'l3l0'), - array('login' => 'cordoval') - ); + $expectedValue = [ + ['login' => 'l3l0'], + ['login' => 'cordoval'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUser/MembershipsTest.php b/test/Github/Tests/Api/CurrentUser/MembershipsTest.php index 60edaa07e16..858e018cb42 100644 --- a/test/Github/Tests/Api/CurrentUser/MembershipsTest.php +++ b/test/Github/Tests/Api/CurrentUser/MembershipsTest.php @@ -9,28 +9,28 @@ class MembershipsTest extends TestCase */ public function shouldGetMemberships() { - $expectedValue = array( - array( - 'organization' => array( + $expectedValue = [ + [ + 'organization' => [ 'login' => 'octocat', 'id' => 1, - ), - 'user' => array( + ], + 'user' => [ 'login' => 'defunkt', 'id' => 3, - ), - ), - array( - 'organization' => array( + ], + ], + [ + 'organization' => [ 'login' => 'invitocat', 'id' => 2, - ), - 'user' => array( + ], + 'user' => [ 'login' => 'defunkt', 'id' => 3, - ), - ), - ); + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -46,16 +46,16 @@ public function shouldGetMemberships() */ public function shouldGetMembershipsForOrganization() { - $expectedValue = array( - 'organization' => array( + $expectedValue = [ + 'organization' => [ 'login' => 'invitocat', 'id' => 2, - ), - 'user' => array( + ], + 'user' => [ 'login' => 'defunkt', 'id' => 3, - ), - ); + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -71,9 +71,9 @@ public function shouldGetMembershipsForOrganization() */ public function shouldEditMembershipsForOrganization() { - $expectedValue = array( + $expectedValue = [ 'state' => 'active', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUser/StarringTest.php b/test/Github/Tests/Api/CurrentUser/StarringTest.php index 3cf8b7dae02..75c272b0008 100644 --- a/test/Github/Tests/Api/CurrentUser/StarringTest.php +++ b/test/Github/Tests/Api/CurrentUser/StarringTest.php @@ -9,10 +9,10 @@ class StarringTest extends TestCase */ public function shouldGetStarred() { - $expectedValue = array( - array('name' => 'l3l0/test'), - array('name' => 'cordoval/test') - ); + $expectedValue = [ + ['name' => 'l3l0/test'], + ['name' => 'cordoval/test'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUser/WatchersTest.php b/test/Github/Tests/Api/CurrentUser/WatchersTest.php index 79f8c9fee83..0347d02f3c0 100644 --- a/test/Github/Tests/Api/CurrentUser/WatchersTest.php +++ b/test/Github/Tests/Api/CurrentUser/WatchersTest.php @@ -9,10 +9,10 @@ class WatchersTest extends TestCase */ public function shouldGetWatchers() { - $expectedValue = array( - array('name' => 'l3l0/test'), - array('name' => 'cordoval/test') - ); + $expectedValue = [ + ['name' => 'l3l0/test'], + ['name' => 'cordoval/test'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/CurrentUserTest.php b/test/Github/Tests/Api/CurrentUserTest.php index b93d94ed1bd..ace2301b650 100644 --- a/test/Github/Tests/Api/CurrentUserTest.php +++ b/test/Github/Tests/Api/CurrentUserTest.php @@ -9,7 +9,7 @@ class CurrentUserTest extends TestCase */ public function shouldShowCurrentUser() { - $expectedArray = array('id' => 1, 'username' => 'l3l0'); + $expectedArray = ['id' => 1, 'username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,15 +25,15 @@ public function shouldShowCurrentUser() */ public function shouldUpdateCurrentUserData() { - $expectedArray = array('id' => 1, 'username' => 'l3l0'); + $expectedArray = ['id' => 1, 'username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/user', array('value' => 'toChange')) + ->with('/user', ['value' => 'toChange']) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->update(array('value' => 'toChange'))); + $this->assertEquals($expectedArray, $api->update(['value' => 'toChange'])); } /** @@ -41,12 +41,12 @@ public function shouldUpdateCurrentUserData() */ public function shouldGetUserFollowers() { - $expectedArray = array(array('id' => 1, 'username' => 'l3l0test')); + $expectedArray = [['id' => 1, 'username' => 'l3l0test']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/user/followers', array('page' => 1)) + ->with('/user/followers', ['page' => 1]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->followers(1)); @@ -57,15 +57,15 @@ public function shouldGetUserFollowers() */ public function shouldGetIssuesAssignedToUser() { - $expectedArray = array(array('id' => 1, 'title' => 'issues')); + $expectedArray = [['id' => 1, 'title' => 'issues']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/issues', array('page' => 1, 'some' => 'param')) + ->with('/issues', ['page' => 1, 'some' => 'param']) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->issues(array('some' => 'param'))); + $this->assertEquals($expectedArray, $api->issues(['some' => 'param'])); } /** @@ -73,12 +73,12 @@ public function shouldGetIssuesAssignedToUser() */ public function shouldGetWatchedRepositories() { - $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/user/watched', array('page' => 1)) + ->with('/user/watched', ['page' => 1]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->watched(1)); @@ -105,12 +105,12 @@ public function shouldGetInstallations() */ public function shouldGetRepositoriesByInstallation() { - $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/user/installations/42/repositories', array('page' => 1)) + ->with('/user/installations/42/repositories', ['page' => 1]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->repositoriesByInstallation(42)); diff --git a/test/Github/Tests/Api/DeploymentTest.php b/test/Github/Tests/Api/DeploymentTest.php index 0aab01db155..3c9a397855b 100644 --- a/test/Github/Tests/Api/DeploymentTest.php +++ b/test/Github/Tests/Api/DeploymentTest.php @@ -10,7 +10,7 @@ class DeploymentTest extends TestCase public function shouldCreateDeployment() { $api = $this->getApiMock(); - $deploymentData = array('ref' => 'fd6a5f9e5a430dddae8d6a8ea378f913d3a766f9'); + $deploymentData = ['ref' => 'fd6a5f9e5a430dddae8d6a8ea378f913d3a766f9']; $api->expects($this->once()) ->method('post') ->with('/repos/KnpLabs/php-github-api/deployments', $deploymentData); @@ -37,7 +37,7 @@ public function shouldGetAllDeployments() public function shouldGetAllDeploymentsWithFilterParameters() { $api = $this->getApiMock(); - $filterData = array('foo' => 'bar', 'bar' => 'foo'); + $filterData = ['foo' => 'bar', 'bar' => 'foo']; $api->expects($this->once()) ->method('get') @@ -51,7 +51,7 @@ public function shouldGetAllDeploymentsWithFilterParameters() */ public function shouldShowProject() { - $expectedValue = array('id' => 123, 'ref' => 'master'); + $expectedValue = ['id' => 123, 'ref' => 'master']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -68,7 +68,7 @@ public function shouldShowProject() public function shouldCreateStatusUpdate() { $api = $this->getApiMock(); - $statusData = array('state' => 'pending', 'description' => 'waiting to start'); + $statusData = ['state' => 'pending', 'description' => 'waiting to start']; $api->expects($this->once()) ->method('post') @@ -84,7 +84,7 @@ public function shouldCreateStatusUpdate() public function shouldRejectStatusUpdateWithoutStateField() { $api = $this->getApiMock(); - $statusData = array('description' => 'waiting to start'); + $statusData = ['description' => 'waiting to start']; $api->updateStatus('KnpLabs', 'php-github-api', 1, $statusData); } diff --git a/test/Github/Tests/Api/Enterprise/LicenseTest.php b/test/Github/Tests/Api/Enterprise/LicenseTest.php index 798a362752f..b8d988a6146 100644 --- a/test/Github/Tests/Api/Enterprise/LicenseTest.php +++ b/test/Github/Tests/Api/Enterprise/LicenseTest.php @@ -11,14 +11,14 @@ class LicenseTest extends TestCase */ public function shouldShowLicenseInformation() { - $expectedArray = array( + $expectedArray = [ 'seats' => 1400, 'seats_used' => 1316, 'seats_available' => 84, 'kind' => 'standard', 'days_until_expiration' => 365, - 'expire_at' => '2016/02/06 12:41:52 -0600' - ); + 'expire_at' => '2016/02/06 12:41:52 -0600', + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php b/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php index df1b64ce743..fd1d2064f66 100644 --- a/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php +++ b/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php @@ -20,7 +20,7 @@ public function shouldShowConfigData() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/setup/api/configcheck', array('license_md5' => $this->getLicenseHash())) + ->with('/setup/api/configcheck', ['license_md5' => $this->getLicenseHash()]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->configcheck($this->getLicenseHash())); @@ -58,7 +58,7 @@ public function shouldShowSettingsData() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/setup/api/settings', array('license_md5' => $this->getLicenseHash())) + ->with('/setup/api/settings', ['license_md5' => $this->getLicenseHash()]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->settings($this->getLicenseHash())); @@ -77,7 +77,7 @@ public function shouldShowMaintenanceStatus() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/setup/api/maintenance', array('license_md5' => $this->getLicenseHash())) + ->with('/setup/api/maintenance', ['license_md5' => $this->getLicenseHash()]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->maintenance($this->getLicenseHash())); @@ -97,7 +97,7 @@ public function shouldShowAuthorizedKeys() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/setup/api/settings/authorized-keys', array('license_md5' => $this->getLicenseHash())) + ->with('/setup/api/settings/authorized-keys', ['license_md5' => $this->getLicenseHash()]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->keys($this->getLicenseHash())); } diff --git a/test/Github/Tests/Api/Enterprise/StatsTest.php b/test/Github/Tests/Api/Enterprise/StatsTest.php index fe902257e17..d3a8a89883a 100644 --- a/test/Github/Tests/Api/Enterprise/StatsTest.php +++ b/test/Github/Tests/Api/Enterprise/StatsTest.php @@ -36,7 +36,7 @@ public function shouldShowStatsByType($type) ->with(sprintf('/enterprise/stats/%s', $type)) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, call_user_func(array($api, $type))); + $this->assertEquals($expectedArray, call_user_func([$api, $type])); } /** @@ -44,19 +44,19 @@ public function shouldShowStatsByType($type) */ public function getTypes() { - return array( - array('issues'), - array('hooks'), - array('milestones'), - array('orgs'), - array('comments'), - array('pages'), - array('users'), - array('gists'), - array('pulls'), - array('repos'), - array('all') - ); + return [ + ['issues'], + ['hooks'], + ['milestones'], + ['orgs'], + ['comments'], + ['pages'], + ['users'], + ['gists'], + ['pulls'], + ['repos'], + ['all'], + ]; } /** diff --git a/test/Github/Tests/Api/Enterprise/UserAdminTest.php b/test/Github/Tests/Api/Enterprise/UserAdminTest.php index d9eddf8aa08..37b97a43447 100644 --- a/test/Github/Tests/Api/Enterprise/UserAdminTest.php +++ b/test/Github/Tests/Api/Enterprise/UserAdminTest.php @@ -1,4 +1,5 @@ getApiMock(); $api->expects($this->once()) @@ -25,7 +26,7 @@ public function shouldSuspendUser() */ public function shouldUnsuspendUser() { - $expectedArray = array(); + $expectedArray = []; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Gist/CommentsTest.php b/test/Github/Tests/Api/Gist/CommentsTest.php index 3a7fe8febd5..9f0b88fda9e 100644 --- a/test/Github/Tests/Api/Gist/CommentsTest.php +++ b/test/Github/Tests/Api/Gist/CommentsTest.php @@ -11,7 +11,7 @@ class CommentsTest extends TestCase */ public function shouldGetAllGistComments() { - $expectedValue = array(array('comment1data'), array('comment2data')); + $expectedValue = [['comment1data'], ['comment2data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllGistComments() */ public function shouldShowGistComment() { - $expectedValue = array('comment1'); + $expectedValue = ['comment1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,12 +43,12 @@ public function shouldShowGistComment() */ public function shouldCreateGistComment() { - $expectedValue = array('comment1data'); + $expectedValue = ['comment1data']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/gists/123/comments', array('body' => 'Test body')) + ->with('/gists/123/comments', ['body' => 'Test body']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->create('123', 'Test body')); @@ -59,8 +59,8 @@ public function shouldCreateGistComment() */ public function shouldUpdateGistComment() { - $expectedValue = array('comment1data'); - $data = array('body' => 'body test'); + $expectedValue = ['comment1data']; + $data = ['body' => 'body test']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -76,7 +76,7 @@ public function shouldUpdateGistComment() */ public function shouldRemoveComment() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/GistsTest.php b/test/Github/Tests/Api/GistsTest.php index 2a7a6464bbb..8e179693656 100644 --- a/test/Github/Tests/Api/GistsTest.php +++ b/test/Github/Tests/Api/GistsTest.php @@ -9,7 +9,7 @@ class GistsTest extends TestCase */ public function shouldGetStarredGists() { - $expectedArray = array(array('id' => '123')); + $expectedArray = [['id' => '123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,7 +25,7 @@ public function shouldGetStarredGists() */ public function shouldGetAllGists() { - $expectedArray = array(array('id' => '123')); + $expectedArray = [['id' => '123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -41,7 +41,7 @@ public function shouldGetAllGists() */ public function shouldShowGist() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -57,7 +57,7 @@ public function shouldShowGist() */ public function shouldShowCommits() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -83,7 +83,7 @@ public function shouldGetCommentsApiObject() */ public function shouldForkGist() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -99,7 +99,7 @@ public function shouldForkGist() */ public function shouldListGistForks() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -116,10 +116,10 @@ public function shouldListGistForks() */ public function shouldNotCreateGistWithoutFile() { - $input = array( + $input = [ 'description' => '', 'public' => false, - ); + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -133,7 +133,7 @@ public function shouldNotCreateGistWithoutFile() */ public function shouldCheckGist() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -149,7 +149,7 @@ public function shouldCheckGist() */ public function shouldStarGist() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -165,7 +165,7 @@ public function shouldStarGist() */ public function shouldUnstarGist() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -181,15 +181,15 @@ public function shouldUnstarGist() */ public function shouldCreateAnonymousGist() { - $input = array( + $input = [ 'description' => '', 'public' => false, - 'files' => array( - 'filename.txt' => array( - 'content' => 'content' - ) - ) - ); + 'files' => [ + 'filename.txt' => [ + 'content' => 'content', + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -204,18 +204,18 @@ public function shouldCreateAnonymousGist() */ public function shouldUpdateGist() { - $input = array( + $input = [ 'description' => 'jimbo', - 'files' => array( - 'filename.txt' => array( + 'files' => [ + 'filename.txt' => [ 'filename' => 'new_name.txt', - 'content' => 'content' - ), - 'filename_new.txt' => array( - 'content' => 'content new' - ) - ) - ); + 'content' => 'content', + ], + 'filename_new.txt' => [ + 'content' => 'content new', + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/GitData/BlobsTest.php b/test/Github/Tests/Api/GitData/BlobsTest.php index 4c96ba303a5..a871414f96b 100644 --- a/test/Github/Tests/Api/GitData/BlobsTest.php +++ b/test/Github/Tests/Api/GitData/BlobsTest.php @@ -9,7 +9,7 @@ class BlobsTest extends TestCase */ public function shouldShowBlob() { - $expectedValue = array('blob' => 'some data'); + $expectedValue = ['blob' => 'some data']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,15 +25,15 @@ public function shouldShowBlob() */ public function shouldShowRawBlob() { - $expectedValue = array('blob' => 'some data'); + $expectedValue = ['blob' => 'some data']; $client = $this->getMockBuilder('Github\Client') ->disableOriginalConstructor() ->getMock(); $api = $this->getMockBuilder($this->getApiClass()) - ->setMethods(array('configure', 'get')) - ->setConstructorArgs(array($client)) + ->setMethods(['configure', 'get']) + ->setConstructorArgs([$client]) ->getMock(); $api->expects($this->once()) ->method('configure') @@ -53,8 +53,8 @@ public function shouldShowRawBlob() */ public function shouldCreateBlob() { - $expectedValue = array('blob' => 'some data'); - $data = array('content' => 'some cotent', 'encoding' => 'utf8'); + $expectedValue = ['blob' => 'some data']; + $data = ['content' => 'some cotent', 'encoding' => 'utf8']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -71,7 +71,7 @@ public function shouldCreateBlob() */ public function shouldNotCreateBlobWithoutEncoding() { - $data = array('content' => 'some cotent'); + $data = ['content' => 'some cotent']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -86,7 +86,7 @@ public function shouldNotCreateBlobWithoutEncoding() */ public function shouldNotCreateBlobWithoutContent() { - $data = array('encoding' => 'utf8'); + $data = ['encoding' => 'utf8']; $api = $this->getApiMock(); $api->expects($this->never()) diff --git a/test/Github/Tests/Api/GitData/CommitsTest.php b/test/Github/Tests/Api/GitData/CommitsTest.php index 964956439cf..3d973c6ab59 100644 --- a/test/Github/Tests/Api/GitData/CommitsTest.php +++ b/test/Github/Tests/Api/GitData/CommitsTest.php @@ -9,7 +9,7 @@ class CommitsTest extends TestCase */ public function shouldShowCommitUsingSha() { - $expectedValue = array('sha' => '123', 'comitter'); + $expectedValue = ['sha' => '123', 'comitter']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,8 +25,8 @@ public function shouldShowCommitUsingSha() */ public function shouldCreateCommit() { - $expectedValue = array('sha' => '123', 'comitter'); - $data = array('message' => 'some message', 'tree' => 1234, 'parents' => array()); + $expectedValue = ['sha' => '123', 'comitter']; + $data = ['message' => 'some message', 'tree' => 1234, 'parents' => []]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,7 +43,7 @@ public function shouldCreateCommit() */ public function shouldNotCreateCommitWithoutMessageParam() { - $data = array('tree' => 1234, 'parents' => array()); + $data = ['tree' => 1234, 'parents' => []]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -58,7 +58,7 @@ public function shouldNotCreateCommitWithoutMessageParam() */ public function shouldNotCreateCommitWithoutTreeParam() { - $data = array('message' => 'some message', 'parents' => array()); + $data = ['message' => 'some message', 'parents' => []]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -73,7 +73,7 @@ public function shouldNotCreateCommitWithoutTreeParam() */ public function shouldNotCreateCommitWithoutParentsParam() { - $data = array('message' => 'some message', 'tree' => '12334'); + $data = ['message' => 'some message', 'tree' => '12334']; $api = $this->getApiMock(); $api->expects($this->never()) diff --git a/test/Github/Tests/Api/GitData/ReferencesTest.php b/test/Github/Tests/Api/GitData/ReferencesTest.php index 2c094492f2a..55a3fa0edd6 100644 --- a/test/Github/Tests/Api/GitData/ReferencesTest.php +++ b/test/Github/Tests/Api/GitData/ReferencesTest.php @@ -9,7 +9,7 @@ class ReferencesTest extends TestCase */ public function shouldNotEscapeSlashesInReferences() { - $expectedValue = array('reference' => 'some data'); + $expectedValue = ['reference' => 'some data']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,7 +25,7 @@ public function shouldNotEscapeSlashesInReferences() */ public function shouldShowReference() { - $expectedValue = array('reference' => 'some data'); + $expectedValue = ['reference' => 'some data']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -41,7 +41,7 @@ public function shouldShowReference() */ public function shouldRemoveReference() { - $expectedValue = array('reference' => 'some data'); + $expectedValue = ['reference' => 'some data']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -57,7 +57,7 @@ public function shouldRemoveReference() */ public function shouldGetAllRepoReferences() { - $expectedValue = array(array('reference' => 'some data')); + $expectedValue = [['reference' => 'some data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -73,7 +73,7 @@ public function shouldGetAllRepoReferences() */ public function shouldGetAllRepoBranches() { - $expectedValue = array(array('branch' => 'some data')); + $expectedValue = [['branch' => 'some data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -89,7 +89,7 @@ public function shouldGetAllRepoBranches() */ public function shouldGetAllRepoTags() { - $expectedValue = array(array('tag' => 'some data')); + $expectedValue = [['tag' => 'some data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -105,8 +105,8 @@ public function shouldGetAllRepoTags() */ public function shouldCreateReference() { - $expectedValue = array('reference' => 'some data'); - $data = array('ref' => '122', 'sha' => '1234'); + $expectedValue = ['reference' => 'some data']; + $data = ['ref' => '122', 'sha' => '1234']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -123,7 +123,7 @@ public function shouldCreateReference() */ public function shouldNotCreateReferenceWithoutShaParam() { - $data = array('ref' => '123'); + $data = ['ref' => '123']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -138,7 +138,7 @@ public function shouldNotCreateReferenceWithoutShaParam() */ public function shouldNotCreateReferenceWithoutRefsParam() { - $data = array('sha' => '1234'); + $data = ['sha' => '1234']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -152,8 +152,8 @@ public function shouldNotCreateReferenceWithoutRefsParam() */ public function shouldUpdateReference() { - $expectedValue = array('reference' => 'some data'); - $data = array('sha' => '12345sha'); + $expectedValue = ['reference' => 'some data']; + $data = ['sha' => '12345sha']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -170,7 +170,7 @@ public function shouldUpdateReference() */ public function shouldNoUpdateReferenceWithoutSha() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) diff --git a/test/Github/Tests/Api/GitData/TagsTest.php b/test/Github/Tests/Api/GitData/TagsTest.php index 8b109d0b9be..06543edeace 100644 --- a/test/Github/Tests/Api/GitData/TagsTest.php +++ b/test/Github/Tests/Api/GitData/TagsTest.php @@ -9,7 +9,7 @@ class TagsTest extends TestCase */ public function shouldShowTagUsingSha() { - $expectedValue = array('sha' => '123', 'comitter'); + $expectedValue = ['sha' => '123', 'comitter']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,7 +25,7 @@ public function shouldShowTagUsingSha() */ public function shouldGetAllTags() { - $expectedValue = array(array('sha' => '123', 'tagger')); + $expectedValue = [['sha' => '123', 'tagger']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -41,18 +41,18 @@ public function shouldGetAllTags() */ public function shouldCreateTag() { - $expectedValue = array('sha' => '123', 'comitter'); - $data = array( + $expectedValue = ['sha' => '123', 'comitter']; + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'object' => 'test', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -69,16 +69,16 @@ public function shouldCreateTag() */ public function shouldNotCreateTagWithoutMessageParam() { - $data = array( + $data = [ 'tag' => 'v2.2', 'object' => 'test', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -93,12 +93,12 @@ public function shouldNotCreateTagWithoutMessageParam() */ public function shouldNotCreateTagWithoutTaggerParam() { - $data = array( + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'object' => 'test', 'type' => 'unsigned', - ); + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -113,16 +113,16 @@ public function shouldNotCreateTagWithoutTaggerParam() */ public function shouldNotCreateTagWithoutTaggerNameParam() { - $data = array( + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'object' => 'test', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -137,16 +137,16 @@ public function shouldNotCreateTagWithoutTaggerNameParam() */ public function shouldNotCreateTagWithoutTaggerEmailParam() { - $data = array( + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'object' => 'test', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -161,16 +161,16 @@ public function shouldNotCreateTagWithoutTaggerEmailParam() */ public function shouldNotCreateTagWithoutTaggerDateParam() { - $data = array( + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'object' => 'test', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', 'email' => 'leszek.prabucki@gmail.com', - ) - ); + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -185,16 +185,16 @@ public function shouldNotCreateTagWithoutTaggerDateParam() */ public function shouldNotCreateTagWithoutTagParam() { - $data = array( + $data = [ 'message' => 'some message', 'object' => 'test', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -209,16 +209,16 @@ public function shouldNotCreateTagWithoutTagParam() */ public function shouldNotCreateTagWithoutObjectParam() { - $data = array( + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'type' => 'unsigned', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -233,16 +233,16 @@ public function shouldNotCreateTagWithoutObjectParam() */ public function shouldNotCreateTagWithoutTypeParam() { - $data = array( + $data = [ 'message' => 'some message', 'tag' => 'v2.2', 'object' => 'test', - 'tagger' => array( + 'tagger' => [ 'name' => 'l3l0', 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s') - ) - ); + 'date' => date('Y-m-d H:i:s'), + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) diff --git a/test/Github/Tests/Api/GitData/TreesTest.php b/test/Github/Tests/Api/GitData/TreesTest.php index bd8db13f688..58ef5cef2a0 100644 --- a/test/Github/Tests/Api/GitData/TreesTest.php +++ b/test/Github/Tests/Api/GitData/TreesTest.php @@ -9,12 +9,12 @@ class TreesTest extends TestCase */ public function shouldShowTreeUsingSha() { - $expectedValue = array('sha' => '123', 'comitter'); + $expectedValue = ['sha' => '123', 'comitter']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/git/trees/123', array()) + ->with('/repos/KnpLabs/php-github-api/git/trees/123', []) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); @@ -25,23 +25,23 @@ public function shouldShowTreeUsingSha() */ public function shouldCreateTreeUsingSha() { - $expectedValue = array('sha' => '123', 'comitter'); - $data = array( - 'tree' => array( - array( + $expectedValue = ['sha' => '123', 'comitter']; + $data = [ + 'tree' => [ + [ 'path' => 'path', 'mode' => 'mode', 'type' => 'type', - 'sha' => '1234' - ), - array( + 'sha' => '1234', + ], + [ 'path' => 'htap', 'mode' => 'edom', 'type' => 'epyt', - 'sha' => '4321' - ), - ) - ); + 'sha' => '4321', + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -57,23 +57,23 @@ public function shouldCreateTreeUsingSha() */ public function shouldCreateTreeUsingContent() { - $expectedValue = array('sha' => '123', 'comitter'); - $data = array( - 'tree' => array( - array( + $expectedValue = ['sha' => '123', 'comitter']; + $data = [ + 'tree' => [ + [ 'path' => 'path', 'mode' => 'mode', 'type' => 'type', - 'content' => 'content' - ), - array( + 'content' => 'content', + ], + [ 'path' => 'htap', 'mode' => 'edom', 'type' => 'epyt', - 'content' => 'tnetnoc' - ), - ) - ); + 'content' => 'tnetnoc', + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -90,13 +90,13 @@ public function shouldCreateTreeUsingContent() */ public function shouldNotCreateTreeWithoutShaAndContentParam() { - $data = array( - 'tree' => array( + $data = [ + 'tree' => [ 'path' => 'path', 'mode' => 'mode', 'type' => 'type', - ) - ); + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -111,13 +111,13 @@ public function shouldNotCreateTreeWithoutShaAndContentParam() */ public function shouldNotCreateTreeWithoutPathParam() { - $data = array( - 'tree' => array( + $data = [ + 'tree' => [ 'mode' => 'mode', 'type' => 'type', - 'content' => 'content' - ) - ); + 'content' => 'content', + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -132,13 +132,13 @@ public function shouldNotCreateTreeWithoutPathParam() */ public function shouldNotCreateTreeWithoutModeParam() { - $data = array( - 'tree' => array( + $data = [ + 'tree' => [ 'path' => 'path', 'type' => 'type', - 'content' => 'content' - ) - ); + 'content' => 'content', + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -153,13 +153,13 @@ public function shouldNotCreateTreeWithoutModeParam() */ public function shouldNotCreateTreeWithoutTypeParam() { - $data = array( - 'tree' => array( + $data = [ + 'tree' => [ 'path' => 'path', 'mode' => 'mode', - 'content' => 'content' - ) - ); + 'content' => 'content', + ], + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -174,7 +174,7 @@ public function shouldNotCreateTreeWithoutTypeParam() */ public function shouldNotCreateTreeWithoutTreeParam() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -189,9 +189,9 @@ public function shouldNotCreateTreeWithoutTreeParam() */ public function shouldNotCreateTreeWhenTreeParamIsNotArray() { - $data = array( - 'tree' => '' - ); + $data = [ + 'tree' => '', + ]; $api = $this->getApiMock(); $api->expects($this->never()) diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php index e2f2d692c84..5faea997d3b 100644 --- a/test/Github/Tests/Api/GraphQLTest.php +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -4,7 +4,6 @@ class GraphQLTest extends TestCase { - /** * @test */ @@ -44,7 +43,7 @@ public function shouldJSONEncodeGraphQLVariables() $api->method('post') ->with('/graphql', $this->equalTo([ 'query'=>'bar', - 'variables' => '{"variable":"foo"}' + 'variables' => '{"variable":"foo"}', ])); $api->execute('bar', ['variable' => 'foo']); diff --git a/test/Github/Tests/Api/Issue/AssigneesTest.php b/test/Github/Tests/Api/Issue/AssigneesTest.php index a3cfe0f6066..8777f0923b2 100644 --- a/test/Github/Tests/Api/Issue/AssigneesTest.php +++ b/test/Github/Tests/Api/Issue/AssigneesTest.php @@ -39,7 +39,7 @@ public function shouldCheckAssignee() */ public function shouldNotAddAssigneeMissingParameter() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -53,9 +53,9 @@ public function shouldNotAddAssigneeMissingParameter() */ public function shouldAddAssignee() { - $data = array( - 'assignees' => array('test-user') - ); + $data = [ + 'assignees' => ['test-user'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -71,7 +71,7 @@ public function shouldAddAssignee() */ public function shouldNotRemoveAssigneeMissingParameter() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -85,9 +85,9 @@ public function shouldNotRemoveAssigneeMissingParameter() */ public function shouldRemoveAssignee() { - $data = array( - 'assignees' => array('test-user') - ); + $data = [ + 'assignees' => ['test-user'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Issue/CommentsTest.php b/test/Github/Tests/Api/Issue/CommentsTest.php index daa7207c37f..51c67fe8f85 100644 --- a/test/Github/Tests/Api/Issue/CommentsTest.php +++ b/test/Github/Tests/Api/Issue/CommentsTest.php @@ -11,12 +11,12 @@ class CommentsTest extends TestCase */ public function shouldGetAllIssueComments() { - $expectedValue = array(array('comment1data'), array('comment2data')); + $expectedValue = [['comment1data'], ['comment2data']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/comments', array('page' => 1)) + ->with('/repos/KnpLabs/php-github-api/issues/123/comments', ['page' => 1]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123)); @@ -27,7 +27,7 @@ public function shouldGetAllIssueComments() */ public function shouldShowIssueComment() { - $expectedValue = array('comment1'); + $expectedValue = ['comment1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -44,7 +44,7 @@ public function shouldShowIssueComment() */ public function shouldNotCreateWithoutBody() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -58,8 +58,8 @@ public function shouldNotCreateWithoutBody() */ public function shouldCreateIssueComment() { - $expectedValue = array('comment1data'); - $data = array('body' => 'test body'); + $expectedValue = ['comment1data']; + $data = ['body' => 'test body']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -76,7 +76,7 @@ public function shouldCreateIssueComment() */ public function shouldNotUpdateWithoutBody() { - $data = array('somedata'); + $data = ['somedata']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -90,8 +90,8 @@ public function shouldNotUpdateWithoutBody() */ public function shouldUpdateIssueComment() { - $expectedValue = array('comment1data'); - $data = array('body' => 'body test'); + $expectedValue = ['comment1data']; + $data = ['body' => 'body test']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldUpdateIssueComment() */ public function shouldRemoveComment() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Issue/EventsTest.php b/test/Github/Tests/Api/Issue/EventsTest.php index 6e965c5ff22..37139936c63 100644 --- a/test/Github/Tests/Api/Issue/EventsTest.php +++ b/test/Github/Tests/Api/Issue/EventsTest.php @@ -11,12 +11,12 @@ class EventsTest extends TestCase */ public function shouldGetAllRepoIssuesEvents() { - $expectedValue = array(array('event1data'), array('event2data')); + $expectedValue = [['event1data'], ['event2data']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/events', array('page' => 1)) + ->with('/repos/KnpLabs/php-github-api/issues/events', ['page' => 1]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); @@ -27,12 +27,12 @@ public function shouldGetAllRepoIssuesEvents() */ public function shouldGetIssueEvents() { - $expectedValue = array(array('event1data'), array('event2data')); + $expectedValue = [['event1data'], ['event2data']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/events', array('page' => 1)) + ->with('/repos/KnpLabs/php-github-api/issues/123/events', ['page' => 1]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123)); @@ -43,7 +43,7 @@ public function shouldGetIssueEvents() */ public function shouldShowIssueEvent() { - $expectedValue = array('event1'); + $expectedValue = ['event1']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Issue/LabelsTest.php b/test/Github/Tests/Api/Issue/LabelsTest.php index 5be4e21254d..af8f14c67cb 100644 --- a/test/Github/Tests/Api/Issue/LabelsTest.php +++ b/test/Github/Tests/Api/Issue/LabelsTest.php @@ -11,15 +11,15 @@ class LabelsTest extends TestCase */ public function shouldGetProjectLabels() { - $expectedValue = array( - array('name' => 'l3l0repo'), - array('name' => 'other'), - ); + $expectedValue = [ + ['name' => 'l3l0repo'], + ['name' => 'other'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/labels', array()) + ->with('/repos/KnpLabs/php-github-api/labels', []) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); @@ -30,7 +30,7 @@ public function shouldGetProjectLabels() */ public function shouldGetAllIssueLabels() { - $expectedValue = array(array('name' => 'label')); + $expectedValue = [['name' => 'label']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -46,13 +46,13 @@ public function shouldGetAllIssueLabels() */ public function shouldCreateLabel() { - $expectedValue = array(array('name' => 'label', 'color' => 'FFFFFF')); - $data = array('name' => 'label'); + $expectedValue = [['name' => 'label', 'color' => 'FFFFFF']]; + $data = ['name' => 'label']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/repos/KnpLabs/php-github-api/labels', $data + array('color' => 'FFFFFF')) + ->with('/repos/KnpLabs/php-github-api/labels', $data + ['color' => 'FFFFFF']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); @@ -63,7 +63,7 @@ public function shouldCreateLabel() */ public function shouldGetSingleLabel() { - $expectedValue = array(array('name' => 'label1')); + $expectedValue = [['name' => 'label1']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -79,8 +79,8 @@ public function shouldGetSingleLabel() */ public function shouldCreateLabelWithColor() { - $expectedValue = array(array('name' => 'label', 'color' => '111111')); - $data = array('name' => 'label', 'color' => '111111'); + $expectedValue = [['name' => 'label', 'color' => '111111']]; + $data = ['name' => 'label', 'color' => '111111']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -96,7 +96,7 @@ public function shouldCreateLabelWithColor() */ public function shouldDeleteLabel() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -112,8 +112,8 @@ public function shouldDeleteLabel() */ public function shouldUpdateLabel() { - $expectedValue = array(array('name' => 'bar', 'color' => 'FFF')); - $data = array('name' => 'bar', 'color' => 'FFF'); + $expectedValue = [['name' => 'bar', 'color' => 'FFF']]; + $data = ['name' => 'bar', 'color' => 'FFF']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -129,7 +129,7 @@ public function shouldUpdateLabel() */ public function shouldRemoveLabel() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -145,12 +145,12 @@ public function shouldRemoveLabel() */ public function shouldAddOneLabel() { - $expectedValue = array('label' => 'somename'); + $expectedValue = ['label' => 'somename']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels', array('labelname')) + ->with('/repos/KnpLabs/php-github-api/issues/123/labels', ['labelname']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, 'labelname')); @@ -161,15 +161,15 @@ public function shouldAddOneLabel() */ public function shouldAddManyLabels() { - $expectedValue = array('label' => 'somename'); + $expectedValue = ['label' => 'somename']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels', array('labelname', 'labelname2')) + ->with('/repos/KnpLabs/php-github-api/issues/123/labels', ['labelname', 'labelname2']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, array('labelname', 'labelname2'))); + $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, ['labelname', 'labelname2'])); } /** @@ -177,8 +177,8 @@ public function shouldAddManyLabels() */ public function shouldReplaceLabels() { - $expectedValue = array(array('label' => 'somename')); - $data = array('labels' => array('labelname')); + $expectedValue = [['label' => 'somename']]; + $data = ['labels' => ['labelname']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -199,7 +199,7 @@ public function shouldNotAddWhenDoNotHaveLabelsToAdd() $api->expects($this->any()) ->method('post'); - $api->add('KnpLabs', 'php-github-api', 123, array()); + $api->add('KnpLabs', 'php-github-api', 123, []); } /** @@ -207,7 +207,7 @@ public function shouldNotAddWhenDoNotHaveLabelsToAdd() */ public function shouldClearLabels() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Issue/MilestonesTest.php b/test/Github/Tests/Api/Issue/MilestonesTest.php index 74f7b50fcda..18963580b8a 100644 --- a/test/Github/Tests/Api/Issue/MilestonesTest.php +++ b/test/Github/Tests/Api/Issue/MilestonesTest.php @@ -11,12 +11,12 @@ class MilestonesTest extends TestCase */ public function shouldGetMilestones() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', array('page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc')) + ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); @@ -27,8 +27,8 @@ public function shouldGetMilestones() */ public function shouldCreateMilestone() { - $expectedValue = array(array('title' => 'milestone')); - $data = array('title' => 'milestone'); + $expectedValue = [['title' => 'milestone']]; + $data = ['title' => 'milestone']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -45,8 +45,8 @@ public function shouldCreateMilestone() */ public function shouldNotCreateMilestoneWithoutTitle() { - $expectedValue = array(array('title' => 'milestone')); - $data = array(); + $expectedValue = [['title' => 'milestone']]; + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -60,15 +60,15 @@ public function shouldNotCreateMilestoneWithoutTitle() */ public function shouldSetStateToOpenWhileCreationWhenStateParamNotRecognized() { - $expectedValue = array('title' => 'l3l0repo'); + $expectedValue = ['title' => 'l3l0repo']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/repos/KnpLabs/php-github-api/milestones', array('state' => 'open', 'title' => 'milestone')) + ->with('/repos/KnpLabs/php-github-api/milestones', ['state' => 'open', 'title' => 'milestone']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', array('state' => 'clos', 'title' => 'milestone'))); + $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', ['state' => 'clos', 'title' => 'milestone'])); } /** @@ -76,13 +76,13 @@ public function shouldSetStateToOpenWhileCreationWhenStateParamNotRecognized() */ public function shouldUpdateMilestone() { - $expectedValue = array(array('title' => 'milestone')); - $data = array('title' => 'milestone'); + $expectedValue = [['title' => 'milestone']]; + $data = ['title' => 'milestone']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/repos/KnpLabs/php-github-api/milestones/123', array('title' => 'milestone')) + ->with('/repos/KnpLabs/php-github-api/milestones/123', ['title' => 'milestone']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); @@ -93,8 +93,8 @@ public function shouldUpdateMilestone() */ public function shouldUpdateMilestoneWithClosedStatus() { - $expectedValue = array(array('title' => 'milestone')); - $data = array('title' => 'milestone', 'status' => 'closed'); + $expectedValue = [['title' => 'milestone']]; + $data = ['title' => 'milestone', 'status' => 'closed']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -110,13 +110,13 @@ public function shouldUpdateMilestoneWithClosedStatus() */ public function shouldSetStateToOpenWhileUpdateWhenStateParamNotRecognized() { - $expectedValue = array('title' => 'l3l0repo'); - $data = array('title' => 'milestone', 'state' => 'some'); + $expectedValue = ['title' => 'l3l0repo']; + $data = ['title' => 'milestone', 'state' => 'some']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/repos/KnpLabs/php-github-api/milestones/123', array('state' => 'open', 'title' => 'milestone')) + ->with('/repos/KnpLabs/php-github-api/milestones/123', ['state' => 'open', 'title' => 'milestone']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); @@ -127,15 +127,15 @@ public function shouldSetStateToOpenWhileUpdateWhenStateParamNotRecognized() */ public function shouldSortByDueDateWhenSortParamNotRecognized() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', array('page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc')) + ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', array('sort' => 'completenes'))); + $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['sort' => 'completenes'])); } /** @@ -143,15 +143,15 @@ public function shouldSortByDueDateWhenSortParamNotRecognized() */ public function shouldSetStateToOpenWhenStateParamNotRecognized() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', array('page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc')) + ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', array('state' => 'clos'))); + $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['state' => 'clos'])); } /** @@ -159,15 +159,15 @@ public function shouldSetStateToOpenWhenStateParamNotRecognized() */ public function shouldSetDirectionToDescWhenDirectionParamNotRecognized() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', array('page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc')) + ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', array('direction' => 'asc'))); + $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['direction' => 'asc'])); } /** @@ -175,7 +175,7 @@ public function shouldSetDirectionToDescWhenDirectionParamNotRecognized() */ public function shouldRemoveMilestones() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -191,7 +191,7 @@ public function shouldRemoveMilestones() */ public function shouldShowMilestone() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -207,7 +207,7 @@ public function shouldShowMilestone() */ public function shouldGetMilestoneLabels() { - $expectedValue = array(array('label'), array('label2')); + $expectedValue = [['label'], ['label2']]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Issue/TimelineTest.php b/test/Github/Tests/Api/Issue/TimelineTest.php index 43bd991f279..401219af32b 100644 --- a/test/Github/Tests/Api/Issue/TimelineTest.php +++ b/test/Github/Tests/Api/Issue/TimelineTest.php @@ -11,21 +11,20 @@ class TimelineTest extends TestCase */ public function shouldGetIssueEvents() { - $expectedValue = array( + $expectedValue = [ 'event1', 'event2', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/timeline', array()) + ->with('/repos/KnpLabs/php-github-api/issues/123/timeline', []) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123)); } - /** * @return string */ diff --git a/test/Github/Tests/Api/IssueTest.php b/test/Github/Tests/Api/IssueTest.php index 545c5184be5..2fed3618853 100644 --- a/test/Github/Tests/Api/IssueTest.php +++ b/test/Github/Tests/Api/IssueTest.php @@ -9,12 +9,12 @@ class IssueTest extends TestCase */ public function shouldGetIssues() { - $data = array( - 'state' => 'open' - ); - $sentData = $data + array( - 'page' => 1 - ); + $data = [ + 'state' => 'open', + ]; + $sentData = $data + [ + 'page' => 1, + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -29,19 +29,19 @@ public function shouldGetIssues() */ public function shouldGetIssuesUsingAdditionalParameters() { - $expectedArray = array(array('id' => '123')); - $data = array( + $expectedArray = [['id' => '123']]; + $data = [ 'state' => 'open', 'milestone' => '*', 'assignee' => 'l3l0', 'mentioned' => 'l3l0', 'labels' => 'bug,@high', 'sort' => 'created', - 'direction' => 'asc' - ); - $sentData = $data + array( - 'page' => 1 - ); + 'direction' => 'asc', + ]; + $sentData = $data + [ + 'page' => 1, + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -57,7 +57,7 @@ public function shouldGetIssuesUsingAdditionalParameters() */ public function shouldShowIssue() { - $expectedArray = array('id' => '123'); + $expectedArray = ['id' => '123']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -73,10 +73,10 @@ public function shouldShowIssue() */ public function shouldCreateIssue() { - $data = array( + $data = [ 'title' => 'some title', - 'body' => 'some body' - ); + 'body' => 'some body', + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -92,9 +92,9 @@ public function shouldCreateIssue() */ public function shouldNotCreateIssueWithoutTitle() { - $data = array( - 'body' => 'some body' - ); + $data = [ + 'body' => 'some body', + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -108,9 +108,9 @@ public function shouldNotCreateIssueWithoutTitle() */ public function shouldCreateIssueWithoutBody() { - $data = array( - 'title' => 'some title' - ); + $data = [ + 'title' => 'some title', + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -125,9 +125,9 @@ public function shouldCreateIssueWithoutBody() */ public function shouldCloseIssue() { - $data = array( + $data = [ 'state' => 'closed', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -142,9 +142,9 @@ public function shouldCloseIssue() */ public function shouldReOpenIssue() { - $data = array( + $data = [ 'state' => 'open', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -159,7 +159,7 @@ public function shouldReOpenIssue() */ public function shouldSearchOpenIssues() { - $expectedArray = array(array('id' => '123')); + $expectedArray = [['id' => '123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -175,7 +175,7 @@ public function shouldSearchOpenIssues() */ public function shouldSearchClosedIssues() { - $expectedArray = array(array('id' => '123')); + $expectedArray = [['id' => '123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -191,7 +191,7 @@ public function shouldSearchClosedIssues() */ public function shouldSearchOpenIssuesWhenStateNotRecognized() { - $expectedArray = array(array('id' => '123')); + $expectedArray = [['id' => '123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -257,7 +257,7 @@ public function shouldGetTimelineApiObject() */ public function shouldLockIssue() { - $parameters = array(); + $parameters = []; $api = $this->getApiMock(); $api->expects($this->once()) @@ -272,7 +272,7 @@ public function shouldLockIssue() */ public function shouldUnlockIssue() { - $parameters = array(); + $parameters = []; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/MetaTest.php b/test/Github/Tests/Api/MetaTest.php index 57e2cac8bac..9275e5a1f1b 100644 --- a/test/Github/Tests/Api/MetaTest.php +++ b/test/Github/Tests/Api/MetaTest.php @@ -9,15 +9,15 @@ class MetaTest extends TestCase */ public function shouldGetInformationService() { - $expectedArray = array( - 'hooks' => array( - '127.0.0.1/32' - ), - 'git' => array( - '127.0.0.1/32' - ), - 'verifiable_password_authentication' => true - ); + $expectedArray = [ + 'hooks' => [ + '127.0.0.1/32', + ], + 'git' => [ + '127.0.0.1/32', + ], + 'verifiable_password_authentication' => true, + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Miscellaneous/EmojisTest.php b/test/Github/Tests/Api/Miscellaneous/EmojisTest.php index 63bac291e94..b4408b80aa1 100644 --- a/test/Github/Tests/Api/Miscellaneous/EmojisTest.php +++ b/test/Github/Tests/Api/Miscellaneous/EmojisTest.php @@ -12,10 +12,10 @@ class EmojisTest extends TestCase */ public function shouldGetAllEmojis() { - $expectedArray = array( + $expectedArray = [ '+1' => 'https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5', '-1' => 'https://github.global.ssl.fastly.net/images/icons/emoji/-1.png?v5', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php b/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php index 9fbd0ef4fc4..6a244adaef5 100644 --- a/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php +++ b/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php @@ -2,7 +2,6 @@ namespace Github\Tests\Api\Miscellaneous; -use Github\Api\Miscellaneous\Emojis; use Github\Api\Miscellaneous\Gitignore; use Github\Tests\Api\TestCase; @@ -13,15 +12,15 @@ class GitignoreTest extends TestCase */ public function shouldGetAllTemplates() { - $expectedArray = array( + $expectedArray = [ 'Actionscript', 'Android', 'AppceleratorTitanium', 'Autotools', 'Bancha', 'C', - 'C++' - ); + 'C++', + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -37,10 +36,10 @@ public function shouldGetAllTemplates() */ public function shouldGetTemplate() { - $expectedArray = array( + $expectedArray = [ 'name' => 'C', - 'source' => "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a" - ); + 'source' => "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a", + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php b/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php index 14cb9bf439a..b327a1b83c8 100644 --- a/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php +++ b/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php @@ -11,12 +11,12 @@ class MarkdownTest extends TestCase */ public function shouldRenderMarkdown() { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; + $input = 'Hello world github/linguist#1 **cool**, and #1!'; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/markdown', array('text' => $input, 'mode' => 'markdown')); + ->with('/markdown', ['text' => $input, 'mode' => 'markdown']); $api->render($input); } @@ -26,12 +26,12 @@ public function shouldRenderMarkdown() */ public function shouldRenderMarkdownUsingGfmMode() { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; + $input = 'Hello world github/linguist#1 **cool**, and #1!'; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/markdown', array('text' => $input, 'mode' => 'gfm')); + ->with('/markdown', ['text' => $input, 'mode' => 'gfm']); $api->render($input, 'gfm'); } @@ -41,12 +41,12 @@ public function shouldRenderMarkdownUsingGfmMode() */ public function shouldSetModeToMarkdownWhenIsNotRecognized() { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; + $input = 'Hello world github/linguist#1 **cool**, and #1!'; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/markdown', array('text' => $input, 'mode' => 'markdown')); + ->with('/markdown', ['text' => $input, 'mode' => 'markdown']); $api->render($input, 'abc'); } @@ -56,17 +56,17 @@ public function shouldSetModeToMarkdownWhenIsNotRecognized() */ public function shouldSetContextOnlyForGfmMode() { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; + $input = 'Hello world github/linguist#1 **cool**, and #1!'; $apiWithMarkdown = $this->getApiMock(); $apiWithMarkdown->expects($this->once()) ->method('post') - ->with('/markdown', array('text' => $input, 'mode' => 'markdown')); + ->with('/markdown', ['text' => $input, 'mode' => 'markdown']); $apiWithGfm = $this->getApiMock(); $apiWithGfm->expects($this->once()) ->method('post') - ->with('/markdown', array('text' => $input, 'mode' => 'gfm', 'context' => 'someContext')); + ->with('/markdown', ['text' => $input, 'mode' => 'gfm', 'context' => 'someContext']); $apiWithMarkdown->render($input, 'markdown', 'someContext'); $apiWithGfm->render($input, 'gfm', 'someContext'); @@ -77,12 +77,12 @@ public function shouldSetContextOnlyForGfmMode() */ public function shouldRenderRawFile() { - $file = 'file'; + $file = 'file'; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/markdown/raw', array('file' => $file)); + ->with('/markdown/raw', ['file' => $file]); $api->renderRaw($file); } diff --git a/test/Github/Tests/Api/NotificationTest.php b/test/Github/Tests/Api/NotificationTest.php index 0f2616996e2..5cbf7fabc11 100644 --- a/test/Github/Tests/Api/NotificationTest.php +++ b/test/Github/Tests/Api/NotificationTest.php @@ -11,10 +11,10 @@ class NotificationTest extends TestCase */ public function shouldGetNotifications() { - $parameters = array( + $parameters = [ 'all' => false, 'participating' => false, - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -31,11 +31,11 @@ public function shouldGetNotificationsSince() { $since = new DateTime('now'); - $parameters = array( + $parameters = [ 'all' => false, 'participating' => false, 'since' => $since->format(DateTime::ISO8601), - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -50,10 +50,10 @@ public function shouldGetNotificationsSince() */ public function shouldGetNotificationsIncludingAndParticipating() { - $parameters = array( + $parameters = [ 'all' => true, 'participating' => true, - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -68,7 +68,7 @@ public function shouldGetNotificationsIncludingAndParticipating() */ public function shouldMarkNotificationsAsRead() { - $parameters = array(); + $parameters = []; $api = $this->getApiMock(); $api->expects($this->once()) @@ -85,9 +85,9 @@ public function shouldMarkNotificationsAsReadForGivenDate() { $since = new DateTime('now'); - $parameters = array( + $parameters = [ 'last_read_at' => $since->format(DateTime::ISO8601), - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -96,7 +96,7 @@ public function shouldMarkNotificationsAsReadForGivenDate() $api->markRead($since); } - + public function shouldGetNotification() { $id = mt_rand(1, time()); diff --git a/test/Github/Tests/Api/Organization/HooksTest.php b/test/Github/Tests/Api/Organization/HooksTest.php index f61b4b54302..5c905ece70f 100644 --- a/test/Github/Tests/Api/Organization/HooksTest.php +++ b/test/Github/Tests/Api/Organization/HooksTest.php @@ -11,7 +11,7 @@ class HooksTest extends TestCase */ public function shouldGetAllOrganizationsHooks() { - $expectedValue = array(array('name' => 'hook')); + $expectedValue = [['name' => 'hook']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllOrganizationsHooks() */ public function shouldShowHook() { - $expectedValue = array('hook' => 'somename'); + $expectedValue = ['hook' => 'somename']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,7 +43,7 @@ public function shouldShowHook() */ public function shouldRemoveHook() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,7 +60,7 @@ public function shouldRemoveHook() */ public function shouldNotCreateHookWithoutName() { - $data = array('config' => 'conf'); + $data = ['config' => 'conf']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -75,7 +75,7 @@ public function shouldNotCreateHookWithoutName() */ public function shouldNotCreateHookWithoutConfig() { - $data = array('name' => 'test'); + $data = ['name' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -89,8 +89,8 @@ public function shouldNotCreateHookWithoutConfig() */ public function shouldCreateHook() { - $expectedValue = array('hook' => 'somename'); - $data = array('name' => 'test', 'config' => 'someconfig'); + $expectedValue = ['hook' => 'somename']; + $data = ['name' => 'test', 'config' => 'someconfig']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldCreateHook() */ public function shouldNotUpdateHookWithoutConfig() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -121,8 +121,8 @@ public function shouldNotUpdateHookWithoutConfig() */ public function shouldUpdateHook() { - $expectedValue = array('hook' => 'somename'); - $data = array('config' => 'config'); + $expectedValue = ['hook' => 'somename']; + $data = ['config' => 'config']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Organization/MembersTest.php b/test/Github/Tests/Api/Organization/MembersTest.php index 19f072e14ef..58ff1ea3c08 100644 --- a/test/Github/Tests/Api/Organization/MembersTest.php +++ b/test/Github/Tests/Api/Organization/MembersTest.php @@ -11,7 +11,7 @@ class MembersTest extends TestCase */ public function shouldGetAllOrganizationMembers() { - $expectedValue = array(array('username' => 'l3l0')); + $expectedValue = [['username' => 'l3l0']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllOrganizationMembers() */ public function shouldGetPublicOrganizationMembers() { - $expectedValue = array(array('username' => 'l3l0')); + $expectedValue = [['username' => 'l3l0']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -123,7 +123,7 @@ public function shouldConcealOrganizationMembership() */ public function shouldShowOrganizationMember() { - $expectedValue = array('username' => 'l3l0'); + $expectedValue = ['username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Organization/ProjectsTest.php b/test/Github/Tests/Api/Organization/ProjectsTest.php index 1415949a343..8ac5bf52229 100644 --- a/test/Github/Tests/Api/Organization/ProjectsTest.php +++ b/test/Github/Tests/Api/Organization/ProjectsTest.php @@ -11,7 +11,7 @@ class ProjectsTest extends TestCase */ public function shouldGetAllRepositoryProjects() { - $expectedValue = array(array('name' => 'Test project 1')); + $expectedValue = [['name' => 'Test project 1']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -28,7 +28,7 @@ public function shouldGetAllRepositoryProjects() */ public function shouldNotCreateWithoutName() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -42,8 +42,8 @@ public function shouldNotCreateWithoutName() */ public function shouldCreateColumn() { - $expectedValue = array('project1data'); - $data = array('name' => 'Project 1'); + $expectedValue = ['project1data']; + $data = ['name' => 'Project 1']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Organization/TeamsTest.php b/test/Github/Tests/Api/Organization/TeamsTest.php index 44cb781c8ce..4cff3609764 100644 --- a/test/Github/Tests/Api/Organization/TeamsTest.php +++ b/test/Github/Tests/Api/Organization/TeamsTest.php @@ -11,7 +11,7 @@ class TeamsTest extends TestCase */ public function shouldGetAllOrganizationTeams() { - $expectedValue = array(array('name' => 'KnpWorld'), array('name' => 'KnpFrance'), array('name' => 'KnpMontreal')); + $expectedValue = [['name' => 'KnpWorld'], ['name' => 'KnpFrance'], ['name' => 'KnpMontreal']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -59,7 +59,7 @@ public function shouldRemoveOrganizationTeam() */ public function shouldShowOrganizationTeam() { - $expectedValue = array('username' => 'l3l0'); + $expectedValue = ['username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -75,7 +75,7 @@ public function shouldShowOrganizationTeam() */ public function shouldGetTeamMembers() { - $expectedValue = array(array('username' => 'l3l0')); + $expectedValue = [['username' => 'l3l0']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -91,7 +91,7 @@ public function shouldGetTeamMembers() */ public function shouldAddTeamMembers() { - $expectedValue = array('username' => 'l3l0'); + $expectedValue = ['username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldAddTeamMembers() */ public function shouldRemoveTeamMembers() { - $expectedValue = array('username' => 'l3l0'); + $expectedValue = ['username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -123,7 +123,7 @@ public function shouldRemoveTeamMembers() */ public function shouldGetTeamRepositories() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -139,7 +139,7 @@ public function shouldGetTeamRepositories() */ public function shouldGetTeamRepository() { - $expectedValue = array('name' => 'l3l0repo'); + $expectedValue = ['name' => 'l3l0repo']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -155,7 +155,7 @@ public function shouldGetTeamRepository() */ public function shouldAddTeamRepository() { - $expectedValue = array('name' => 'l3l0repo'); + $expectedValue = ['name' => 'l3l0repo']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -171,7 +171,7 @@ public function shouldAddTeamRepository() */ public function shouldRemoveTeamRepository() { - $expectedValue = array('name' => 'l3l0repo'); + $expectedValue = ['name' => 'l3l0repo']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -188,7 +188,7 @@ public function shouldRemoveTeamRepository() */ public function shouldNotCreateTeamWithoutName() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -202,8 +202,8 @@ public function shouldNotCreateTeamWithoutName() */ public function shouldCreateOrganizationTeam() { - $expectedValue = array('name' => 'KnpWorld'); - $data = array('name' => 'KnpWorld'); + $expectedValue = ['name' => 'KnpWorld']; + $data = ['name' => 'KnpWorld']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -219,13 +219,13 @@ public function shouldCreateOrganizationTeam() */ public function shouldCreateOrganizationTeamWithRepoName() { - $expectedValue = array('name' => 'KnpWorld'); - $data = array('name' => 'KnpWorld', 'repo_names' => 'somerepo'); + $expectedValue = ['name' => 'KnpWorld']; + $data = ['name' => 'KnpWorld', 'repo_names' => 'somerepo']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/orgs/KnpLabs/teams', array('name' => 'KnpWorld', 'repo_names' => array('somerepo'))) + ->with('/orgs/KnpLabs/teams', ['name' => 'KnpWorld', 'repo_names' => ['somerepo']]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); @@ -236,13 +236,13 @@ public function shouldCreateOrganizationTeamWithRepoName() */ public function shouldCreateWithPullPermissionWhenPermissionParamNotRecognized() { - $expectedValue = array('name' => 'KnpWorld'); - $data = array('name' => 'KnpWorld', 'permission' => 'someinvalid'); + $expectedValue = ['name' => 'KnpWorld']; + $data = ['name' => 'KnpWorld', 'permission' => 'someinvalid']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/orgs/KnpLabs/teams', array('name' => 'KnpWorld', 'permission' => 'pull')) + ->with('/orgs/KnpLabs/teams', ['name' => 'KnpWorld', 'permission' => 'pull']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); @@ -254,7 +254,7 @@ public function shouldCreateWithPullPermissionWhenPermissionParamNotRecognized() */ public function shouldNotUpdateTeamWithoutName() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -268,8 +268,8 @@ public function shouldNotUpdateTeamWithoutName() */ public function shouldUpdateOrganizationTeam() { - $expectedValue = array('name' => 'KnpWorld'); - $data = array('name' => 'KnpWorld'); + $expectedValue = ['name' => 'KnpWorld']; + $data = ['name' => 'KnpWorld']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -285,13 +285,13 @@ public function shouldUpdateOrganizationTeam() */ public function shouldUpdateWithPullPermissionWhenPermissionParamNotRecognized() { - $expectedValue = array('name' => 'KnpWorld'); - $data = array('name' => 'KnpWorld', 'permission' => 'someinvalid'); + $expectedValue = ['name' => 'KnpWorld']; + $data = ['name' => 'KnpWorld', 'permission' => 'someinvalid']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/teams/KnpWorld', array('name' => 'KnpWorld', 'permission' => 'pull')) + ->with('/teams/KnpWorld', ['name' => 'KnpWorld', 'permission' => 'pull']) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->update('KnpWorld', $data)); diff --git a/test/Github/Tests/Api/OrganizationTest.php b/test/Github/Tests/Api/OrganizationTest.php index 2090827655a..04f389c0337 100644 --- a/test/Github/Tests/Api/OrganizationTest.php +++ b/test/Github/Tests/Api/OrganizationTest.php @@ -9,7 +9,7 @@ class OrganizationTest extends TestCase */ public function shouldGetAllOrganizations() { - $expectedValue = array(array('login' => 'KnpLabs')); + $expectedValue = [['login' => 'KnpLabs']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,7 +25,7 @@ public function shouldGetAllOrganizations() */ public function shouldShowOrganization() { - $expectedArray = array('id' => 1, 'name' => 'KnpLabs'); + $expectedArray = ['id' => 1, 'name' => 'KnpLabs']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -41,15 +41,15 @@ public function shouldShowOrganization() */ public function shouldUpdateOrganization() { - $expectedArray = array('id' => 1, 'name' => 'KnpLabs'); + $expectedArray = ['id' => 1, 'name' => 'KnpLabs']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/orgs/KnpLabs', array('value' => 'toUpdate')) + ->with('/orgs/KnpLabs', ['value' => 'toUpdate']) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->update('KnpLabs', array('value' => 'toUpdate'))); + $this->assertEquals($expectedArray, $api->update('KnpLabs', ['value' => 'toUpdate'])); } /** @@ -57,12 +57,12 @@ public function shouldUpdateOrganization() */ public function shouldGetOrganizationRepositories() { - $expectedArray = array(array('id' => 1, 'username' => 'KnpLabs', 'name' => 'php-github-api')); + $expectedArray = [['id' => 1, 'username' => 'KnpLabs', 'name' => 'php-github-api']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/orgs/KnpLabs/repos', array('type' => 'all', 'page' => 1)) + ->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->repositories('KnpLabs')); diff --git a/test/Github/Tests/Api/Project/CardsTest.php b/test/Github/Tests/Api/Project/CardsTest.php index 0b68310274f..6195f1b3514 100644 --- a/test/Github/Tests/Api/Project/CardsTest.php +++ b/test/Github/Tests/Api/Project/CardsTest.php @@ -11,7 +11,7 @@ class CardsTest extends TestCase */ public function shouldGetAllColumnCards() { - $expectedValue = array(array('card1data'), array('card2data')); + $expectedValue = [['card1data'], ['card2data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllColumnCards() */ public function shouldShowCard() { - $expectedValue = array('card1'); + $expectedValue = ['card1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,8 +43,8 @@ public function shouldShowCard() */ public function shouldCreateCard() { - $expectedValue = array('card1data'); - $data = array('content_id' => '123', 'content_type' => 'Issue'); + $expectedValue = ['card1data']; + $data = ['content_id' => '123', 'content_type' => 'Issue']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,8 +60,8 @@ public function shouldCreateCard() */ public function shouldUpdateCard() { - $expectedValue = array('note1data'); - $data = array('note' => 'note test'); + $expectedValue = ['note1data']; + $data = ['note' => 'note test']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -77,7 +77,7 @@ public function shouldUpdateCard() */ public function shouldRemoveCard() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -94,7 +94,7 @@ public function shouldRemoveCard() */ public function shouldNotMoveWithoutPosition() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -108,8 +108,8 @@ public function shouldNotMoveWithoutPosition() */ public function shouldMoveCard() { - $expectedValue = array('card1'); - $data = array('position' => 'top'); + $expectedValue = ['card1']; + $data = ['position' => 'top']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Project/ColumnsTest.php b/test/Github/Tests/Api/Project/ColumnsTest.php index cb244623095..7ce3a1693f2 100644 --- a/test/Github/Tests/Api/Project/ColumnsTest.php +++ b/test/Github/Tests/Api/Project/ColumnsTest.php @@ -11,7 +11,7 @@ class ColumnsTest extends TestCase */ public function shouldGetAllProjectColumns() { - $expectedValue = array(array('column1data'), array('column2data')); + $expectedValue = [['column1data'], ['column2data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllProjectColumns() */ public function shouldShowColumn() { - $expectedValue = array('column1'); + $expectedValue = ['column1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -44,7 +44,7 @@ public function shouldShowColumn() */ public function shouldNotCreateWithoutName() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -58,8 +58,8 @@ public function shouldNotCreateWithoutName() */ public function shouldCreateColumn() { - $expectedValue = array('column1data'); - $data = array('name' => 'column 1'); + $expectedValue = ['column1data']; + $data = ['name' => 'column 1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -76,7 +76,7 @@ public function shouldCreateColumn() */ public function shouldNotUpdateWithoutName() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -90,8 +90,8 @@ public function shouldNotUpdateWithoutName() */ public function shouldUpdateColumn() { - $expectedValue = array('column1data'); - $data = array('name' => 'column 1 update'); + $expectedValue = ['column1data']; + $data = ['name' => 'column 1 update']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldUpdateColumn() */ public function shouldRemoveCard() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -124,7 +124,7 @@ public function shouldRemoveCard() */ public function shouldNotMoveWithoutPosition() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -138,8 +138,8 @@ public function shouldNotMoveWithoutPosition() */ public function shouldMoveCard() { - $expectedValue = array('card1'); - $data = array('position' => 'first'); + $expectedValue = ['card1']; + $data = ['position' => 'first']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Project/ProjectsTest.php b/test/Github/Tests/Api/Project/ProjectsTest.php index 3278b6b0ee1..0dc7e2645a5 100644 --- a/test/Github/Tests/Api/Project/ProjectsTest.php +++ b/test/Github/Tests/Api/Project/ProjectsTest.php @@ -12,7 +12,7 @@ class ProjectsTest extends TestCase */ public function shouldShowProject() { - $expectedValue = array('name' => 'Test project 1'); + $expectedValue = ['name' => 'Test project 1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -28,8 +28,8 @@ public function shouldShowProject() */ public function shouldUpdateProject() { - $expectedValue = array('project1data'); - $data = array('name' => 'Project 1 update'); + $expectedValue = ['project1data']; + $data = ['name' => 'Project 1 update']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -45,7 +45,7 @@ public function shouldUpdateProject() */ public function shouldRemoveProject() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/PullRequest/CommentsTest.php b/test/Github/Tests/Api/PullRequest/CommentsTest.php index a6213a168cc..872934260d1 100644 --- a/test/Github/Tests/Api/PullRequest/CommentsTest.php +++ b/test/Github/Tests/Api/PullRequest/CommentsTest.php @@ -3,7 +3,6 @@ namespace Github\Tests\Api\PullRequest; use Github\Api\PullRequest\Comments; -use Github\Api\PullRequest\ReviewComment; use Github\Tests\Api\TestCase; class CommentsTest extends TestCase diff --git a/test/Github/Tests/Api/PullRequest/ReviewTest.php b/test/Github/Tests/Api/PullRequest/ReviewTest.php index 441240ecfd3..24e212cde42 100644 --- a/test/Github/Tests/Api/PullRequest/ReviewTest.php +++ b/test/Github/Tests/Api/PullRequest/ReviewTest.php @@ -33,7 +33,7 @@ public function shouldGetAllReviewsForAPullRequest() 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', 'received_events_url' => 'https://api.github.com/users/octocat/received_events', 'type' => 'User', - 'site_admin' => false + 'site_admin' => false, ], 'body' => 'Here is the body for the review.', 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', @@ -42,10 +42,10 @@ public function shouldGetAllReviewsForAPullRequest() 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', '_links' => [ 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80' + 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', ], 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12' + 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', ], ], ], @@ -85,7 +85,7 @@ public function shouldShowReview() 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', 'received_events_url' => 'https://api.github.com/users/octocat/received_events', 'type' => 'User', - 'site_admin' => false + 'site_admin' => false, ], 'body' => 'Here is the body for the review.', 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', @@ -94,10 +94,10 @@ public function shouldShowReview() 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', '_links' => [ 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80' + 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', ], 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12' + 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', ], ], ]; @@ -133,48 +133,48 @@ public function shouldShowReviewComments() { $expectedValue = [ [ - "url" => "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1", - "id" => 1, - "pull_request_review_id" => 42, - "diff_hunk" => "@@ -16,33 +16,40 @@ public class Connection => IConnection...", - "path" => "file1.txt", - "position" => 1, - "original_position" => 4, - "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e", - "original_commit_id" => "9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840", - "user" => [ - "login" => "octocat", - "id" => 1, - "avatar_url" => "https://github.com/images/error/octocat_happy.gif", - "gravatar_id" => "", - "url" => "https://api.github.com/users/octocat", - "html_url" => "https://github.com/octocat", - "followers_url" => "https://api.github.com/users/octocat/followers", - "following_url" => "https://api.github.com/users/octocat/following[/other_user]", - "gists_url" => "https://api.github.com/users/octocat/gists[/gist_id]", - "starred_url" => "https://api.github.com/users/octocat/starred[/owner][/repo]", - "subscriptions_url" => "https://api.github.com/users/octocat/subscriptions", - "organizations_url" => "https://api.github.com/users/octocat/orgs", - "repos_url" => "https://api.github.com/users/octocat/repos", - "events_url" => "https://api.github.com/users/octocat/events[/privacy]", - "received_events_url" => "https://api.github.com/users/octocat/received_events", - "type" => "User", - "site_admin" => false, + 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', + 'id' => 1, + 'pull_request_review_id' => 42, + 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', + 'path' => 'file1.txt', + 'position' => 1, + 'original_position' => 4, + 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', + 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', + 'user' => [ + 'login' => 'octocat', + 'id' => 1, + 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', + 'gravatar_id' => '', + 'url' => 'https://api.github.com/users/octocat', + 'html_url' => 'https://github.com/octocat', + 'followers_url' => 'https://api.github.com/users/octocat/followers', + 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', + 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', + 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', + 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', + 'organizations_url' => 'https://api.github.com/users/octocat/orgs', + 'repos_url' => 'https://api.github.com/users/octocat/repos', + 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', + 'received_events_url' => 'https://api.github.com/users/octocat/received_events', + 'type' => 'User', + 'site_admin' => false, ], - "body" => "Great stuff", - "created_at" => "2011-04-14T16:00:49Z", - "updated_at" => "2011-04-14T16:00:49Z", - "html_url" => "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1", - "pull_request_url" => "https://api.github.com/repos/octocat/Hello-World/pulls/1", - "_links" => [ - "self" => [ - "href" => "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1", + 'body' => 'Great stuff', + 'created_at' => '2011-04-14T16:00:49Z', + 'updated_at' => '2011-04-14T16:00:49Z', + 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', + 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', + '_links' => [ + 'self' => [ + 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', ], - "html" => [ - "href" => "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1", + 'html' => [ + 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', ], - "pull_request" => [ - "href" => "https://api.github.com/repos/octocat/Hello-World/pulls/1", + 'pull_request' => [ + 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', ], ], ], @@ -273,7 +273,7 @@ public function shouldSubmitReviewComment() 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', 'received_events_url' => 'https://api.github.com/users/octocat/received_events', 'type' => 'User', - 'site_admin' => false + 'site_admin' => false, ], 'body' => 'Here is the body for the review.', 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', @@ -282,10 +282,10 @@ public function shouldSubmitReviewComment() 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', '_links' => [ 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80' + 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', ], 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12' + 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', ], ], ]; @@ -367,7 +367,7 @@ public function shouldDismissReview() 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', 'received_events_url' => 'https://api.github.com/users/octocat/received_events', 'type' => 'User', - 'site_admin' => false + 'site_admin' => false, ], 'body' => 'Here is the body for the review.', 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', @@ -376,10 +376,10 @@ public function shouldDismissReview() 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', '_links' => [ 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80' + 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', ], 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12' + 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', ], ], ]; diff --git a/test/Github/Tests/Api/PullRequestTest.php b/test/Github/Tests/Api/PullRequestTest.php index cfcc005599d..a3486d1f301 100644 --- a/test/Github/Tests/Api/PullRequestTest.php +++ b/test/Github/Tests/Api/PullRequestTest.php @@ -9,7 +9,7 @@ class PullRequestTest extends TestCase */ public function shouldGetAllPullRequests() { - $expectedArray = array('pr1', 'pr2'); + $expectedArray = ['pr1', 'pr2']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,15 +25,15 @@ public function shouldGetAllPullRequests() */ public function shouldGetOpenPullRequests() { - $expectedArray = array('pr1', 'pr2'); + $expectedArray = ['pr1', 'pr2']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls', array('state' => 'open', 'per_page' => 30, 'page' => 1)) + ->with('/repos/ezsystems/ezpublish/pulls', ['state' => 'open', 'per_page' => 30, 'page' => 1]) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', array('state' => 'open'))); + $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', ['state' => 'open'])); } /** @@ -41,15 +41,15 @@ public function shouldGetOpenPullRequests() */ public function shouldGetClosedPullRequests() { - $expectedArray = array('pr1', 'pr2'); + $expectedArray = ['pr1', 'pr2']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls', array('state' => 'closed', 'per_page' => 30, 'page' => 1)) + ->with('/repos/ezsystems/ezpublish/pulls', ['state' => 'closed', 'per_page' => 30, 'page' => 1]) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', array('state' => 'closed'))); + $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', ['state' => 'closed'])); } /** @@ -57,7 +57,7 @@ public function shouldGetClosedPullRequests() */ public function shouldShowPullRequest() { - $expectedArray = array('id' => 'id', 'sha' => '123123'); + $expectedArray = ['id' => 'id', 'sha' => '123123']; $api = $this->getApiMock(); @@ -74,7 +74,7 @@ public function shouldShowPullRequest() */ public function shouldShowCommitsFromPullRequest() { - $expectedArray = array(array('id' => 'id', 'sha' => '123123')); + $expectedArray = [['id' => 'id', 'sha' => '123123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -90,7 +90,7 @@ public function shouldShowCommitsFromPullRequest() */ public function shouldShowFilesFromPullRequest() { - $expectedArray = array(array('id' => 'id', 'sha' => '123123')); + $expectedArray = [['id' => 'id', 'sha' => '123123']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -106,7 +106,7 @@ public function shouldShowFilesFromPullRequest() */ public function shouldShowStatusesFromPullRequest() { - $expectedArray = array(array('id' => 'id', 'sha' => '123123')); + $expectedArray = [['id' => 'id', 'sha' => '123123']]; $expectedArray['_links']['statuses']['href'] = '/repos/ezsystems/ezpublish/pulls/15/statuses'; $api = $this->getApiMock(); @@ -128,15 +128,15 @@ public function shouldShowStatusesFromPullRequest() */ public function shouldUpdatePullRequests() { - $expectedArray = array('id' => 15, 'sha' => '123123'); + $expectedArray = ['id' => 15, 'sha' => '123123']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/repos/ezsystems/ezpublish/pulls/15', array('state' => 'open', 'some' => 'param')) + ->with('/repos/ezsystems/ezpublish/pulls/15', ['state' => 'open', 'some' => 'param']) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->update('ezsystems', 'ezpublish', 15, array('state' => 'aa', 'some' => 'param'))); + $this->assertEquals($expectedArray, $api->update('ezsystems', 'ezpublish', 15, ['state' => 'aa', 'some' => 'param'])); } /** @@ -144,7 +144,7 @@ public function shouldUpdatePullRequests() */ public function shouldCheckIfPullRequestIsMerged() { - $expectedArray = array('some' => 'response'); + $expectedArray = ['some' => 'response']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -160,12 +160,12 @@ public function shouldCheckIfPullRequestIsMerged() */ public function shouldMergePullRequest() { - $expectedArray = array('some' => 'response'); + $expectedArray = ['some' => 'response']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('put') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'merge')) + ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'merge']) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40))); @@ -176,12 +176,12 @@ public function shouldMergePullRequest() */ public function shouldMergePullRequestWithSquashAsBool() { - $expectedArray = array('some' => 'response'); + $expectedArray = ['some' => 'response']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('put') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'squash')) + ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'squash']) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40), true)); @@ -192,12 +192,12 @@ public function shouldMergePullRequestWithSquashAsBool() */ public function shouldMergePullRequestWithMergeMethod() { - $expectedArray = array('some' => 'response'); + $expectedArray = ['some' => 'response']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('put') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'rebase')) + ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'rebase']) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40), 'rebase')); @@ -208,12 +208,12 @@ public function shouldMergePullRequestWithMergeMethod() */ public function shouldCreatePullRequestUsingTitle() { - $data = array( + $data = [ 'base' => 'master', 'head' => 'virtualtestbranch', 'title' => 'TITLE: Testing pull-request creation from PHP Github API', 'body' => 'BODY: Testing pull-request creation from PHP Github API', - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -228,11 +228,11 @@ public function shouldCreatePullRequestUsingTitle() */ public function shouldCreatePullRequestUsingIssueId() { - $data = array( + $data = [ 'base' => 'master', 'head' => 'virtualtestbranch', 'issue' => 25, - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -248,11 +248,11 @@ public function shouldCreatePullRequestUsingIssueId() */ public function shouldNotCreatePullRequestWithoutBase() { - $data = array( + $data = [ 'head' => 'virtualtestbranch', 'title' => 'TITLE: Testing pull-request creation from PHP Github API', 'body' => 'BODY: Testing pull-request creation from PHP Github API', - ); + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -267,11 +267,11 @@ public function shouldNotCreatePullRequestWithoutBase() */ public function shouldNotCreatePullRequestWithoutHead() { - $data = array( + $data = [ 'base' => 'master', 'title' => 'TITLE: Testing pull-request creation from PHP Github API', 'body' => 'BODY: Testing pull-request creation from PHP Github API', - ); + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -286,11 +286,11 @@ public function shouldNotCreatePullRequestWithoutHead() */ public function shouldNotCreatePullRequestUsingTitleButWithoutBody() { - $data = array( + $data = [ 'base' => 'master', 'head' => 'virtualtestbranch', 'title' => 'TITLE: Testing pull-request creation from PHP Github API', - ); + ]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -305,10 +305,10 @@ public function shouldNotCreatePullRequestUsingTitleButWithoutBody() */ public function shouldNotCreatePullRequestWithoutIssueIdOrTitle() { - $data = array( + $data = [ 'base' => 'master', 'head' => 'virtualtestbranch', - ); + ]; $api = $this->getApiMock(); $api->expects($this->never()) diff --git a/test/Github/Tests/Api/RateLimitTest.php b/test/Github/Tests/Api/RateLimitTest.php index dbbc1d7e722..7ff78ca0de1 100644 --- a/test/Github/Tests/Api/RateLimitTest.php +++ b/test/Github/Tests/Api/RateLimitTest.php @@ -9,20 +9,20 @@ class RateLimitTest extends TestCase */ public function shouldReturnRateLimitArray() { - $expectedArray = array( - 'resources' => array( - 'core' => array( + $expectedArray = [ + 'resources' => [ + 'core' => [ 'limit' => 5000, 'remaining' => 4999, - 'reset' => 1372700873 - ), - 'search' => array( + 'reset' => 1372700873, + ], + 'search' => [ 'limit' => 30, 'remaining' => 18, - 'reset' => 1372697452 - ) - ) - ); + 'reset' => 1372697452, + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/RepoTest.php b/test/Github/Tests/Api/RepoTest.php index 24a4be1fe51..6fe7bd9d5f2 100644 --- a/test/Github/Tests/Api/RepoTest.php +++ b/test/Github/Tests/Api/RepoTest.php @@ -9,7 +9,7 @@ class RepoTest extends TestCase */ public function shouldShowRepository() { - $expectedArray = array('id' => 1, 'name' => 'repoName'); + $expectedArray = ['id' => 1, 'name' => 'repoName']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,7 +25,7 @@ public function shouldShowRepository() */ public function shouldShowRepositoryById() { - $expectedArray = array('id' => 123456, 'name' => 'repoName'); + $expectedArray = ['id' => 123456, 'name' => 'repoName']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -41,18 +41,18 @@ public function shouldShowRepositoryById() */ public function shouldSearchRepositories() { - $expectedArray = array( - array('id' => 1, 'name' => 'php'), - array('id' => 2, 'name' => 'php-cs') - ); + $expectedArray = [ + ['id' => 1, 'name' => 'php'], + ['id' => 2, 'name' => 'php-cs'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/legacy/repos/search/php', array('myparam' => 2, 'start_page' => 1)) + ->with('/legacy/repos/search/php', ['myparam' => 2, 'start_page' => 1]) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->find('php', array('myparam' => 2))); + $this->assertEquals($expectedArray, $api->find('php', ['myparam' => 2])); } /** @@ -60,18 +60,18 @@ public function shouldSearchRepositories() */ public function shouldPaginateFoundRepositories() { - $expectedArray = array( - array('id' => 3, 'name' => 'fork of php'), - array('id' => 4, 'name' => 'fork of php-cs') - ); + $expectedArray = [ + ['id' => 3, 'name' => 'fork of php'], + ['id' => 4, 'name' => 'fork of php-cs'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/legacy/repos/search/php', array('start_page' => 2)) + ->with('/legacy/repos/search/php', ['start_page' => 2]) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->find('php', array('start_page' => 2))); + $this->assertEquals($expectedArray, $api->find('php', ['start_page' => 2])); } /** @@ -79,12 +79,12 @@ public function shouldPaginateFoundRepositories() */ public function shouldGetAllRepositories() { - $expectedArray = array( - array('id' => 1, 'name' => 'dummy project'), - array('id' => 2, 'name' => 'awesome another project'), - array('id' => 3, 'name' => 'fork of php'), - array('id' => 4, 'name' => 'fork of php-cs'), - ); + $expectedArray = [ + ['id' => 1, 'name' => 'dummy project'], + ['id' => 2, 'name' => 'awesome another project'], + ['id' => 3, 'name' => 'fork of php'], + ['id' => 4, 'name' => 'fork of php-cs'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -100,12 +100,12 @@ public function shouldGetAllRepositories() */ public function shouldGetAllRepositoriesStartingIndex() { - $expectedArray = array( - array('id' => 1, 'name' => 'dummy project'), - array('id' => 2, 'name' => 'awesome another project'), - array('id' => 3, 'name' => 'fork of php'), - array('id' => 4, 'name' => 'fork of php-cs'), - ); + $expectedArray = [ + ['id' => 1, 'name' => 'dummy project'], + ['id' => 2, 'name' => 'awesome another project'], + ['id' => 3, 'name' => 'fork of php'], + ['id' => 4, 'name' => 'fork of php-cs'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -121,12 +121,12 @@ public function shouldGetAllRepositoriesStartingIndex() */ public function shouldCreateRepositoryUsingNameOnly() { - $expectedArray = array('id' => 1, 'name' => 'l3l0Repo'); + $expectedArray = ['id' => 1, 'name' => 'l3l0Repo']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/user/repos', array( + ->with('/user/repos', [ 'name' => 'l3l0Repo', 'description' => '', 'homepage' => '', @@ -134,8 +134,8 @@ public function shouldCreateRepositoryUsingNameOnly() 'has_issues' => false, 'has_wiki' => false, 'has_downloads' => false, - 'auto_init' => false - )) + 'auto_init' => false, + ]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->create('l3l0Repo')); @@ -146,12 +146,12 @@ public function shouldCreateRepositoryUsingNameOnly() */ public function shouldCreateRepositoryForOrganization() { - $expectedArray = array('id' => 1, 'name' => 'KnpLabsRepo'); + $expectedArray = ['id' => 1, 'name' => 'KnpLabsRepo']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/orgs/KnpLabs/repos', array( + ->with('/orgs/KnpLabs/repos', [ 'name' => 'KnpLabsRepo', 'description' => '', 'homepage' => '', @@ -159,8 +159,8 @@ public function shouldCreateRepositoryForOrganization() 'has_issues' => false, 'has_wiki' => false, 'has_downloads' => false, - 'auto_init' => false - )) + 'auto_init' => false, + ]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->create('KnpLabsRepo', '', '', true, 'KnpLabs')); @@ -171,12 +171,12 @@ public function shouldCreateRepositoryForOrganization() */ public function shouldGetRepositorySubscribers() { - $expectedArray = array(array('id' => 1, 'username' => 'l3l0')); + $expectedArray = [['id' => 1, 'username' => 'l3l0']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/subscribers', array('page' => 2)) + ->with('/repos/KnpLabs/php-github-api/subscribers', ['page' => 2]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->subscribers('KnpLabs', 'php-github-api', 2)); @@ -187,7 +187,7 @@ public function shouldGetRepositorySubscribers() */ public function shouldGetRepositoryTags() { - $expectedArray = array(array('sha' => 1234)); + $expectedArray = [['sha' => 1234]]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -203,7 +203,7 @@ public function shouldGetRepositoryTags() */ public function shouldGetRepositoryBranches() { - $expectedArray = array(array('sha' => 1234, 'name' => 'master')); + $expectedArray = [['sha' => 1234, 'name' => 'master']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -219,7 +219,7 @@ public function shouldGetRepositoryBranches() */ public function shouldGetRepositoryBranch() { - $expectedArray = array('sha' => 1234, 'name' => 'master'); + $expectedArray = ['sha' => 1234, 'name' => 'master']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -235,7 +235,7 @@ public function shouldGetRepositoryBranch() */ public function shouldGetRepositoryLanguages() { - $expectedArray = array('lang1', 'lang2'); + $expectedArray = ['lang1', 'lang2']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -251,7 +251,7 @@ public function shouldGetRepositoryLanguages() */ public function shouldGetRepositoryMilestones() { - $expectedArray = array('milestone1', 'milestone2'); + $expectedArray = ['milestone1', 'milestone2']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -267,12 +267,12 @@ public function shouldGetRepositoryMilestones() */ public function shouldGetContributorsExcludingAnonymousOnes() { - $expectedArray = array('contrib1', 'contrib2'); + $expectedArray = ['contrib1', 'contrib2']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/contributors', array('anon' => null)) + ->with('/repos/KnpLabs/php-github-api/contributors', ['anon' => null]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->contributors('KnpLabs', 'php-github-api', false)); @@ -283,12 +283,12 @@ public function shouldGetContributorsExcludingAnonymousOnes() */ public function shouldGetContributorsIncludingAnonymousOnes() { - $expectedArray = array('contrib1', 'contrib2'); + $expectedArray = ['contrib1', 'contrib2']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/contributors', array('anon' => true)) + ->with('/repos/KnpLabs/php-github-api/contributors', ['anon' => true]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->contributors('KnpLabs', 'php-github-api', true)); @@ -299,7 +299,7 @@ public function shouldGetContributorsIncludingAnonymousOnes() */ public function shouldGetRepositoryTeams() { - $expectedArray = array(array('id' => 1234), array('id' => 2345)); + $expectedArray = [['id' => 1234], ['id' => 2345]]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -315,12 +315,12 @@ public function shouldGetRepositoryTeams() */ public function shouldCreateUsingAllParams() { - $expectedArray = array('id' => 1, 'name' => 'l3l0Repo'); + $expectedArray = ['id' => 1, 'name' => 'l3l0Repo']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/user/repos', array( + ->with('/user/repos', [ 'name' => 'l3l0Repo', 'description' => 'test', 'homepage' => 'http://l3l0.eu', @@ -328,8 +328,8 @@ public function shouldCreateUsingAllParams() 'has_issues' => false, 'has_wiki' => false, 'has_downloads' => false, - 'auto_init' => false - )) + 'auto_init' => false, + ]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->create('l3l0Repo', 'test', 'http://l3l0.eu', false)); @@ -340,15 +340,15 @@ public function shouldCreateUsingAllParams() */ public function shouldUpdate() { - $expectedArray = array('id' => 1, 'name' => 'l3l0Repo'); + $expectedArray = ['id' => 1, 'name' => 'l3l0Repo']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('patch') - ->with('/repos/l3l0Repo/test', array('description' => 'test', 'homepage' => 'http://l3l0.eu')) + ->with('/repos/l3l0Repo/test', ['description' => 'test', 'homepage' => 'http://l3l0.eu']) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', array('description' => 'test', 'homepage' => 'http://l3l0.eu'))); + $this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', ['description' => 'test', 'homepage' => 'http://l3l0.eu'])); } /** @@ -370,7 +370,7 @@ public function shouldDelete() */ public function shouldNotDelete() { - $expectedArray = array('message' => 'Not Found'); + $expectedArray = ['message' => 'Not Found']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -506,7 +506,7 @@ public function shouldGetReleasesApiObject() */ public function shouldGetCommitActivity() { - $expectedArray = array(array('days' => array(0, 3, 26, 20, 39, 1, 0), 'total' => 89, 'week' => 1336280400)); + $expectedArray = [['days' => [0, 3, 26, 20, 39, 1, 0], 'total' => 89, 'week' => 1336280400]]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -522,14 +522,14 @@ public function shouldGetCommitActivity() */ public function shouldGetRepositoryEvents() { - $expectedArray = array('id' => 6122723754, 'type' => 'ForkEvent'); + $expectedArray = ['id' => 6122723754, 'type' => 'ForkEvent']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/events', array( + ->with('/repos/KnpLabs/php-github-api/events', [ 'page' => 3, - )) + ]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->events('KnpLabs', 'php-github-api', 3)); @@ -540,7 +540,7 @@ public function shouldGetRepositoryEvents() */ public function shouldGetRepositoryCodeOfConduct() { - $expectedArray = array('name' => 'Contributor Covenant', 'url' => 'http://...'); + $expectedArray = ['name' => 'Contributor Covenant', 'url' => 'http://...']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -572,14 +572,14 @@ public function shouldGetRepositoryTopics() */ public function shouldReplaceRepositoryTopics() { - $expectedArray = array('id' => 6122723754, 'type' => 'ForkEvent'); + $expectedArray = ['id' => 6122723754, 'type' => 'ForkEvent']; $api = $this->getApiMock(); $api->expects($this->once()) ->method('put') - ->with('/repos/KnpLabs/php-github-api/topics', array( + ->with('/repos/KnpLabs/php-github-api/topics', [ 'names' => ['octocat', 'atom', 'electron', 'API'], - )) + ]) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->replaceTopics('KnpLabs', 'php-github-api', ['octocat', 'atom', 'electron', 'API'])); diff --git a/test/Github/Tests/Api/Repository/AssetsTest.php b/test/Github/Tests/Api/Repository/AssetsTest.php index 5c49c682112..9341cb5ac99 100644 --- a/test/Github/Tests/Api/Repository/AssetsTest.php +++ b/test/Github/Tests/Api/Repository/AssetsTest.php @@ -11,7 +11,7 @@ class AssetsTest extends TestCase */ public function shouldGetAllReleaseAssets() { - $expectedValue = array(array('asset1data'), array('asset2data')); + $expectedValue = [['asset1data'], ['asset2data']]; $id = 76; $api = $this->getApiMock(); @@ -28,7 +28,7 @@ public function shouldGetAllReleaseAssets() */ public function shouldGetSingleReleaseAsset() { - $expectedValue = array('assetData'); + $expectedValue = ['assetData']; $assetId = 2; $api = $this->getApiMock(); @@ -60,7 +60,7 @@ public function shouldCreateReleaseAsset() $api = $this->getApiMock(); $api->expects($this->once()) ->method('postRaw') - ->with('https://uploads.github.com/repos/KnpLabs/php-github-api/releases/'. $releaseId .'/assets?name='.$name) + ->with('https://uploads.github.com/repos/KnpLabs/php-github-api/releases/'.$releaseId.'/assets?name='.$name) ->will($this->returnValue($body)); $this->assertEquals($body, $api->create('KnpLabs', 'php-github-api', $releaseId, $name, $contentType, $body)); @@ -71,9 +71,9 @@ public function shouldCreateReleaseAsset() */ public function shouldEditReleaseAsset() { - $expectedValue = array('assetUpdatedData'); + $expectedValue = ['assetUpdatedData']; $assetId = 5; - $data = array('name' => 'asset111_name_qweqwe'); + $data = ['name' => 'asset111_name_qweqwe']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -91,7 +91,7 @@ public function shouldEditReleaseAsset() public function shouldNotEditReleaseAssetWithoutName() { $assetId = 5; - $data = array('not_a_name' => 'just a value'); + $data = ['not_a_name' => 'just a value']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -105,7 +105,7 @@ public function shouldNotEditReleaseAssetWithoutName() */ public function shouldRemoveReleaseAsset() { - $expectedValue = array('assetUpdatedData'); + $expectedValue = ['assetUpdatedData']; $assetId = 5; $api = $this->getApiMock(); diff --git a/test/Github/Tests/Api/Repository/CollaboratorsTest.php b/test/Github/Tests/Api/Repository/CollaboratorsTest.php index cbbacd1a94e..6683dba2bd0 100644 --- a/test/Github/Tests/Api/Repository/CollaboratorsTest.php +++ b/test/Github/Tests/Api/Repository/CollaboratorsTest.php @@ -11,7 +11,7 @@ class CollaboratorsTest extends TestCase */ public function shouldGetAllRepositoryCollaborators() { - $expectedValue = array(array('username' => 'l3l0')); + $expectedValue = [['username' => 'l3l0']]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/CommentsTest.php b/test/Github/Tests/Api/Repository/CommentsTest.php index 0924dbb1606..b573d3735c3 100644 --- a/test/Github/Tests/Api/Repository/CommentsTest.php +++ b/test/Github/Tests/Api/Repository/CommentsTest.php @@ -11,7 +11,7 @@ class CommentsTest extends TestCase */ public function shouldGetAllRepositoryComments() { - $expectedValue = array(array('comment1data'), array('comment2data')); + $expectedValue = [['comment1data'], ['comment2data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllRepositoryComments() */ public function shouldGetSpecificCommitRepositoryComments() { - $expectedValue = array(array('comment1data'), array('comment2data')); + $expectedValue = [['comment1data'], ['comment2data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,7 +43,7 @@ public function shouldGetSpecificCommitRepositoryComments() */ public function shouldShowComment() { - $expectedValue = array('comment1'); + $expectedValue = ['comment1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,7 +60,7 @@ public function shouldShowComment() */ public function shouldNotCreateWithoutBody() { - $data = array('line' => 53, 'path' => 'test.php', 'position' => 2); + $data = ['line' => 53, 'path' => 'test.php', 'position' => 2]; $api = $this->getApiMock(); $api->expects($this->never()) @@ -74,8 +74,8 @@ public function shouldNotCreateWithoutBody() */ public function shouldCreateRepositoryCommitComment() { - $expectedValue = array('comment1data'); - $data = array('body' => 'test body', 'line' => 53, 'path' => 'test.php', 'position' => 2); + $expectedValue = ['comment1data']; + $data = ['body' => 'test body', 'line' => 53, 'path' => 'test.php', 'position' => 2]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -91,8 +91,8 @@ public function shouldCreateRepositoryCommitComment() */ public function shouldCreateRepositoryCommitCommentWithoutLine() { - $expectedValue = array('comment1data'); - $data = array('body' => 'body', 'path' => 'test.php', 'position' => 2); + $expectedValue = ['comment1data']; + $data = ['body' => 'body', 'path' => 'test.php', 'position' => 2]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -113,7 +113,7 @@ public function shouldNotUpdateWithoutBody() $api->expects($this->never()) ->method('patch'); - $api->update('KnpLabs', 'php-github-api', 'commitSHA123456', array()); + $api->update('KnpLabs', 'php-github-api', 'commitSHA123456', []); } /** @@ -121,8 +121,8 @@ public function shouldNotUpdateWithoutBody() */ public function shouldUpdateComment() { - $expectedValue = array('comment1data'); - $data = array('body' => 'body test'); + $expectedValue = ['comment1data']; + $data = ['body' => 'body test']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -138,7 +138,7 @@ public function shouldUpdateComment() */ public function shouldRemoveComment() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/CommitsTest.php b/test/Github/Tests/Api/Repository/CommitsTest.php index 727b39f4a18..25ef2536a1c 100644 --- a/test/Github/Tests/Api/Repository/CommitsTest.php +++ b/test/Github/Tests/Api/Repository/CommitsTest.php @@ -11,8 +11,8 @@ class CommitsTest extends TestCase */ public function shouldGetAllRepositoryCommits() { - $expectedValue = array('commit' => array(), 'comitter'); - $data = array('sha' => 'v3'); + $expectedValue = ['commit' => [], 'comitter']; + $data = ['sha' => 'v3']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -28,7 +28,7 @@ public function shouldGetAllRepositoryCommits() */ public function shouldCompareTwoCommits() { - $expectedValue = array('someCompareChanges'); + $expectedValue = ['someCompareChanges']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -44,7 +44,7 @@ public function shouldCompareTwoCommits() */ public function shouldShowCommitUsingSha() { - $expectedValue = array('sha' => '123', 'comitter'); + $expectedValue = ['sha' => '123', 'comitter']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/ContentsTest.php b/test/Github/Tests/Api/Repository/ContentsTest.php index a8cc4098005..12fa01d44ef 100644 --- a/test/Github/Tests/Api/Repository/ContentsTest.php +++ b/test/Github/Tests/Api/Repository/ContentsTest.php @@ -2,8 +2,8 @@ namespace Github\Tests\Api\Repository; -use Github\Tests\Api\TestCase; use Github\Exception\TwoFactorAuthenticationRequiredException; +use Github\Tests\Api\TestCase; use GuzzleHttp\Psr7\Response; class ContentsTest extends TestCase @@ -18,7 +18,7 @@ public function shouldShowContentForGivenPath() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', array('ref' => null)) + ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php')); @@ -34,7 +34,7 @@ public function shouldShowReadme() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/readme', array('ref' => null)) + ->with('/repos/KnpLabs/php-github-api/readme', ['ref' => null]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->readme('KnpLabs', 'php-github-api')); @@ -50,7 +50,7 @@ public function shouldReturnTrueWhenFileExists() $api = $this->getApiMock(); $api->expects($this->once()) ->method('head') - ->with('/repos/KnpLabs/php-github-api/contents/composer.json', array('ref' => null)) + ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null]) ->will($this->returnValue($response)); $this->assertTrue($api->exists('KnpLabs', 'php-github-api', 'composer.json')); @@ -60,10 +60,10 @@ public function getFailureStubsForExistsTest() { $response = new Response(403); - return array( - array($this->throwException(new \ErrorException())), - array($this->returnValue($response)) - ); + return [ + [$this->throwException(new \ErrorException())], + [$this->returnValue($response)], + ]; } /** @@ -77,7 +77,7 @@ public function shouldReturnFalseWhenFileIsNotFound($failureStub) $api = $this->getApiMock(); $api->expects($this->once()) ->method('head') - ->with('/repos/KnpLabs/php-github-api/contents/composer.json', array('ref' => null)) + ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null]) ->will($failureStub); $this->assertFalse($api->exists('KnpLabs', 'php-github-api', 'composer.json')); @@ -92,7 +92,7 @@ public function shouldBubbleTwoFactorAuthenticationRequiredExceptionsWhenCheckin $api = $this->getApiMock(); $api->expects($this->once()) ->method('head') - ->with('/repos/KnpLabs/php-github-api/contents/composer.json', array('ref' => null)) + ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null]) ->will($this->throwException(new TwoFactorAuthenticationRequiredException(0))); $api->exists('KnpLabs', 'php-github-api', 'composer.json'); @@ -103,17 +103,17 @@ public function shouldBubbleTwoFactorAuthenticationRequiredExceptionsWhenCheckin */ public function shouldCreateNewFile() { - $expectedArray = array('content' => 'some data'); - $content = ' 'committer name', 'email' => 'email@example.com'); - $parameters = array( + $expectedArray = ['content' => 'some data']; + $content = ' 'committer name', 'email' => 'email@example.com']; + $parameters = [ 'content' => base64_encode($content), 'message' => $message, 'committer' => $committer, 'branch' => $branch, - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -131,8 +131,8 @@ public function shouldCreateNewFile() */ public function shouldThrowExceptionWhenCreateNewFileWithInvalidCommitter() { - $committer = array('invalid_key' => 'some data'); - $api = $this->getApiMock(); + $committer = ['invalid_key' => 'some data']; + $api = $this->getApiMock(); $api->create('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'some content', 'a commit message', null, $committer); } @@ -141,19 +141,19 @@ public function shouldThrowExceptionWhenCreateNewFileWithInvalidCommitter() */ public function shouldUpdateFile() { - $expectedArray = array('content' => 'some data'); - $content = ' 'committer name', 'email' => 'email@example.com'); - $parameters = array( + $expectedArray = ['content' => 'some data']; + $content = ' 'committer name', 'email' => 'email@example.com']; + $parameters = [ 'content' => base64_encode($content), 'message' => $message, 'committer' => $committer, 'branch' => $branch, 'sha' => $sha, - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -171,8 +171,8 @@ public function shouldUpdateFile() */ public function shouldThrowExceptionWhenUpdateFileWithInvalidCommitter() { - $committer = array('invalid_key' => 'some data'); - $api = $this->getApiMock(); + $committer = ['invalid_key' => 'some data']; + $api = $this->getApiMock(); $api->update('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'some content', 'a commit message', null, null, $committer); } @@ -181,17 +181,17 @@ public function shouldThrowExceptionWhenUpdateFileWithInvalidCommitter() */ public function shouldDeleteFile() { - $expectedArray = array('content' => 'some data'); - $message = 'a commit message'; - $sha = 'a sha'; - $branch = 'master'; - $committer = array('name' => 'committer name', 'email' => 'email@example.com'); - $parameters = array( + $expectedArray = ['content' => 'some data']; + $message = 'a commit message'; + $sha = 'a sha'; + $branch = 'master'; + $committer = ['name' => 'committer name', 'email' => 'email@example.com']; + $parameters = [ 'message' => $message, 'committer' => $committer, 'branch' => $branch, 'sha' => $sha, - ); + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -209,8 +209,8 @@ public function shouldDeleteFile() */ public function shouldThrowExceptionWhenDeleteFileWithInvalidCommitter() { - $committer = array('invalid_key' => 'some data'); - $api = $this->getApiMock(); + $committer = ['invalid_key' => 'some data']; + $api = $this->getApiMock(); $api->rm('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'a commit message', null, null, $committer); } @@ -292,7 +292,7 @@ public function shouldDownloadForGivenPath() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', array('ref' => null)) + ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null]) ->will($this->returnValue($getValue)); $this->assertEquals($expectedValue, $api->download('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php')); @@ -312,7 +312,7 @@ public function shouldDownloadForSpacedPath() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/mads379/scala.tmbundle/contents/Syntaxes%2FSimple%20Build%20Tool.tmLanguage', array('ref' => null)) + ->with('/repos/mads379/scala.tmbundle/contents/Syntaxes%2FSimple%20Build%20Tool.tmLanguage', ['ref' => null]) ->will($this->returnValue($getValue)); $this->assertEquals($expectedValue, $api->download('mads379', 'scala.tmbundle', 'Syntaxes/Simple Build Tool.tmLanguage')); diff --git a/test/Github/Tests/Api/Repository/DeployKeysTest.php b/test/Github/Tests/Api/Repository/DeployKeysTest.php index 557d259f483..f26c83c08e4 100644 --- a/test/Github/Tests/Api/Repository/DeployKeysTest.php +++ b/test/Github/Tests/Api/Repository/DeployKeysTest.php @@ -11,7 +11,7 @@ class DeployKeysTest extends TestCase */ public function shouldGetAllRepositoryDeployKeys() { - $expectedValue = array(array('name' => 'key')); + $expectedValue = [['name' => 'key']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllRepositoryDeployKeys() */ public function shouldShowDeployKey() { - $expectedValue = array('key' => 'somename'); + $expectedValue = ['key' => 'somename']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,7 +43,7 @@ public function shouldShowDeployKey() */ public function shouldRemoveDeployKey() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,7 +60,7 @@ public function shouldRemoveDeployKey() */ public function shouldNotCreateDeployKeyWithoutName() { - $data = array('config' => 'conf'); + $data = ['config' => 'conf']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -75,7 +75,7 @@ public function shouldNotCreateDeployKeyWithoutName() */ public function shouldNotCreateDeployKeyWithoutColor() { - $data = array('name' => 'test'); + $data = ['name' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -89,8 +89,8 @@ public function shouldNotCreateDeployKeyWithoutColor() */ public function shouldCreateDeployKey() { - $expectedValue = array('key' => 'somename'); - $data = array('title' => 'test', 'key' => 'ssh-rsa 1231234232'); + $expectedValue = ['key' => 'somename']; + $data = ['title' => 'test', 'key' => 'ssh-rsa 1231234232']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldCreateDeployKey() */ public function shouldNotUpdateDeployKeyWithoutTitle() { - $data = array('key' => 'ssh-rsa 12323213'); + $data = ['key' => 'ssh-rsa 12323213']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -122,7 +122,7 @@ public function shouldNotUpdateDeployKeyWithoutTitle() */ public function shouldNotUpdateDeployKeyWithoutKey() { - $data = array('title' => 'test'); + $data = ['title' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -136,8 +136,8 @@ public function shouldNotUpdateDeployKeyWithoutKey() */ public function shouldUpdateDeployKey() { - $expectedValue = array('key' => 'somename'); - $data = array('title' => 'test', 'key' => 'ssh-rsa 12312312321...'); + $expectedValue = ['key' => 'somename']; + $data = ['title' => 'test', 'key' => 'ssh-rsa 12312312321...']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/DownloadsTest.php b/test/Github/Tests/Api/Repository/DownloadsTest.php index 33fe2b4b277..f73b71491e4 100644 --- a/test/Github/Tests/Api/Repository/DownloadsTest.php +++ b/test/Github/Tests/Api/Repository/DownloadsTest.php @@ -11,7 +11,7 @@ class DownloadsTest extends TestCase */ public function shouldGetAllRepositoryDownloads() { - $expectedValue = array(array('download')); + $expectedValue = [['download']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllRepositoryDownloads() */ public function shouldShowRepositoryDownload() { - $expectedValue = array('download'); + $expectedValue = ['download']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/ForksTest.php b/test/Github/Tests/Api/Repository/ForksTest.php index 36912fd93df..fbc6eb67212 100644 --- a/test/Github/Tests/Api/Repository/ForksTest.php +++ b/test/Github/Tests/Api/Repository/ForksTest.php @@ -11,12 +11,12 @@ class ForksTest extends TestCase */ public function shouldGetForks() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/forks', array('page' => 1)) + ->with('/repos/KnpLabs/php-github-api/forks', ['page' => 1]) ->will($this->returnValue($expectedValue)); $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); @@ -27,8 +27,8 @@ public function shouldGetForks() */ public function shouldCreateFork() { - $expectedValue = array(array('name' => 'l3l0repo')); - $data = array('someparam'); + $expectedValue = [['name' => 'l3l0repo']]; + $data = ['someparam']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -44,15 +44,15 @@ public function shouldCreateFork() */ public function shouldSortByNewestWhenSortParamNotRecognized() { - $expectedValue = array(array('name' => 'l3l0repo')); + $expectedValue = [['name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/repos/KnpLabs/php-github-api/forks', array('page' => 1, 'sort' => 'newest')) + ->with('/repos/KnpLabs/php-github-api/forks', ['page' => 1, 'sort' => 'newest']) ->will($this->returnValue($expectedValue)); - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', array('sort' => 'oldes'))); + $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['sort' => 'oldes'])); } /** diff --git a/test/Github/Tests/Api/Repository/HooksTest.php b/test/Github/Tests/Api/Repository/HooksTest.php index 6b5447d762e..6571d04496d 100644 --- a/test/Github/Tests/Api/Repository/HooksTest.php +++ b/test/Github/Tests/Api/Repository/HooksTest.php @@ -11,7 +11,7 @@ class HooksTest extends TestCase */ public function shouldGetAllRepositoryHooks() { - $expectedValue = array(array('name' => 'hook')); + $expectedValue = [['name' => 'hook']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllRepositoryHooks() */ public function shouldShowHook() { - $expectedValue = array('hook' => 'somename'); + $expectedValue = ['hook' => 'somename']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,7 +43,7 @@ public function shouldShowHook() */ public function shouldRemoveHook() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,7 +60,7 @@ public function shouldRemoveHook() */ public function shouldNotCreateHookWithoutName() { - $data = array('config' => 'conf'); + $data = ['config' => 'conf']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -75,7 +75,7 @@ public function shouldNotCreateHookWithoutName() */ public function shouldNotCreateHookWithoutColor() { - $data = array('name' => 'test'); + $data = ['name' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -89,8 +89,8 @@ public function shouldNotCreateHookWithoutColor() */ public function shouldCreateHook() { - $expectedValue = array('hook' => 'somename'); - $data = array('name' => 'test', 'config' => 'someconfig'); + $expectedValue = ['hook' => 'somename']; + $data = ['name' => 'test', 'config' => 'someconfig']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldCreateHook() */ public function shouldNotUpdateHookWithoutConfig() { - $data = array('name' => 'test'); + $data = ['name' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -121,8 +121,8 @@ public function shouldNotUpdateHookWithoutConfig() */ public function shouldUpdateHook() { - $expectedValue = array('hook' => 'somename'); - $data = array('name' => 'test', 'config' => 'config'); + $expectedValue = ['hook' => 'somename']; + $data = ['name' => 'test', 'config' => 'config']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -138,7 +138,7 @@ public function shouldUpdateHook() */ public function shouldTestHook() { - $expectedValue = array(array('name' => 'hook')); + $expectedValue = [['name' => 'hook']]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/LabelsTest.php b/test/Github/Tests/Api/Repository/LabelsTest.php index b7be0312b66..df9f03844ec 100644 --- a/test/Github/Tests/Api/Repository/LabelsTest.php +++ b/test/Github/Tests/Api/Repository/LabelsTest.php @@ -11,7 +11,7 @@ class LabelsTest extends TestCase */ public function shouldGetAllRepositoryLabelss() { - $expectedValue = array(array('name' => 'label')); + $expectedValue = [['name' => 'label']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllRepositoryLabelss() */ public function shouldShowLabel() { - $expectedValue = array('label' => 'somename'); + $expectedValue = ['label' => 'somename']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -43,7 +43,7 @@ public function shouldShowLabel() */ public function shouldRemoveLabel() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,7 +60,7 @@ public function shouldRemoveLabel() */ public function shouldNotCreateLabelWithoutName() { - $data = array('color' => 'red'); + $data = ['color' => 'red']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -75,7 +75,7 @@ public function shouldNotCreateLabelWithoutName() */ public function shouldNotCreateLabelWithoutColor() { - $data = array('name' => 'test'); + $data = ['name' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -89,8 +89,8 @@ public function shouldNotCreateLabelWithoutColor() */ public function shouldCreateLabel() { - $expectedValue = array('label' => 'somename'); - $data = array('name' => 'test', 'color' => 'red'); + $expectedValue = ['label' => 'somename']; + $data = ['name' => 'test', 'color' => 'red']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -107,7 +107,7 @@ public function shouldCreateLabel() */ public function shouldNotUpdateLabelWithoutName() { - $data = array('color' => 'red'); + $data = ['color' => 'red']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -122,7 +122,7 @@ public function shouldNotUpdateLabelWithoutName() */ public function shouldNotUpdateLabelWithoutColor() { - $data = array('name' => 'test'); + $data = ['name' => 'test']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -136,8 +136,8 @@ public function shouldNotUpdateLabelWithoutColor() */ public function shouldUpdateLabel() { - $expectedValue = array('label' => 'somename'); - $data = array('name' => 'test', 'color' => 'red'); + $expectedValue = ['label' => 'somename']; + $data = ['name' => 'test', 'color' => 'red']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/ProjectsTest.php b/test/Github/Tests/Api/Repository/ProjectsTest.php index 2b0c50d2cf0..1c0b0f2ce4c 100644 --- a/test/Github/Tests/Api/Repository/ProjectsTest.php +++ b/test/Github/Tests/Api/Repository/ProjectsTest.php @@ -11,7 +11,7 @@ class ProjectsTest extends TestCase */ public function shouldGetAllRepositoryProjects() { - $expectedValue = array(array('name' => 'Test project 1')); + $expectedValue = [['name' => 'Test project 1']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -28,7 +28,7 @@ public function shouldGetAllRepositoryProjects() */ public function shouldNotCreateWithoutName() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -42,8 +42,8 @@ public function shouldNotCreateWithoutName() */ public function shouldCreateColumn() { - $expectedValue = array('project1data'); - $data = array('name' => 'Project 1'); + $expectedValue = ['project1data']; + $data = ['name' => 'Project 1']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/ProtectionTest.php b/test/Github/Tests/Api/Repository/ProtectionTest.php index 53f4e7ade69..f4f711dce74 100644 --- a/test/Github/Tests/Api/Repository/ProtectionTest.php +++ b/test/Github/Tests/Api/Repository/ProtectionTest.php @@ -11,7 +11,7 @@ class ProtectionTest extends TestCase */ public function shouldShowProtection() { - $expectedValue = array('required_status_checks', 'required_pull_reqeust_reviews', 'restrictions'); + $expectedValue = ['required_status_checks', 'required_pull_reqeust_reviews', 'restrictions']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,8 +27,8 @@ public function shouldShowProtection() */ public function shouldUpdateProtection() { - $expectedValue = array('required_status_checks', 'required_pull_reqeust_reviews', 'restrictions'); - $data = array('required_status_checks' => null); + $expectedValue = ['required_status_checks', 'required_pull_reqeust_reviews', 'restrictions']; + $data = ['required_status_checks' => null]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -44,7 +44,7 @@ public function shouldUpdateProtection() */ public function shouldRemoveProtection() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -60,7 +60,7 @@ public function shouldRemoveProtection() */ public function shouldShowStatusChecks() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -76,8 +76,8 @@ public function shouldShowStatusChecks() */ public function shouldUpdateStatusChecks() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -93,7 +93,7 @@ public function shouldUpdateStatusChecks() */ public function shouldRemoveStatusChecks() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -109,7 +109,7 @@ public function shouldRemoveStatusChecks() */ public function shouldShowStatusChecksContexts() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -125,8 +125,8 @@ public function shouldShowStatusChecksContexts() */ public function shouldReplaceStatusChecksContexts() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -142,8 +142,8 @@ public function shouldReplaceStatusChecksContexts() */ public function shouldAddStatusChecksContexts() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -159,8 +159,8 @@ public function shouldAddStatusChecksContexts() */ public function shouldRemoveStatusChecksContexts() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -176,7 +176,7 @@ public function shouldRemoveStatusChecksContexts() */ public function shouldShowPullRequestReviewEnforcement() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -192,8 +192,8 @@ public function shouldShowPullRequestReviewEnforcement() */ public function shouldUpdatePullRequestReviewEnforcement() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -209,7 +209,7 @@ public function shouldUpdatePullRequestReviewEnforcement() */ public function shouldRemovePullRequestReviewEnforcement() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -225,7 +225,7 @@ public function shouldRemovePullRequestReviewEnforcement() */ public function shouldShowAdminEnforcement() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -241,7 +241,7 @@ public function shouldShowAdminEnforcement() */ public function shouldAddAdminEnforcement() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -257,7 +257,7 @@ public function shouldAddAdminEnforcement() */ public function shouldRemoveAdminEnforcement() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -273,7 +273,7 @@ public function shouldRemoveAdminEnforcement() */ public function shouldShowRestrictions() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -289,7 +289,7 @@ public function shouldShowRestrictions() */ public function shouldRemoveRestrictions() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -305,7 +305,7 @@ public function shouldRemoveRestrictions() */ public function shouldShowTeamRestrictions() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -321,8 +321,8 @@ public function shouldShowTeamRestrictions() */ public function shouldReplaceTeamRestrictions() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -338,8 +338,8 @@ public function shouldReplaceTeamRestrictions() */ public function shouldAddTeamRestrictions() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -355,8 +355,8 @@ public function shouldAddTeamRestrictions() */ public function shouldRemoveTeamRestrictions() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -372,7 +372,7 @@ public function shouldRemoveTeamRestrictions() */ public function shouldShowUserRestrictions() { - $expectedValue = array('someOutput'); + $expectedValue = ['someOutput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -388,8 +388,8 @@ public function shouldShowUserRestrictions() */ public function shouldReplaceUserRestrictions() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -405,8 +405,8 @@ public function shouldReplaceUserRestrictions() */ public function shouldAddUserRestrictions() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -422,8 +422,8 @@ public function shouldAddUserRestrictions() */ public function shouldRemoveUserRestrictions() { - $expectedValue = array('someOutput'); - $data = array('someInput'); + $expectedValue = ['someOutput']; + $data = ['someInput']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/ReleasesTest.php b/test/Github/Tests/Api/Repository/ReleasesTest.php index 64b164cb237..297ee283a08 100644 --- a/test/Github/Tests/Api/Repository/ReleasesTest.php +++ b/test/Github/Tests/Api/Repository/ReleasesTest.php @@ -11,7 +11,7 @@ class ReleasesTest extends TestCase */ public function shouldGetLatestRelease() { - $expectedValue = array('latest_release_data'); + $expectedValue = ['latest_release_data']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetLatestRelease() */ public function shouldGetReleaseByTag() { - $expectedValue = array('latest_release_data'); + $expectedValue = ['latest_release_data']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -47,7 +47,7 @@ public function shouldGetReleaseByTag() */ public function shouldGetAllRepositoryReleases() { - $expectedValue = array(array('release1data'), array('release2data')); + $expectedValue = [['release1data'], ['release2data']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -63,7 +63,7 @@ public function shouldGetAllRepositoryReleases() */ public function shouldGetSingleRepositoryRelease() { - $expectedValue = array('releaseData'); + $expectedValue = ['releaseData']; $id = 331; $api = $this->getApiMock(); @@ -80,8 +80,8 @@ public function shouldGetSingleRepositoryRelease() */ public function shouldCreateRepositoryRelease() { - $expectedValue = array('newReleaseData'); - $data = array('tag_name' => '1.1'); + $expectedValue = ['newReleaseData']; + $data = ['tag_name' => '1.1']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -98,7 +98,7 @@ public function shouldCreateRepositoryRelease() */ public function shouldNotCreateRepositoryReleaseWithoutTagName() { - $data = array('not_a_tag_name' => '1.1'); + $data = ['not_a_tag_name' => '1.1']; $api = $this->getApiMock(); $api->expects($this->never()) @@ -112,9 +112,9 @@ public function shouldNotCreateRepositoryReleaseWithoutTagName() */ public function shouldEditRepositoryRelease() { - $expectedValue = array('updatedData'); + $expectedValue = ['updatedData']; $id = 332; - $data = array('some' => 'thing'); + $data = ['some' => 'thing']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -130,7 +130,7 @@ public function shouldEditRepositoryRelease() */ public function shouldRemoveRepositoryRelease() { - $expectedValue = array('deleted'); + $expectedValue = ['deleted']; $id = 333; $api = $this->getApiMock(); diff --git a/test/Github/Tests/Api/Repository/StargazersTest.php b/test/Github/Tests/Api/Repository/StargazersTest.php index ef5e5d6d5f8..0552100556c 100644 --- a/test/Github/Tests/Api/Repository/StargazersTest.php +++ b/test/Github/Tests/Api/Repository/StargazersTest.php @@ -11,7 +11,7 @@ class StargazersTest extends TestCase */ public function shouldGetAllRepositoryStargazers() { - $expectedValue = array(array('login' => 'nidup')); + $expectedValue = [['login' => 'nidup']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -27,7 +27,7 @@ public function shouldGetAllRepositoryStargazers() */ public function shouldGetAllRepositoryStargazersWithAlternativeResponse() { - $expectedValue = array(array('starred_at' => '2013-10-01T13:22:01Z', 'user' => array('login' => 'nidup'))); + $expectedValue = [['starred_at' => '2013-10-01T13:22:01Z', 'user' => ['login' => 'nidup']]]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/StatusesTest.php b/test/Github/Tests/Api/Repository/StatusesTest.php index 9b64708d452..f286d79aa51 100644 --- a/test/Github/Tests/Api/Repository/StatusesTest.php +++ b/test/Github/Tests/Api/Repository/StatusesTest.php @@ -11,10 +11,10 @@ class StatusesTest extends TestCase */ public function shouldShowCommitStatuses() { - $expectedValue = array( - array('state' => 'success', 'context' => 'Travis'), - array('state' => 'pending', 'context' => 'Travis') - ); + $expectedValue = [ + ['state' => 'success', 'context' => 'Travis'], + ['state' => 'pending', 'context' => 'Travis'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -30,21 +30,21 @@ public function shouldShowCommitStatuses() */ public function shouldShowCombinedCommitStatuses() { - $expectedValue = array( - array( + $expectedValue = [ + [ 'state' => 'success', - 'statuses' => array( - array( + 'statuses' => [ + [ 'state' => 'success', - 'context' => 'Travis' - ), - array( + 'context' => 'Travis', + ], + [ 'state' => 'success', - 'context' => 'Jenkins' - ) - ) - ) - ); + 'context' => 'Jenkins', + ], + ], + ], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -61,7 +61,7 @@ public function shouldShowCombinedCommitStatuses() */ public function shouldNotCreateWithoutStatus() { - $data = array(); + $data = []; $api = $this->getApiMock(); $api->expects($this->never()) @@ -75,8 +75,8 @@ public function shouldNotCreateWithoutStatus() */ public function shouldCreateCommitStatus() { - $expectedValue = array('state' => 'success'); - $data = array('state' => 'success'); + $expectedValue = ['state' => 'success']; + $data = ['state' => 'success']; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/Api/Repository/TrafficTest.php b/test/Github/Tests/Api/Repository/TrafficTest.php index 5110c546240..f13a71ace1b 100644 --- a/test/Github/Tests/Api/Repository/TrafficTest.php +++ b/test/Github/Tests/Api/Repository/TrafficTest.php @@ -4,13 +4,12 @@ class TrafficTest extends TestCase { - /** * @test */ public function shouldgetReferers() { - $expectedValue = json_encode(["referrer" => "github.com","count" => 112,"uniques" => 15]); + $expectedValue = json_encode(['referrer' => 'github.com', 'count' => 112, 'uniques' => 15]); $api = $this->getApiMock(); @@ -26,7 +25,7 @@ public function shouldgetReferers() public function shouldgetPaths() { - $expectedValue = json_encode(["path" => "/knplabs/php-github-api","title" => "KnpLabs/php-github-api: A simple PHP GitHub API client, Object Oriented, tested and documented. For 5.5+.","count" => 203,"uniques" => 54]); + $expectedValue = json_encode(['path' => '/knplabs/php-github-api', 'title' => 'KnpLabs/php-github-api: A simple PHP GitHub API client, Object Oriented, tested and documented. For 5.5+.', 'count' => 203, 'uniques' => 54]); $api = $this->getApiMock(); @@ -42,7 +41,7 @@ public function shouldgetPaths() public function shouldgetViews() { - $expectedValue = json_encode(["count" => 813,"uniques" => 61,"views" => [["timestamp" => "2017-03-12T00:00:00Z","count" => 40,"uniques" => 3]]]); + $expectedValue = json_encode(['count' => 813, 'uniques' => 61, 'views' => [['timestamp' => '2017-03-12T00:00:00Z', 'count' => 40, 'uniques' => 3]]]); $api = $this->getApiMock(); @@ -58,7 +57,7 @@ public function shouldgetViews() public function shouldgetClones() { - $expectedValue = json_encode(["count" => 813,"uniques" => 61,"clones" => [["timestamp" => "2017-03-12T00:00:00Z","count" => 14,"uniques" => 8]]]); + $expectedValue = json_encode(['count' => 813, 'uniques' => 61, 'clones' => [['timestamp' => '2017-03-12T00:00:00Z', 'count' => 14, 'uniques' => 8]]]); $api = $this->getApiMock(); diff --git a/test/Github/Tests/Api/SearchTest.php b/test/Github/Tests/Api/SearchTest.php index c67fc96171c..60ebb6cd3e1 100644 --- a/test/Github/Tests/Api/SearchTest.php +++ b/test/Github/Tests/Api/SearchTest.php @@ -9,7 +9,7 @@ class SearchTest extends TestCase */ public function shouldSearchRepositoriesByQuery() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -17,7 +17,7 @@ public function shouldSearchRepositoriesByQuery() ->method('get') ->with( '/search/repositories', - array('q' => 'query text', 'sort' => 'updated', 'order' => 'desc') + ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] ) ->will($this->returnValue($expectedArray)); @@ -29,7 +29,7 @@ public function shouldSearchRepositoriesByQuery() */ public function shouldSearchRepositoriesRegardingSortAndOrder() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -37,7 +37,7 @@ public function shouldSearchRepositoriesRegardingSortAndOrder() ->method('get') ->with( '/search/repositories', - array('q' => 'query text', 'sort' => 'created', 'order' => 'asc') + ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] ) ->will($this->returnValue($expectedArray)); @@ -52,7 +52,7 @@ public function shouldSearchRepositoriesRegardingSortAndOrder() */ public function shouldSearchIssuesByQuery() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -60,7 +60,7 @@ public function shouldSearchIssuesByQuery() ->method('get') ->with( '/search/issues', - array('q' => 'query text', 'sort' => 'updated', 'order' => 'desc') + ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] ) ->will($this->returnValue($expectedArray)); @@ -72,7 +72,7 @@ public function shouldSearchIssuesByQuery() */ public function shouldSearchIssuesRegardingSortAndOrder() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -80,7 +80,7 @@ public function shouldSearchIssuesRegardingSortAndOrder() ->method('get') ->with( '/search/issues', - array('q' => 'query text', 'sort' => 'created', 'order' => 'asc') + ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] ) ->will($this->returnValue($expectedArray)); @@ -95,7 +95,7 @@ public function shouldSearchIssuesRegardingSortAndOrder() */ public function shouldSearchCodeByQuery() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -103,7 +103,7 @@ public function shouldSearchCodeByQuery() ->method('get') ->with( '/search/code', - array('q' => 'query text', 'sort' => 'updated', 'order' => 'desc') + ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] ) ->will($this->returnValue($expectedArray)); @@ -115,7 +115,7 @@ public function shouldSearchCodeByQuery() */ public function shouldSearchCodeRegardingSortAndOrder() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -123,7 +123,7 @@ public function shouldSearchCodeRegardingSortAndOrder() ->method('get') ->with( '/search/code', - array('q' => 'query text', 'sort' => 'created', 'order' => 'asc') + ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] ) ->will($this->returnValue($expectedArray)); @@ -138,7 +138,7 @@ public function shouldSearchCodeRegardingSortAndOrder() */ public function shouldSearchUsersByQuery() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -146,7 +146,7 @@ public function shouldSearchUsersByQuery() ->method('get') ->with( '/search/users', - array('q' => 'query text', 'sort' => 'updated', 'order' => 'desc') + ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] ) ->will($this->returnValue($expectedArray)); @@ -158,7 +158,7 @@ public function shouldSearchUsersByQuery() */ public function shouldSearchUsersRegardingSortAndOrder() { - $expectedArray = array(array('total_count' => '0')); + $expectedArray = [['total_count' => '0']]; $api = $this->getApiMock(); @@ -166,7 +166,7 @@ public function shouldSearchUsersRegardingSortAndOrder() ->method('get') ->with( '/search/users', - array('q' => 'query text', 'sort' => 'created', 'order' => 'asc') + ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] ) ->will($this->returnValue($expectedArray)); diff --git a/test/Github/Tests/Api/TestCase.php b/test/Github/Tests/Api/TestCase.php index c02e08bbde3..512a8fc4d87 100644 --- a/test/Github/Tests/Api/TestCase.php +++ b/test/Github/Tests/Api/TestCase.php @@ -2,7 +2,6 @@ namespace Github\Tests\Api; -use Github\HttpClient\Builder; use ReflectionMethod; abstract class TestCase extends \PHPUnit\Framework\TestCase @@ -18,7 +17,7 @@ abstract protected function getApiClass(); protected function getApiMock() { $httpClient = $this->getMockBuilder(\Http\Client\HttpClient::class) - ->setMethods(array('sendRequest')) + ->setMethods(['sendRequest']) ->getMock(); $httpClient ->expects($this->any()) @@ -27,14 +26,15 @@ protected function getApiMock() $client = \Github\Client::createWithHttpClient($httpClient); return $this->getMockBuilder($this->getApiClass()) - ->setMethods(array('get', 'post', 'postRaw', 'patch', 'delete', 'put', 'head')) - ->setConstructorArgs(array($client)) + ->setMethods(['get', 'post', 'postRaw', 'patch', 'delete', 'put', 'head']) + ->setConstructorArgs([$client]) ->getMock(); } /** * @param object $object * @param string $methodName + * * @return ReflectionMethod */ protected function getMethod($object, $methodName) diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index b93d62b3c03..fa56225fd1f 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -9,7 +9,7 @@ class UserTest extends TestCase */ public function shouldShowUser() { - $expectedArray = array('id' => 1, 'username' => 'l3l0'); + $expectedArray = ['id' => 1, 'username' => 'l3l0']; $api = $this->getApiMock(); $api->expects($this->once()) @@ -25,14 +25,14 @@ public function shouldShowUser() */ public function shouldGetUserOrganizations() { - $expectedArray = array(array( + $expectedArray = [[ 'id' => 202732, 'url' => 'https://api.github.com/orgs/KnpLabs', 'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos', 'events_url' => 'https://api.github.com/orgs/KnpLabs/events', 'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}', - 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}' - )); + 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}', + ]]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -45,14 +45,14 @@ public function shouldGetUserOrganizations() public function shouldGetUserOrgs() { - $expectedArray = array(array( + $expectedArray = [[ 'id' => 202732, 'url' => 'https://api.github.com/orgs/KnpLabs', 'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos', 'events_url' => 'https://api.github.com/orgs/KnpLabs/events', 'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}', - 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}' - )); + 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}', + ]]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -68,10 +68,10 @@ public function shouldGetUserOrgs() */ public function shouldGetAllUsers() { - $expectedArray = array( - array('id' => 1, 'username' => 'l3l0'), - array('id' => 2, 'username' => 'l3l0test') - ); + $expectedArray = [ + ['id' => 1, 'username' => 'l3l0'], + ['id' => 2, 'username' => 'l3l0test'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -87,10 +87,10 @@ public function shouldGetAllUsers() */ public function shouldGetAllUsersSince() { - $expectedArray = array( - array('id' => 3, 'username' => 'test3'), - array('id' => 4, 'username' => 'test4') - ); + $expectedArray = [ + ['id' => 3, 'username' => 'test3'], + ['id' => 4, 'username' => 'test4'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -106,10 +106,10 @@ public function shouldGetAllUsersSince() */ public function shouldSearchUsers() { - $expectedArray = array( - array('id' => 1, 'username' => 'l3l0'), - array('id' => 2, 'username' => 'l3l0test') - ); + $expectedArray = [ + ['id' => 1, 'username' => 'l3l0'], + ['id' => 2, 'username' => 'l3l0test'], + ]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -125,7 +125,7 @@ public function shouldSearchUsers() */ public function shouldGetFollowingUsers() { - $expectedArray = array(array('id' => 1, 'username' => 'l3l0test')); + $expectedArray = [['id' => 1, 'username' => 'l3l0test']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -141,7 +141,7 @@ public function shouldGetFollowingUsers() */ public function shouldGetUserFollowers() { - $expectedArray = array(array('id' => 1, 'username' => 'l3l0test')); + $expectedArray = [['id' => 1, 'username' => 'l3l0test']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -157,7 +157,7 @@ public function shouldGetUserFollowers() */ public function shouldGetStarredToRepositories() { - $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -173,7 +173,7 @@ public function shouldGetStarredToRepositories() */ public function shouldGetSubscriptionsToRepositories() { - $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) @@ -189,12 +189,12 @@ public function shouldGetSubscriptionsToRepositories() */ public function shouldGetUserRepositories() { - $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('/users/l3l0/repos', array('type' => 'owner', 'sort' => 'full_name', 'direction' => 'asc')) + ->with('/users/l3l0/repos', ['type' => 'owner', 'sort' => 'full_name', 'direction' => 'asc']) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->repositories('l3l0')); @@ -220,7 +220,7 @@ public function shouldGetMyRepositories() */ public function shouldGetUserGists() { - $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; $api = $this->getApiMock(); $api->expects($this->once()) diff --git a/test/Github/Tests/ClientTest.php b/test/Github/Tests/ClientTest.php index 3be0e3ba44e..b92abe0599b 100644 --- a/test/Github/Tests/ClientTest.php +++ b/test/Github/Tests/ClientTest.php @@ -8,7 +8,6 @@ use Github\HttpClient\Builder; use Github\HttpClient\Plugin\Authentication; use GuzzleHttp\Psr7\Response; -use Http\Client\Common\Plugin; use Http\Client\HttpClient; use Psr\Http\Message\RequestInterface; @@ -44,7 +43,7 @@ public function shouldPassHttpClientInterfaceToConstructor() public function shouldAuthenticateUsingAllGivenParameters($login, $password, $method) { $builder = $this->getMockBuilder(\Github\HttpClient\Builder::class) - ->setMethods(array('addPlugin', 'removePlugin')) + ->setMethods(['addPlugin', 'removePlugin']) ->disableOriginalConstructor() ->getMock(); $builder->expects($this->once()) @@ -67,12 +66,12 @@ public function shouldAuthenticateUsingAllGivenParameters($login, $password, $me public function getAuthenticationFullData() { - return array( - array('login', 'password', Client::AUTH_HTTP_PASSWORD), - array('token', null, Client::AUTH_HTTP_TOKEN), - array('token', null, Client::AUTH_URL_TOKEN), - array('client_id', 'client_secret', Client::AUTH_URL_CLIENT_ID), - ); + return [ + ['login', 'password', Client::AUTH_HTTP_PASSWORD], + ['token', null, Client::AUTH_HTTP_TOKEN], + ['token', null, Client::AUTH_URL_TOKEN], + ['client_id', 'client_secret', Client::AUTH_URL_CLIENT_ID], + ]; } /** @@ -82,7 +81,7 @@ public function getAuthenticationFullData() public function shouldAuthenticateUsingGivenParameters($token, $method) { $builder = $this->getMockBuilder(\Github\HttpClient\Builder::class) - ->setMethods(array('addPlugin', 'removePlugin')) + ->setMethods(['addPlugin', 'removePlugin']) ->getMock(); $builder->expects($this->once()) ->method('addPlugin') @@ -105,10 +104,10 @@ public function shouldAuthenticateUsingGivenParameters($token, $method) public function getAuthenticationPartialData() { - return array( - array('token', Client::AUTH_HTTP_TOKEN), - array('token', Client::AUTH_URL_TOKEN), - ); + return [ + ['token', Client::AUTH_HTTP_TOKEN], + ['token', Client::AUTH_URL_TOKEN], + ]; } /** @@ -166,47 +165,47 @@ public function shouldNotGetMagicApiInstance() public function getApiClassesProvider() { - return array( - array('user', Api\User::class), - array('users', Api\User::class), + return [ + ['user', Api\User::class], + ['users', Api\User::class], - array('me', Api\CurrentUser::class), - array('current_user', Api\CurrentUser::class), - array('currentUser', Api\CurrentUser::class), + ['me', Api\CurrentUser::class], + ['current_user', Api\CurrentUser::class], + ['currentUser', Api\CurrentUser::class], - array('git', Api\GitData::class), - array('git_data', Api\GitData::class), - array('gitData', Api\GitData::class), + ['git', Api\GitData::class], + ['git_data', Api\GitData::class], + ['gitData', Api\GitData::class], - array('gist', Api\Gists::class), - array('gists', Api\Gists::class), + ['gist', Api\Gists::class], + ['gists', Api\Gists::class], - array('issue', Api\Issue::class), - array('issues', Api\Issue::class), + ['issue', Api\Issue::class], + ['issues', Api\Issue::class], - array('markdown', Api\Markdown::class), + ['markdown', Api\Markdown::class], - array('organization', Api\Organization::class), - array('organizations', Api\Organization::class), + ['organization', Api\Organization::class], + ['organizations', Api\Organization::class], - array('repo', Api\Repo::class), - array('repos', Api\Repo::class), - array('repository', Api\Repo::class), - array('repositories', Api\Repo::class), + ['repo', Api\Repo::class], + ['repos', Api\Repo::class], + ['repository', Api\Repo::class], + ['repositories', Api\Repo::class], - array('search', Api\Search::class), + ['search', Api\Search::class], - array('pr', Api\PullRequest::class), - array('pullRequest', Api\PullRequest::class), - array('pull_request', Api\PullRequest::class), - array('pullRequests', Api\PullRequest::class), - array('pull_requests', Api\PullRequest::class), + ['pr', Api\PullRequest::class], + ['pullRequest', Api\PullRequest::class], + ['pull_request', Api\PullRequest::class], + ['pullRequests', Api\PullRequest::class], + ['pull_requests', Api\PullRequest::class], - array('authorization', Api\Authorizations::class), - array('authorizations', Api\Authorizations::class), + ['authorization', Api\Authorizations::class], + ['authorizations', Api\Authorizations::class], - array('meta', Api\Meta::class) - ); + ['meta', Api\Meta::class], + ]; } /** diff --git a/test/Github/Tests/Functional/CacheTest.php b/test/Github/Tests/Functional/CacheTest.php index 1af87ce63d6..6fd190dbca8 100644 --- a/test/Github/Tests/Functional/CacheTest.php +++ b/test/Github/Tests/Functional/CacheTest.php @@ -32,6 +32,7 @@ public function shouldServeCachedResponse() $userB = $github->currentUser()->show(); $this->assertEquals('nyholm', $userB['login'], 'Two request following each other should be cached.'); } + /** * @test */ diff --git a/test/Github/Tests/HttpClient/BuilderTest.php b/test/Github/Tests/HttpClient/BuilderTest.php index d04aa496bd8..33d21025f0e 100644 --- a/test/Github/Tests/HttpClient/BuilderTest.php +++ b/test/Github/Tests/HttpClient/BuilderTest.php @@ -15,7 +15,7 @@ class BuilderTest extends \PHPUnit\Framework\TestCase public function shouldClearHeaders() { $builder = $this->getMockBuilder(\Github\HttpClient\Builder::class) - ->setMethods(array('addPlugin', 'removePlugin')) + ->setMethods(['addPlugin', 'removePlugin']) ->getMock(); $builder->expects($this->once()) ->method('addPlugin') @@ -33,10 +33,10 @@ public function shouldClearHeaders() */ public function shouldAddHeaders() { - $headers = array('header1', 'header2'); + $headers = ['header1', 'header2']; $client = $this->getMockBuilder(\Github\HttpClient\Builder::class) - ->setMethods(array('addPlugin', 'removePlugin')) + ->setMethods(['addPlugin', 'removePlugin']) ->getMock(); $client->expects($this->once()) ->method('addPlugin') @@ -60,7 +60,7 @@ public function appendingHeaderShouldAddAndRemovePlugin() ]; $client = $this->getMockBuilder(\Github\HttpClient\Builder::class) - ->setMethods(array('removePlugin', 'addPlugin')) + ->setMethods(['removePlugin', 'addPlugin']) ->getMock(); $client->expects($this->once()) diff --git a/test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php b/test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php index d8f246c919d..c14eac8a297 100644 --- a/test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php +++ b/test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php @@ -12,10 +12,10 @@ class ResponseMediatorTest extends \PHPUnit\Framework\TestCase { public function testGetContent() { - $body = array('foo' => 'bar'); + $body = ['foo' => 'bar']; $response = new Response( 200, - array('Content-Type'=>'application/json'), + ['Content-Type'=>'application/json'], \GuzzleHttp\Psr7\stream_for(json_encode($body)) ); @@ -30,7 +30,7 @@ public function testGetContentNotJson() $body = 'foobar'; $response = new Response( 200, - array(), + [], \GuzzleHttp\Psr7\stream_for($body) ); @@ -38,14 +38,14 @@ public function testGetContentNotJson() } /** - * Make sure we return the body if we have invalid json + * Make sure we return the body if we have invalid json. */ public function testGetContentInvalidJson() { $body = 'foobar'; $response = new Response( 200, - array('Content-Type'=>'application/json'), + ['Content-Type'=>'application/json'], \GuzzleHttp\Psr7\stream_for($body) ); @@ -54,22 +54,22 @@ public function testGetContentInvalidJson() public function testGetPagination() { - $header = <<; rel="first", ; rel="next", ; rel="prev", ; rel="last", TEXT; - $pagination = array( + $pagination = [ 'first' => 'http://github.com', 'next' => 'http://github.com', 'prev' => 'http://github.com', - 'last' => 'http://github.com' - ); + 'last' => 'http://github.com', + ]; // response mock - $response = new Response(200, array('link'=>$header)); + $response = new Response(200, ['link'=>$header]); $result = ResponseMediator::getPagination($response); $this->assertEquals($pagination, $result); @@ -80,7 +80,7 @@ public function testGetHeader() $header = 'application/json'; $response = new Response( 200, - array('Content-Type'=> $header) + ['Content-Type'=> $header] ); $this->assertEquals($header, ResponseMediator::getHeader($response, 'content-type')); diff --git a/test/Github/Tests/HttpClient/PathPrependTest.php b/test/Github/Tests/HttpClient/PathPrependTest.php index dbd7905c739..fdfe180980a 100644 --- a/test/Github/Tests/HttpClient/PathPrependTest.php +++ b/test/Github/Tests/HttpClient/PathPrependTest.php @@ -23,7 +23,7 @@ public function testPathIsPrepended($uri, $expectedPath) $plugin->handleRequest($request, function ($request) use (&$newRequest) { $newRequest = $request; }, function () { - throw new \RuntimeException("Did not expect plugin to call first"); + throw new \RuntimeException('Did not expect plugin to call first'); }); $this->assertEquals($expectedPath, $newRequest->getUri()->getPath()); diff --git a/test/Github/Tests/Integration/CommitTest.php b/test/Github/Tests/Integration/CommitTest.php index 8dcaa0d022e..2134bab2f65 100644 --- a/test/Github/Tests/Integration/CommitTest.php +++ b/test/Github/Tests/Integration/CommitTest.php @@ -13,11 +13,11 @@ class CommitTest extends TestCase public function shouldRetrieveCommitsForRepositoryBranch() { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $branch = 'master'; + $repo = 'php-github-api'; + $branch = 'master'; - $commits = $this->client->api('repo')->commits()->all($username, $repo, array('sha' => $branch)); - $commit = array_pop($commits); + $commits = $this->client->api('repo')->commits()->all($username, $repo, ['sha' => $branch]); + $commit = array_pop($commits); $this->assertArrayHasKey('url', $commit); $this->assertArrayHasKey('committer', $commit); @@ -32,7 +32,7 @@ public function shouldRetrieveCommitsForRepositoryBranch() public function shouldRetrieveCommitBySha() { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $commit = $this->client->api('repo')->commits()->show($username, $repo, '6df3adf5bd16745299c6429e163265daed430fa1'); @@ -50,10 +50,10 @@ public function shouldRetrieveCommitBySha() public function shouldRetrieveCommitsForFile() { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $branch = 'master'; + $repo = 'php-github-api'; + $branch = 'master'; - $commits = $this->client->api('repo')->commits()->all($username, $repo, array('sha' => $branch, 'path' => 'composer.json')); + $commits = $this->client->api('repo')->commits()->all($username, $repo, ['sha' => $branch, 'path' => 'composer.json']); $commit = array_pop($commits); $this->assertArrayHasKey('url', $commit); diff --git a/test/Github/Tests/Integration/IssueCommentTest.php b/test/Github/Tests/Integration/IssueCommentTest.php index d035182151a..3db9ce8bb46 100644 --- a/test/Github/Tests/Integration/IssueCommentTest.php +++ b/test/Github/Tests/Integration/IssueCommentTest.php @@ -13,11 +13,11 @@ class IssueCommentTest extends TestCase public function shouldRetrieveCommentsForIssue() { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $issue = 13; + $repo = 'php-github-api'; + $issue = 13; $comments = $this->client->api('issue')->comments()->all($username, $repo, $issue); - $comment = array_pop($comments); + $comment = array_pop($comments); $this->assertArrayHasKey('id', $comment); $this->assertArrayHasKey('url', $comment); @@ -36,7 +36,7 @@ public function shouldRetrieveCommentsForIssue() public function shouldRetrieveSingleComment($commentId) { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $comment = $this->client->api('issue')->comments()->show($username, $repo, $commentId); @@ -54,9 +54,9 @@ public function shouldRetrieveSingleComment($commentId) public function shouldCreateCommentForIssue() { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $issue = 13; - $params = array('body' => '%'); + $repo = 'php-github-api'; + $issue = 13; + $params = ['body' => '%']; $comment = $this->client->api('issue')->comments()->create($username, $repo, $issue, $params); @@ -69,6 +69,7 @@ public function shouldCreateCommentForIssue() return $comment['id']; } + /** * @test * @depends shouldCreateCommentForIssue @@ -76,8 +77,8 @@ public function shouldCreateCommentForIssue() public function shouldUpdateCommentByCommentId($commentId) { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $params = array('body' => 'test update'); + $repo = 'php-github-api'; + $params = ['body' => 'test update']; $comment = $this->client->api('issue')->comments()->update($username, $repo, $commentId, $params); @@ -98,7 +99,7 @@ public function shouldUpdateCommentByCommentId($commentId) public function shouldRemoveCommentByCommentId($commentId) { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $this->client->api('issue')->comments()->remove($username, $repo, $commentId); } diff --git a/test/Github/Tests/Integration/MarkdownTest.php b/test/Github/Tests/Integration/MarkdownTest.php index fa4f413a3da..1dd956019fe 100644 --- a/test/Github/Tests/Integration/MarkdownTest.php +++ b/test/Github/Tests/Integration/MarkdownTest.php @@ -17,15 +17,15 @@ public function shouldRetrieveParsedMarkdownContent() /** @var Markdown $api */ $api = $this->client->api('markdown'); - $input = 'Hello world github/linguist#1 **cool**, and #1!'; + $input = 'Hello world github/linguist#1 **cool**, and #1!'; $output = '

Hello world github/linguist#1 cool, and #1!

'; - $html = $api->render($input); + $html = $api->render($input); $this->assertEquals($output, $html); - $input = 'Hello world KnpLabs/KnpBundles#1 **cool**, and #1!'; + $input = 'Hello world KnpLabs/KnpBundles#1 **cool**, and #1!'; $output = '

Hello world KnpLabs/KnpBundles#1 cool, and #1!

'; - $html = $api->render($input, 'gfm', 'KnpLabs/KnpMenu'); + $html = $api->render($input, 'gfm', 'KnpLabs/KnpMenu'); $this->assertEquals($output, $html); } diff --git a/test/Github/Tests/Integration/RateLimitTest.php b/test/Github/Tests/Integration/RateLimitTest.php index d0f0015f2c0..64599e7c679 100644 --- a/test/Github/Tests/Integration/RateLimitTest.php +++ b/test/Github/Tests/Integration/RateLimitTest.php @@ -15,6 +15,6 @@ public function shouldRetrievedRateLimits() $response = $this->client->api('rate_limit')->getRateLimits(); $this->assertArrayHasKey('resources', $response); - $this->assertArraySubset(array('resources' => array('core' => array('limit' => 60))), $response); + $this->assertArraySubset(['resources' => ['core' => ['limit' => 60]]], $response); } } diff --git a/test/Github/Tests/Integration/RepoCommentTest.php b/test/Github/Tests/Integration/RepoCommentTest.php index a6447e8a0df..b2d5dec528a 100644 --- a/test/Github/Tests/Integration/RepoCommentTest.php +++ b/test/Github/Tests/Integration/RepoCommentTest.php @@ -13,10 +13,10 @@ class RepoCommentTest extends TestCase public function shouldRetrieveComments() { $username = 'fabpot'; - $repo = 'Twig'; + $repo = 'Twig'; $comments = $this->client->api('repo')->comments()->all($username, $repo); - $comment = array_pop($comments); + $comment = array_pop($comments); $this->assertArrayHasKey('line', $comment); $this->assertArrayHasKey('body', $comment); @@ -32,11 +32,11 @@ public function shouldRetrieveComments() public function shouldRetrieveCommentsForCommit() { $username = 'fabpot'; - $repo = 'Twig'; - $sha = '3506cfad1d946f4a87e8c55849a18044efe2d5dc'; + $repo = 'Twig'; + $sha = '3506cfad1d946f4a87e8c55849a18044efe2d5dc'; $comments = $this->client->api('repo')->comments()->all($username, $repo, $sha); - $comment = array_pop($comments); + $comment = array_pop($comments); $this->assertArrayHasKey('line', $comment); $this->assertArrayHasKey('body', $comment); @@ -52,9 +52,9 @@ public function shouldRetrieveCommentsForCommit() public function shouldCreateCommentForCommit() { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $sha = '22655813eb54e7d4e21545e396f919bcd245b50d'; - $params = array('body' => '%'); + $repo = 'php-github-api'; + $sha = '22655813eb54e7d4e21545e396f919bcd245b50d'; + $params = ['body' => '%']; $comment = $this->client->api('repo')->comments()->create($username, $repo, $sha, $params); @@ -75,7 +75,7 @@ public function shouldCreateCommentForCommit() public function shouldShowCommentByCommentId($commentId) { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $comment = $this->client->api('repo')->comments()->show($username, $repo, $commentId); @@ -96,8 +96,8 @@ public function shouldShowCommentByCommentId($commentId) public function shouldUpdateCommentByCommentId($commentId) { $username = 'KnpLabs'; - $repo = 'php-github-api'; - $params = array('body' => 'test update'); + $repo = 'php-github-api'; + $params = ['body' => 'test update']; $comment = $this->client->api('repo')->comments()->update($username, $repo, $commentId, $params); @@ -118,7 +118,7 @@ public function shouldUpdateCommentByCommentId($commentId) public function shouldRemoveCommentByCommentId($commentId) { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $this->client->api('repo')->comments()->remove($username, $repo, $commentId); } diff --git a/test/Github/Tests/Integration/RepoTest.php b/test/Github/Tests/Integration/RepoTest.php index 90328b909aa..076175f2523 100644 --- a/test/Github/Tests/Integration/RepoTest.php +++ b/test/Github/Tests/Integration/RepoTest.php @@ -13,10 +13,10 @@ class RepoTest extends TestCase public function shouldShowPRDiffIfHeaderIsPresent() { $this->client->addHeaders( - array('Accept' => sprintf( + ['Accept' => sprintf( 'application/vnd.github.%s.diff', $this->client->getApiVersion() - )) + )] ); $diff = $this->client->api('pull_request')->show('KnpLabs', 'php-github-api', '92'); @@ -66,7 +66,7 @@ public function shouldNotDecodeRawBlob() public function shouldRetrieveContributorsList() { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $contributors = $this->client->api('repo')->contributors($username, $repo); $contributor = array_pop($contributors); @@ -85,7 +85,7 @@ public function shouldRetrieveContributorsList() public function shouldShowRepo() { $username = 'KnpLabs'; - $repo = 'php-github-api'; + $repo = 'php-github-api'; $repo = $this->client->api('repo')->show($username, $repo); diff --git a/test/Github/Tests/Integration/ResultPagerTest.php b/test/Github/Tests/Integration/ResultPagerTest.php index d533d2ac952..447c52913ed 100644 --- a/test/Github/Tests/Integration/ResultPagerTest.php +++ b/test/Github/Tests/Integration/ResultPagerTest.php @@ -19,11 +19,11 @@ public function shouldPaginateGetRequests() $pager = $this->createPager(); - $repositories = $pager->fetch($repositoriesApi, 'repositories', array('KnpLabs')); + $repositories = $pager->fetch($repositoriesApi, 'repositories', ['KnpLabs']); $this->assertCount(10, $repositories); $repositoriesApi->setPerPage(20); - $repositories = $pager->fetch($repositoriesApi, 'repositories', array('KnpLabs')); + $repositories = $pager->fetch($repositoriesApi, 'repositories', ['KnpLabs']); $this->assertCount(20, $repositories); } @@ -47,7 +47,7 @@ public function shouldGetAllResultsFromSearchApi() $pager = $this->createPager(); - $users = $pager->fetch($searchApi, 'users', array('location:Kyiv')); + $users = $pager->fetch($searchApi, 'users', ['location:Kyiv']); $this->assertCount(10, $users); } diff --git a/test/Github/Tests/Integration/UserTest.php b/test/Github/Tests/Integration/UserTest.php index 41a14ac424f..d08f1d643a2 100644 --- a/test/Github/Tests/Integration/UserTest.php +++ b/test/Github/Tests/Integration/UserTest.php @@ -36,7 +36,7 @@ public function shouldShowUserData() */ public function shouldNotUpdateUserWithoutAuthorization() { - $this->client->api('current_user')->update(array('email' => 'leszek.prabucki@gmail.com')); + $this->client->api('current_user')->update(['email' => 'leszek.prabucki@gmail.com']); } /** diff --git a/test/Github/Tests/Mock/PaginatedResponse.php b/test/Github/Tests/Mock/PaginatedResponse.php index 13d2e815fc0..4586de402ec 100644 --- a/test/Github/Tests/Mock/PaginatedResponse.php +++ b/test/Github/Tests/Mock/PaginatedResponse.php @@ -16,18 +16,18 @@ class PaginatedResponse extends Response public function __construct($loopCount, array $content = []) { $this->loopCount = $loopCount; - $this->content = $content; + $this->content = $content; - parent::__construct(200, array('Content-Type'=>'application/json'), \GuzzleHttp\Psr7\stream_for(json_encode($content))); + parent::__construct(200, ['Content-Type'=>'application/json'], \GuzzleHttp\Psr7\stream_for(json_encode($content))); } public function getHeader($header) { if ($header === 'Link') { if ($this->loopCount > 1) { - $header = array(sprintf('; rel="next"', $this->loopCount)); + $header = [sprintf('; rel="next"', $this->loopCount)]; } else { - $header = array('; rel="prev"'); + $header = ['; rel="prev"']; } $this->loopCount--; diff --git a/test/Github/Tests/ResultPagerTest.php b/test/Github/Tests/ResultPagerTest.php index 17be7278ffa..a105a84f054 100644 --- a/test/Github/Tests/ResultPagerTest.php +++ b/test/Github/Tests/ResultPagerTest.php @@ -2,11 +2,8 @@ namespace Github\Tests; -use Github\Api\Organization; use Github\Api\Organization\Members; use Github\Api\Search; -use Github\Client; -use Github\HttpClient\Builder; use Github\ResultPager; use Github\Tests\Mock\PaginatedResponse; use Http\Client\HttpClient; @@ -28,12 +25,12 @@ class ResultPagerTest extends \PHPUnit\Framework\TestCase public function shouldGetAllResults() { $amountLoops = 3; - $content = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + $content = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; $response = new PaginatedResponse($amountLoops, $content); // httpClient mock $httpClientMock = $this->getMockBuilder(\Http\Client\HttpClient::class) - ->setMethods(array('sendRequest')) + ->setMethods(['sendRequest']) ->getMock(); $httpClientMock ->expects($this->exactly($amountLoops)) @@ -46,7 +43,7 @@ public function shouldGetAllResults() $memberApi = new Members($client); $method = 'all'; - $parameters = array('netwerven'); + $parameters = ['netwerven']; // Run fetchAll on result paginator $paginator = new ResultPager($client); @@ -72,15 +69,15 @@ public function shouldGetAllSearchResults() { $amountLoops = 3; - $content = array( + $content = [ 'total_count' => 12, - 'items' => array(1, 2, 3, 4) - ); + 'items' => [1, 2, 3, 4], + ]; $response = new PaginatedResponse($amountLoops, $content); // httpClient mock $httpClientMock = $this->getMockBuilder(\Http\Client\HttpClient::class) - ->setMethods(array('sendRequest')) + ->setMethods(['sendRequest']) ->getMock(); $httpClientMock ->expects($this->exactly($amountLoops)) @@ -92,7 +89,7 @@ public function shouldGetAllSearchResults() $searchApi = new Search($client); $method = 'users'; $paginator = new ResultPager($client); - $result = $paginator->fetchAll($searchApi, $method, array('knplabs')); + $result = $paginator->fetchAll($searchApi, $method, ['knplabs']); $this->assertCount($amountLoops * count($content['items']), $result); } @@ -101,13 +98,13 @@ public function testFetch() { $result = 'foo'; $method = 'bar'; - $parameters = array('baz'); + $parameters = ['baz']; $api = $this->getMockBuilder(\Github\Api\ApiInterface::class) ->getMock(); $paginator = $this->getMockBuilder(\Github\ResultPager::class) ->disableOriginalConstructor() - ->setMethods(array('callApi', 'postFetch')) + ->setMethods(['callApi', 'postFetch']) ->getMock(); $paginator->expects($this->once()) ->method('callApi')