Skip to content

Commit

Permalink
Apply code styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored and github-actions[bot] committed Sep 7, 2023
1 parent d3922d6 commit f4866e7
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 92 deletions.
5 changes: 2 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ class Config implements Contracts\ConfigInterface
* @param string $key
* @param string $secret
* @param string|callable $callbackUri
* @param array $additionalProviderConfig
*/
public function __construct($key, $secret, $callbackUri, array $additionalProviderConfig = [])
{
$this->config = array_merge([
'client_id' => $key,
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $this->formatRedirectUri($callbackUri),
'redirect' => $this->formatRedirectUri($callbackUri),
], $additionalProviderConfig);
}

Expand Down
1 change: 0 additions & 1 deletion src/Contracts/Helpers/ConfigRetrieverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface ConfigRetrieverInterface
{
/**
* @param string $providerName
* @param array $additionalConfigKeys
* @return \SocialiteProviders\Manager\Contracts\ConfigInterface
*/
public function fromServices($providerName, array $additionalConfigKeys = []);
Expand Down
1 change: 0 additions & 1 deletion src/Contracts/OAuth1/ProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
interface ProviderInterface
{
/**
* @param \SocialiteProviders\Manager\Contracts\ConfigInterface $config
* @return $this
*/
public function setConfig(Config $config);
Expand Down
1 change: 0 additions & 1 deletion src/Contracts/OAuth2/ProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
interface ProviderInterface extends SocialiteOauth2ProviderInterface
{
/**
* @param \SocialiteProviders\Manager\Contracts\ConfigInterface $config
* @return $this
*/
public function setConfig(Config $config);
Expand Down
15 changes: 3 additions & 12 deletions src/Helpers/ConfigRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ConfigRetriever implements ConfigRetrieverInterface

/**
* @param string $providerName
* @param array $additionalConfigKeys
* @return \SocialiteProviders\Manager\Contracts\ConfigInterface
*/
public function fromServices($providerName, array $additionalConfigKeys = [])
Expand All @@ -50,8 +49,6 @@ public function fromServices($providerName, array $additionalConfigKeys = [])
}

/**
* @param array $configKeys
* @param \Closure $keyRetrievalClosure
* @return array
*/
protected function getConfigItems(array $configKeys, Closure $keyRetrievalClosure)
Expand All @@ -60,8 +57,6 @@ protected function getConfigItems(array $configKeys, Closure $keyRetrievalClosur
}

/**
* @param array $keys
* @param \Closure $keyRetrievalClosure
* @return array
*/
protected function retrieveItemsFromConfig(array $keys, Closure $keyRetrievalClosure)
Expand Down Expand Up @@ -112,20 +107,16 @@ protected function getConfigFromServicesArray($providerName)
// If we are running in console we should spoof values to make Socialite happy...
if (app()->runningInConsole()) {
$configArray = [
'client_id' => "{$this->providerIdentifier}_KEY",
'client_id' => "{$this->providerIdentifier}_KEY",
'client_secret' => "{$this->providerIdentifier}_SECRET",
'redirect' => "{$this->providerIdentifier}_REDIRECT_URI",
'redirect' => "{$this->providerIdentifier}_REDIRECT_URI",
];
} else {
throw new MissingConfigException("There is no services entry for $providerName");
}
}





return $this->servicesArray = $configArray;
return $this->servicesArray = $configArray;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions src/OAuth1/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public function stateless($stateless = true)
/**
* Set the scopes of the requested access.
*
* @param array $scopes
* @return $this
*/
public function scopes(array $scopes)
Expand All @@ -132,7 +131,6 @@ public function scopes(array $scopes)
/**
* Set the custom parameters of the request.
*
* @param array $parameters
* @return $this
*/
public function with(array $parameters)
Expand All @@ -143,7 +141,6 @@ public function with(array $parameters)
}

