Skip to content

Commit 4848d70

Browse files
author
Южаков Георгий
committed
Code style fix
1 parent bddde31 commit 4848d70

208 files changed

Lines changed: 5998 additions & 6260 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ Extensions
111111

112112
Tests
113113
------
114-
To run the tests, run the command
115114
```bash
116115
composer tests
117116
```

examples/amazon.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<?php
22

33
/**
4-
* Example of retrieving an authentication token of the Amazon service
4+
* Example of retrieving an authentication token of the Amazon service.
55
*
66
* PHP version 5.4
77
*
88
* @author Flávio Heleno <flaviohbatista@gmail.com>
9-
* @copyright Copyright (c) 2012 The authors
109
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1110
*/
1211

13-
use OAuth\OAuth2\Service\Amazon;
14-
use OAuth\Common\Storage\Session;
1512
use OAuth\Common\Consumer\Credentials;
13+
use OAuth\Common\Storage\Session;
14+
use OAuth\OAuth2\Service\Amazon;
1615

1716
/**
18-
* Bootstrap the example
17+
* Bootstrap the example.
1918
*/
2019
require_once __DIR__ . '/bootstrap.php';
2120

@@ -30,8 +29,8 @@
3029
);
3130

3231
// Instantiate the Amazon service using the credentials, http client, storage mechanism for the token and profile scope
33-
/** @var $amazonService Amazon */
34-
$amazonService = $serviceFactory->createService('amazon', $credentials, $storage, array('profile'));
32+
/** @var Amazon $amazonService */
33+
$amazonService = $serviceFactory->createService('amazon', $credentials, $storage, ['profile']);
3534

3635
if (!empty($_GET['code'])) {
3736
// This was a callback request from Amazon, get the token
@@ -42,7 +41,6 @@
4241

4342
// Show some of the resultant data
4443
echo 'Your unique Amazon user id is: ' . $result['user_id'] . ' and your name is ' . $result['name'];
45-
4644
} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') {
4745
$url = $amazonService->getAuthorizationUri();
4846
header('Location: ' . $url);

examples/battlenet.php

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66
* PHP version 5.4
77
*
88
* @author Mukunda Johnson (mukunda.com)
9-
* @copyright Copyright (c) 2012 The authors
109
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1110
*/
1211

13-
use OAuth\OAuth2\Service\BattleNet;
14-
use OAuth\Common\Storage\Session;
1512
use OAuth\Common\Consumer\Credentials;
1613
use OAuth\Common\Http\Uri\Uri;
14+
use OAuth\Common\Storage\Session;
15+
use OAuth\OAuth2\Service\BattleNet;
1716

1817
/** ---------------------------------------------------------------------------
19-
* Bootstrap the example
18+
* Bootstrap the example.
2019
*/
2120
require_once __DIR__ . '/bootstrap.php';
2221

23-
if( empty( $_GET['code'] ) && !isset($_GET['go'] )) {
22+
if (empty($_GET['code']) && !isset($_GET['go'])) {
2423

2524
// Empty query; show the startup page.
26-
25+
2726
echo '
2827
2928
<p>Sign-in using Battle.net. Please pick your region:</p>
@@ -37,7 +36,7 @@
3736
</p>
3837
3938
';
40-
39+
4140
die();
4241
}
4342

@@ -54,40 +53,37 @@
5453
$servicesCredentials['battlenet']['secret'],
5554
$currentUri->getAbsoluteUri()
5655
);
57-
58-
$region = isset($_GET['region']) ? $_GET['region'] : "";
5956

60-
$region_map = array(
57+
$region = $_GET['region'] ?? '';
58+
59+
$region_map = [
6160
'us' => BattleNet::API_URI_US, // USA - this is the default if you omit the base API URI.
6261
'eu' => BattleNet::API_URI_EU, // Europe
6362
'kr' => BattleNet::API_URI_KR, // Korea
6463
'tw' => BattleNet::API_URI_TW, // Taiwan
6564
'cn' => BattleNet::API_URI_CN, // China
66-
);
65+
];
6766

6867
// Get base API URI from region.
69-
$apiuri = isset( $region_map[$region] ) ? new Uri( $region_map[$region] ) : null;
68+
$apiuri = isset($region_map[$region]) ? new Uri($region_map[$region]) : null;
7069

7170
// Without any scopes, we can get their BattleTag.
72-
$scopes = array();
71+
$scopes = [];
7372

74-
$battlenetService = $serviceFactory->createService(
75-
'battlenet', $credentials, $storage, $scopes, $apiuri );
73+
$battlenetService = $serviceFactory->createService(
74+
'battlenet', $credentials, $storage, $scopes, $apiuri);
7675

