Skip to content

Commit

Permalink
Fixed some of CS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Bielawski committed Apr 7, 2016
1 parent 3b7f7bf commit d87ff96
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 70 deletions.
32 changes: 16 additions & 16 deletions DependencyInjection/Configuration.php
Expand Up @@ -172,39 +172,39 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->scalarNode('base_url')->end()
->scalarNode('access_token_url')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('authorization_url')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('request_token_url')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('revoke_token_url')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('infos_url')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
Expand All @@ -214,45 +214,45 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->scalarNode('client_secret')->cannotBeEmpty()->end()
->scalarNode('realm')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('scope')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('user_response_class')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('service')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
->end()
->end()
->scalarNode('type')
->validate()
->ifTrue(function($type) {
->ifTrue(function ($type) {
return !Configuration::isResourceOwnerSupported($type);
})
->thenInvalid('Unknown resource owner type "%s".')
->end()
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return empty($v);
})
->thenUnset()
Expand All @@ -262,7 +262,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->useAttributeAsKey('name')
->prototype('variable')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
if (null === $v) {
return true;
}
Expand All @@ -287,7 +287,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->end()
->end()
->validate()
->ifTrue(function($c) {
->ifTrue(function ($c) {
// skip if this contains a service
if (isset($c['service'])) {
return false;
Expand All @@ -305,7 +305,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->thenInvalid("You should set at least the 'type', 'client_id' and the 'client_secret' of a resource owner.")
->end()
->validate()
->ifTrue(function($c) {
->ifTrue(function ($c) {
// skip if this contains a service
if (isset($c['service'])) {
return false;
Expand Down Expand Up @@ -333,7 +333,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->thenInvalid("All parameters are mandatory for types 'oauth2' and 'oauth1'. Check if you're missing one of: 'access_token_url', 'authorization_url', 'infos_url' and 'request_token_url' for 'oauth1'.")
->end()
->validate()
->ifTrue(function($c) {
->ifTrue(function ($c) {
// skip if this contains a service
if (isset($c['service'])) {
return false;
Expand All @@ -360,7 +360,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
->thenInvalid("At least the 'identifier', 'nickname' and 'realname' paths should be configured for 'oauth2' and 'oauth1' types.")
->end()
->validate()
->ifTrue(function($c) {
->ifTrue(function ($c) {
if (isset($c['service'])) {
// ignore paths & options if none were set
return 0 !== count($c['paths']) || 0 !== count($c['options']) || 3 < count($c);
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Security/Factory/OAuthFactory.php
Expand Up @@ -216,7 +216,7 @@ private function addOAuthProviderConfiguration(NodeDefinition $node)
->end()
->end()
->validate()
->ifTrue(function($c) {
->ifTrue(function ($c) {
return 1 !== count($c) || !in_array(key($c), array('fosub', 'oauth', 'orm', 'service'));
})
->thenInvalid("You should configure (only) one of: 'fosub', 'oauth', 'orm', 'service'.")
Expand All @@ -235,7 +235,7 @@ private function addResourceOwnersConfiguration(NodeDefinition $node)
->prototype('scalar')
->end()
->validate()
->ifTrue(function($c) {
->ifTrue(function ($c) {
$checkPaths = array();
foreach ($c as $checkPath) {
if (in_array($checkPath, $checkPaths)) {
Expand Down
2 changes: 1 addition & 1 deletion HWIOAuthBundle.php
Expand Up @@ -26,7 +26,7 @@
class HWIOAuthBundle extends Bundle
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
Expand Down
1 change: 0 additions & 1 deletion OAuth/ResourceOwner/AbstractResourceOwner.php
Expand Up @@ -110,7 +110,6 @@ public function __construct(HttpClientInterface $httpClient, HttpUtils $httpUtil
*/
public function configure()
{

}

/**
Expand Down
1 change: 0 additions & 1 deletion OAuth/ResourceOwner/AzureResourceOwner.php
Expand Up @@ -12,7 +12,6 @@
namespace HWI\Bundle\OAuthBundle\OAuth\ResourceOwner;

use Symfony\Component\OptionsResolver\OptionsResolver;

use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;

/**
Expand Down
88 changes: 44 additions & 44 deletions OAuth/ResourceOwner/Bitbucket2ResourceOwner.php
Expand Up @@ -21,52 +21,52 @@
class Bitbucket2ResourceOwner extends GenericOAuth2ResourceOwner
{

/**
* {@inheritDoc}
*/
protected $paths = array(
'identifier' => 'uuid',
'nickname' => 'username',
'email' => 'email',
'realname' => 'display_name',
'profilepicture' => 'links.avatar.href',
);
/**
* {@inheritDoc}
*/
protected $paths = array(
'identifier' => 'uuid',
'nickname' => 'username',
'email' => 'email',
'realname' => 'display_name',
'profilepicture' => 'links.avatar.href',
);

/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);

$resolver->setDefaults(array(
'authorization_url' => 'https://bitbucket.org/site/oauth2/authorize',
'access_token_url' => 'https://bitbucket.org/site/oauth2/access_token',
'infos_url' => 'https://api.bitbucket.org/2.0/user',
'emails_url' => 'https://api.bitbucket.org/2.0/user/emails'
));
}
$resolver->setDefaults(array(
'authorization_url' => 'https://bitbucket.org/site/oauth2/authorize',
'access_token_url' => 'https://bitbucket.org/site/oauth2/access_token',
'infos_url' => 'https://api.bitbucket.org/2.0/user',
'emails_url' => 'https://api.bitbucket.org/2.0/user/emails'
));
}

/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$response = parent::getUserInformation($accessToken, $extraParameters);
$responseData = $response->getResponse();
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$response = parent::getUserInformation($accessToken, $extraParameters);
$responseData = $response->getResponse();

// fetch the email addresses linked to the account
if (empty($responseData['email'])) {
$content = $this->httpRequest($this->normalizeUrl($this->options['emails_url']), null, array('Authorization: Bearer '.$accessToken['access_token']));
foreach ($this->getResponseContent($content)['values'] as $email) {
// we only need the primary email address
if (true === $email['is_primary']) {
$responseData['email'] = $email['email'];
}
}
$response->setResponse($responseData);
}
// fetch the email addresses linked to the account
if (empty($responseData['email'])) {
$content = $this->httpRequest($this->normalizeUrl($this->options['emails_url']), null, array('Authorization: Bearer '.$accessToken['access_token']));
foreach ($this->getResponseContent($content)['values'] as $email) {
// we only need the primary email address
if (true === $email['is_primary']) {
$responseData['email'] = $email['email'];
}
}
$response->setResponse($responseData);
}

return $response;
}
}
return $response;
}
}
1 change: 0 additions & 1 deletion OAuth/ResourceOwner/DeezerResourceOwner.php
Expand Up @@ -48,4 +48,3 @@ protected function configureOptions(OptionsResolver $resolver)
));
}
}

2 changes: 1 addition & 1 deletion OAuth/ResourceOwner/DiscogsResourceOwner.php
Expand Up @@ -28,4 +28,4 @@ protected function configureOptions(OptionsResolver $resolver)
'infos_url' => 'http://api.discogs.com/oauth/identity',
));
}
}
}
2 changes: 1 addition & 1 deletion OAuth/ResourceOwner/GenericOAuth2ResourceOwner.php
Expand Up @@ -105,7 +105,7 @@ public function getAccessToken(Request $request, $redirectUri, array $extraParam
*/
public function refreshAccessToken($refreshToken, array $extraParameters = array())
{
$parameters = array_merge( array(
$parameters = array_merge(array(
'refresh_token' => $refreshToken,
'grant_type' => 'refresh_token',
'client_id' => $this->options['client_id'],
Expand Down
2 changes: 1 addition & 1 deletion OAuth/ResourceOwner/SpotifyResourceOwner.php
Expand Up @@ -61,4 +61,4 @@ protected function configureOptions(OptionsResolver $resolver)
'infos_url' => 'https://api.spotify.com/v1/me'
));
}
}
}
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -108,7 +108,8 @@
"symfony/twig-bundle": "~2.3|~3.0",
"symfony/phpunit-bridge": "~2.7|~3.0",
"friendsofsymfony/user-bundle": "~1.3|~2.0",
"phpunit/phpunit": "~4.8|~5.0"
"phpunit/phpunit": "~4.8|~5.0",
"fabpot/php-cs-fixer": "~1.11"
},

"suggest": {
Expand Down

0 comments on commit d87ff96

Please sign in to comment.