Skip to content

Commit d1040b0

Browse files
committed
🚿 PHPCS & PHPMD happy
1 parent 961e1a6 commit d1040b0

File tree

15 files changed

+29
-15
lines changed

15 files changed

+29
-15
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Providers/LastFM/topalbum-patchwork.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,3 @@ function sendResponse(array $response):void{
152152
echo json_encode($response, JSON_PRETTY_PRINT);
153153
exit;
154154
}
155-

examples/Providers/Spotify/playlist-diff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function diff(string $playlistID1, string $playlistID2, bool $createAsPla
2929
return $diff;
3030
}
3131

32-
};
32+
}
3333

3434
/**
3535
* @var \OAuthExampleProviderFactory $factory

examples/create-description.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
$table[] = '| ['.$provider->getName().']('.$provider->getApiDocURL().')'.
4747
' | [link]('.$provider->getApplicationURL().')'.
48-
' | '.($provider->getUserRevokeURL() !== null ? '[link]('.$provider->getUserRevokeURL().')' : '').
48+
' | '.(($provider->getUserRevokeURL() !== null) ? '[link]('.$provider->getUserRevokeURL().')' : '').
4949
' | '.$oauthVersion.
5050
' | '.(($provider instanceof UserInfo) ? '' : '').
5151
' | '.(($provider instanceof CSRFToken) ? '' : '').

examples/provider-example-common.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*
1717
* @var string $AUTOLOADER - path to an alternate autoloader
1818
*/
19+
// PHPCS:ignore
1920
require_once ($AUTOLOADER ?? __DIR__.'/../vendor/autoload.php');
2021
require_once __DIR__.'/OAuthExampleProviderFactory.php';
2122

phpmd.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<exclude name="ExitExpression"/>
2727
</rule>
2828
<rule ref="rulesets/naming.xml">
29+
<exclude name="ShortMethodName"/>
2930
<exclude name="LongVariable"/>
3031
<exclude name="ShortVariable"/>
3132
<exclude name="ConstantNamingConventions"/>

src/Core/OAuth1Provider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function getRequestTokenRequestParams():array{
101101
*
102102
* @throws \chillerlan\OAuth\Providers\ProviderException
103103
*/
104-
protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = false):AccessToken{
104+
protected function parseTokenResponse(ResponseInterface $response, bool|null $checkCallbackConfirmed = null):AccessToken{
105105
$data = QueryUtil::parse(MessageUtil::decompress($response));
106106

107107
if(empty($data)){
@@ -122,7 +122,10 @@ protected function parseTokenResponse(ResponseInterface $response, bool $checkCa
122122
}
123123

124124
// MUST be present and set to "true". The parameter is used to differentiate from previous versions of the protocol
125-
if($checkCallbackConfirmed && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')){
125+
if(
126+
$checkCallbackConfirmed === true
127+
&& (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')
128+
){
126129
throw new ProviderException('invalid OAuth 1.0a response');
127130
}
128131

src/Core/OAuth2Provider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ protected function getRefreshAccessTokenRequestBodyParams(string $refreshToken):
417417
* @throws \chillerlan\OAuth\Providers\ProviderException
418418
*/
419419
public function invalidateAccessToken(AccessToken $token = null, string|null $type = null):bool{
420-
$type = strtolower(trim($type ?? 'access_token'));
420+
$type = strtolower(trim(($type ?? 'access_token')));
421421

422422
// @link https://datatracker.ietf.org/doc/html/rfc7009#section-2.1
423423
if(!in_array($type, ['access_token', 'refresh_token'])){
@@ -587,7 +587,10 @@ final public function setCodeVerifier(array $params):array{
587587
/**
588588
* @implements \chillerlan\OAuth\Core\PKCE::generateVerifier()
589589
* @see \chillerlan\OAuth\Core\OAuth2Provider::setCodeChallenge()
590+
*
590591
* @phan-suppress PhanUndeclaredClassMethod, PhanUndeclaredMethod
592+
* @noinspection PhpFullyQualifiedNameUsageInspection
593+
* @SuppressWarnings(PHPMD.MissingImport)
591594
*/
592595
final public function generateVerifier(int $length):string{
593596

src/Core/Utilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Utilities{
4646
* Fetches a list of provider classes in the given directory
4747
*/
4848
public static function getProviders(string|null $providerDir = null, string|null $namespace = null):array{
49-
$providerDir = realpath($providerDir ?? __DIR__.'/../Providers');
49+
$providerDir = realpath(($providerDir ?? __DIR__.'/../Providers'));
5050
$namespace = trim(($namespace ?? 'chillerlan\\OAuth\\Providers'), '\\');
5151
$providers = [];
5252

src/OAuthOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use chillerlan\Settings\SettingsContainerAbstract;
1515

1616
/**
17-
* This class holds all settings related to the OAuth provider as well as the default HTTP client.
17+
* This class holds all settings related to the OAuth provider
1818
*/
1919
class OAuthOptions extends SettingsContainerAbstract{
2020
use OAuthOptionsTrait;

0 commit comments

Comments
 (0)