77-
if( !empty($_GET['code']) ) {
76+
if (!empty($_GET['code'])) {
7877
// This was a callback request from Battle.net, get the token
79-
$token = $battlenetService->requestAccessToken( $_GET['code'] );
78+
$token = $battlenetService->requestAccessToken($_GET['code']);
8079

8180
// See https://dev.battle.net/io-docs for OAuth request types.
8281
//
8382
// Without any scopes specified, we can get their BattleTag.
84-
$result = json_decode( $battlenetService->request('/account/user') );
83+
$result = json_decode($battlenetService->request('/account/user'));
8584

8685
echo "Your BattleTag is \"$result->battletag\".";
87-
88-
} elseif( isset($_GET['go']) ) {
89-
86+
} elseif (isset($_GET['go'])) {
9087
$url = $battlenetService->getAuthorizationUri();
91-
header( "Location: $url" );
92-
88+
header("Location: $url");
9389
}

examples/bitbucket.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
22

33
/**
4-
* Example of retrieving an authentication token from the BitBucket service
4+
* Example of retrieving an authentication token from the BitBucket service.
55
*
66
* PHP version 5.4
7+
*
78
* @author Ændrew Rininsland <me@aendrew.com>
8-
*
9+
*
910
* Shamelessly cribbed from work by:
1011
* @author David Desberg <david@daviddesberg.com>
1112
* @author Pieter Hordijk <info@pieterhordijk.com>
12-
* @copyright Copyright (c) 2012 The authors
1313
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1414
*/
1515

16-
use OAuth\OAuth1\Service\BitBucket;
17-
use OAuth\Common\Storage\Session;
1816
use OAuth\Common\Consumer\Credentials;
17+
use OAuth\Common\Storage\Session;
18+
use OAuth\OAuth1\Service\BitBucket;
1919

2020
/**
21-
* Bootstrap the example
21+
* Bootstrap the example.
2222
*/
2323
require_once __DIR__ . '/bootstrap.php';
2424

@@ -34,7 +34,7 @@
3434
);
3535

3636
// Instantiate the BitBucket service using the credentials, http client and storage mechanism for the token
37-
/** @var $bbService BitBucket */
37+
/** @var BitBucket $bbService */
3838
$bbService = $serviceFactory->createService('BitBucket', $credentials, $storage);
3939

4040
if (!empty($_GET['oauth_token'])) {
@@ -50,13 +50,12 @@
5050
// Send a request now that we have access token
5151
$result = json_decode($bbService->request('user/repositories'));
5252

53-
echo('The first repo in the list is ' . $result[0]->name);
54-
53+
echo 'The first repo in the list is ' . $result[0]->name;
5554
} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') {
5655
// extra request needed for oauth1 to request a request token :-)
5756
$token = $bbService->requestRequestToken();
5857

59-
$url = $bbService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
58+
$url = $bbService->getAuthorizationUri(['oauth_token' => $token->getRequestToken()]);
6059
header('Location: ' . $url);
6160
} else {
6261
$url = $currentUri->getRelativeUri() . '?go=go';

examples/bitly.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<?php
22

33
/**
4-
* Example of retrieving an authentication token of the Bitly service
4+
* Example of retrieving an authentication token of the Bitly service.
55
*
66
* PHP version 5.4
77
*
88
* @author David Desberg <david@daviddesberg.com>
99
* @author Pieter Hordijk <info@pieterhordijk.com>
10-
* @copyright Copyright (c) 2012 The authors
1110
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1211
*/
1312

14-
use OAuth\OAuth2\Service\Bitly;
15-
use OAuth\Common\Storage\Session;
1613
use OAuth\Common\Consumer\Credentials;
14+
use OAuth\Common\Storage\Session;
15+
use OAuth\OAuth2\Service\Bitly;
1716

1817
/**
19-
* Bootstrap the example
18+
* Bootstrap the example.
2019
*/
2120
require_once __DIR__ . '/bootstrap.php';
2221

@@ -31,7 +30,7 @@
3130
);
3231

3332
// Instantiate the Bitly service using the credentials, http client and storage mechanism for the token
34-
/** @var $bitlyService Bitly */
33+
/** @var Bitly $bitlyService */
3534
$bitlyService = $serviceFactory->createService('bitly', $credentials, $storage);
3635

3736
if (!empty($_GET['code'])) {
@@ -43,7 +42,6 @@
4342

4443
// Show some of the resultant data
4544
echo 'Your unique user id is: ' . $result['data']['login'] . ' and your name is ' . $result['data']['display_name'];
46-
4745
} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') {
4846
$url = $bitlyService->getAuthorizationUri();
4947
header('Location: ' . $url);

examples/bitrix24.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<?php
22

33
/**
4-
* Example of retrieving an authentication token of the Bitrix24 service
4+
* Example of retrieving an authentication token of the Bitrix24 service.
55
*
66
* PHP version 5.4
77
*
88
* @author David Desberg <david@daviddesberg.com>
99
* @author Pieter Hordijk <info@pieterhordijk.com>
10-
* @copyright Copyright (c) 2012 The authors
1110
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1211
*/
1312