/**
* @param Config $config
* @return $this
*/
public function setConfig(Config $config)
Expand Down
8 changes: 2 additions & 6 deletions src/OAuth1/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ abstract class Server extends BaseServer
* the temporary credentials identifier as passed back by the server
* and finally the verifier code.
*
* @param \League\OAuth1\Client\Credentials\TemporaryCredentials $temporaryCredentials
* @param string $temporaryIdentifier
* @param string $verifier
* @return array
Expand All @@ -65,7 +64,7 @@ public function getTokenCredentials(TemporaryCredentials $temporaryCredentials,
try {
if ($client instanceof Client) {
$response = $client->post($uri, [
'headers' => $headers,
'headers' => $headers,

Check warning on line 67 in src/OAuth1/Server.php

View check run for this annotation

Codecov / codecov/patch

src/OAuth1/Server.php#L67

Added line #L67 was not covered by tests
'form_params' => $bodyParameters,
]);
} else {
Expand All @@ -76,15 +75,14 @@ public function getTokenCredentials(TemporaryCredentials $temporaryCredentials,
}

return [
'tokenCredentials' => $this->createTokenCredentials($response->getBody()),
'tokenCredentials' => $this->createTokenCredentials($response->getBody()),

Check warning on line 78 in src/OAuth1/Server.php

View check run for this annotation

Codecov / codecov/patch

src/OAuth1/Server.php#L78

Added line #L78 was not covered by tests
'credentialsResponseBody' => $response->getBody(),
];
}

/**
* Set the scopes of the requested access.
*
* @param array $scopes
* @return $this
*/
public function scopes(array $scopes)
Expand All @@ -97,7 +95,6 @@ public function scopes(array $scopes)
/**
* Set the custom parameters of the request.
*
* @param array $parameters
* @return $this
*/
public function with(array $parameters)
Expand All @@ -110,7 +107,6 @@ public function with(array $parameters)
/**
* Format the given scopes.
*
* @param array $scopes
* @param string $scopeSeparator
* @return string
*/
Expand Down
1 change: 0 additions & 1 deletion src/OAuth1/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class User extends BaseUser
*
* Might include things such as the token and refresh token
*
* @param array $accessTokenResponseBody
* @return $this
*/
public function setAccessTokenResponseBody(array $accessTokenResponseBody)
Expand Down
1 change: 0 additions & 1 deletion src/OAuth2/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class User extends BaseUser
*
* Might include things such as the token and refresh token
*
* @param array $accessTokenResponseBody
* @return $this
*/
public function setAccessTokenResponseBody(array $accessTokenResponseBody)
Expand Down
11 changes: 1 addition & 10 deletions src/SocialiteWasCalled.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class SocialiteWasCalled

private ConfigRetrieverInterface $configRetriever;

/**
* @param \Illuminate\Contracts\Container\Container $app
* @param \SocialiteProviders\Manager\Contracts\Helpers\ConfigRetrieverInterface $configRetriever
*/
public function __construct(Application $app, ConfigRetrieverInterface $configRetriever)
{
$this->app = $app;
Expand Down Expand Up @@ -65,7 +61,6 @@ function () use ($socialite, $providerName, $providerClass, $oauth1Server) {
}

/**
* @param \Laravel\Socialite\SocialiteManager $socialite
* @param string $providerName
* @param string $providerClass
* @param null|string $oauth1Server
Expand All @@ -83,7 +78,6 @@ protected function buildProvider(SocialiteManager $socialite, $providerName, $pr
/**
* Build an OAuth 1 provider instance.
*
* @param \Laravel\Socialite\SocialiteManager $socialite
* @param string $providerClass must extend Laravel\Socialite\One\AbstractProvider
* @param string $providerName
* @param string $oauth1Server must extend League\OAuth1\Client\Server\Server
Expand All @@ -109,7 +103,6 @@ protected function buildOAuth1Provider(SocialiteManager $socialite, $providerCla
/**
* Build an OAuth 2 provider instance.
*
* @param SocialiteManager $socialite
* @param string $providerClass must extend Laravel\Socialite\Two\AbstractProvider
* @param string $providerName
* @return \Laravel\Socialite\Two\AbstractProvider
Expand All @@ -128,8 +121,6 @@ protected function buildOAuth2Provider(SocialiteManager $socialite, $providerCla
}

/**
* @param string $providerClass
* @param string $providerName
* @return \SocialiteProviders\Manager\Contracts\ConfigInterface
*/
protected function getConfig(string $providerClass, string $providerName)
Expand Down Expand Up @@ -159,7 +150,7 @@ private function isOAuth1($oauth1Server)
*/
private function classExtends($class, $baseClass)
{
if (false === is_subclass_of($class, $baseClass)) {
if (is_subclass_of($class, $baseClass) === false) {
throw new InvalidArgumentException("{$class} does not extend {$baseClass}");
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ConfigRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public function it_retrieves_a_config_from_the_services(): void
$uri = 'uri';
$additionalConfigItem = 'test';
$config = [
'client_id' => $key,
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $uri,
'additional' => $additionalConfigItem,
'redirect' => $uri,
'additional' => $additionalConfigItem,
];
self::$functions
->shouldReceive('config')
Expand Down
16 changes: 8 additions & 8 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public function it_returns_a_config_array(): void
$secret = 'secret';
$callbackUri = 'uri';
$result = [
'client_id' => $key,
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $callbackUri,
'redirect' => $callbackUri,
];

$config = new Config($key, $secret, $callbackUri);
Expand All @@ -34,10 +34,10 @@ public function it_allows_additional_config_items(): void
$secret = 'secret';
$callbackUri = 'uri';
$result = [
'client_id' => $key,
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $callbackUri,
'additional' => true,
'redirect' => $callbackUri,
'additional' => true,
];
$additional = ['additional' => true];

Expand All @@ -56,10 +56,10 @@ public function it_allows_closure_config_redirect()
$callbackUri = 'uri';
$callbackFunc = fn () => $callbackUri;
$result = [
'client_id' => $key,
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $callbackUri,
'additional' => true,
'redirect' => $callbackUri,
'additional' => true,
];
$additional = ['additional' => true];

Expand Down
20 changes: 4 additions & 16 deletions tests/ManagerTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,20 @@ protected function configRetrieverMockWithDefaultExpectations($providerName, $pr
return $configRetriever;
}

/**
* @return array
*/
protected function config(): array
{
return [
'client_id' => 'test',
'client_id' => 'test',
'client_secret' => 'test',
'redirect' => 'test',
'redirect' => 'test',
];
}

/**
* @param array $config
* @return array
*/
protected function oauth1FormattedConfig(array $config): array
{
return [
'identifier' => $config['client_id'],
'secret' => $config['client_secret'],
'identifier' => $config['client_id'],
'secret' => $config['client_secret'],
'callback_uri' => $config['redirect'],
];
}
Expand Down Expand Up @@ -152,7 +145,6 @@ protected function oauth2ProviderStubClass(): string

/**
* @param string $stub
* @return \Mockery\MockInterface
*/
protected function mockStub($stub): MockInterface
{
Expand All @@ -161,16 +153,12 @@ protected function mockStub($stub): MockInterface

/**
* @param string $stub
* @return string
*/
protected function fullStubClassName($stub): string
{
return __NAMESPACE__.'\Stubs\\'.$stub;
}

/**
* @return string
*/
protected function invalidClass(): string
{
return 'FooBar';
Expand Down
Loading

0 comments on commit f4866e7

Please sign in to comment.