14-
use OAuth\OAuth2\Service\GitHub;
15-
use OAuth\Common\Storage\Session;
1613
use OAuth\Common\Consumer\Credentials;
14+
use OAuth\Common\Storage\Session;
15+
use OAuth\OAuth2\Service\GitHub;
1716

1817
/**
19-
* Bootstrap the example
18+
* Bootstrap the example.
2019
*/
2120
require_once __DIR__ . '/bootstrap.php';
2221

@@ -32,9 +31,9 @@
3231

3332
// Instantiate the GitHub service using the credentials, http client and storage mechanism for the token
3433

35-
$yourDomain = new \OAuth\Common\Http\Uri\Uri('https://'.$servicesCredentials['bitrix24']['domain']);
36-
/** @var $bitrix24 \OAuth\OAuth2\Service\Bitrix24 */
37-
$bitrix24 = $serviceFactory->createService('Bitrix24', $credentials, $storage, array('user'), $yourDomain);
34+
$yourDomain = new \OAuth\Common\Http\Uri\Uri('https://' . $servicesCredentials['bitrix24']['domain']);
35+
/** @var \OAuth\OAuth2\Service\Bitrix24 $bitrix24 */
36+
$bitrix24 = $serviceFactory->createService('Bitrix24', $credentials, $storage, ['user'], $yourDomain);
3837

3938
if (!empty($_GET['code'])) {
4039
// This was a callback request from bitrix24, get the token
@@ -45,11 +44,9 @@
4544

4645
// Show some of the resultant data
4746
echo 'Your email on your bitrix24 account is ' . $userInfo['EMAIL'];
48-
4947
} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') {
5048
$url = $bitrix24->getAuthorizationUri();
5149
header('Location: ' . $url);
52-
5350
} else {
5451
$url = $currentUri->getRelativeUri() . '?go=go';
5552
echo "<a href='$url'>Login with Bitrix24!</a>";

examples/bootstrap.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
<?php
22

33
/**
4-
* Bootstrap the library
4+
* Bootstrap the library.
55
*/
66
require_once __DIR__ . '/../vendor/autoload.php';
77

8-
/**
9-
* Setup error reporting
10-
*/
8+
// Setup error reporting
119
error_reporting(E_ALL);
1210
ini_set('display_errors', 1);
1311

14-
/**
15-
* Setup the timezone
16-
*/
12+
// Setup the timezone
1713
ini_set('date.timezone', 'Europe/Amsterdam');
1814

1915
/**
20-
* Create a new instance of the URI class with the current URI, stripping the query string
16+
* Create a new instance of the URI class with the current URI, stripping the query string.
2117
*/
2218
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
2319
$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
2420
$currentUri->setQuery('');
2521

2622
/**
27-
* Load the credential for the different services
23+
* Load the credential for the different services.
2824
*/
2925
require_once __DIR__ . '/init.php';

examples/box.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
<?php
22

33
/**
4-
* Example of retrieving an authentication token of the Box service
4+
* Example of retrieving an authentication token of the Box service.
55
*
66
* PHP version 5.4
77
*
88
* @author David Desberg <david@daviddesberg.com>
99
* @author Pieter Hordijk <info@pieterhordijk.com>
1010
* @author Antoine Corcy <contact@sbin.dk>
11-
* @copyright Copyright (c) 2012 The authors
1211
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1312
*/
1413

15-
use OAuth\OAuth2\Service\Box;
16-
use OAuth\Common\Storage\Session;
1714
use OAuth\Common\Consumer\Credentials;
15+
use OAuth\Common\Storage\Session;
16+
use OAuth\OAuth2\Service\Box;
1817

1918
/**
20-
* Bootstrap the example
19+
* Bootstrap the example.
2120
*/
2221
require_once __DIR__ . '/bootstrap.php';
2322

@@ -32,12 +31,12 @@
3231
);
3332

3433
// Instantiate the Box service using the credentials, http client and storage mechanism for the token
35-
/** @var $boxService Box */
34+
/** @var Box $boxService */
3635
$boxService = $serviceFactory->createService('box', $credentials, $storage);
3736

3837
if (!empty($_GET['code'])) {
3938
// retrieve the CSRF state parameter
40-
$state = isset($_GET['state']) ? $_GET['state'] : null;
39+
$state = $_GET['state'] ?? null;
4140

4241
// This was a callback request from box, get the token
4342
$token = $boxService->requestAccessToken($_GET['code'], $state);
@@ -47,7 +46,6 @@
4746

4847
// Show some of the resultant data
4948
echo 'Your Box name is ' . $result['name'] . ' and your email is ' . $result['login'];
50-
5149
} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') {
5250
$url = $boxService->getAuthorizationUri();
5351
// var_dump($url);

0 commit comments

Comments
 (0)