diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index a07f3f3da..430402565 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -172,7 +172,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->scalarNode('base_url')->end() ->scalarNode('access_token_url') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -180,7 +180,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('authorization_url') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -188,7 +188,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('request_token_url') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -196,7 +196,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('revoke_token_url') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -204,7 +204,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('infos_url') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -214,7 +214,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->scalarNode('client_secret')->cannotBeEmpty()->end() ->scalarNode('realm') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -222,7 +222,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('scope') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -230,7 +230,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('user_response_class') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -238,7 +238,7 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->end() ->scalarNode('service') ->validate() - ->ifTrue(function($v) { + ->ifTrue(function ($v) { return empty($v); }) ->thenUnset() @@ -246,13 +246,13 @@ private function addResourceOwnersConfiguration(ArrayNodeDefinition $node) ->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() @@ -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; } @@ -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; @@ -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; @@ -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; @@ -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); diff --git a/DependencyInjection/Security/Factory/OAuthFactory.php b/DependencyInjection/Security/Factory/OAuthFactory.php index 93b4f7639..843b14323 100644 --- a/DependencyInjection/Security/Factory/OAuthFactory.php +++ b/DependencyInjection/Security/Factory/OAuthFactory.php @@ -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'.") @@ -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)) { diff --git a/HWIOAuthBundle.php b/HWIOAuthBundle.php index ebebb10f0..113651fea 100644 --- a/HWIOAuthBundle.php +++ b/HWIOAuthBundle.php @@ -26,7 +26,7 @@ class HWIOAuthBundle extends Bundle { /** - * {@inheritDoc} + * {@inheritdoc} */ public function build(ContainerBuilder $container) { diff --git a/OAuth/ResourceOwner/AbstractResourceOwner.php b/OAuth/ResourceOwner/AbstractResourceOwner.php index 78feeb9b1..5d7d223c0 100644 --- a/OAuth/ResourceOwner/AbstractResourceOwner.php +++ b/OAuth/ResourceOwner/AbstractResourceOwner.php @@ -110,7 +110,6 @@ public function __construct(HttpClientInterface $httpClient, HttpUtils $httpUtil */ public function configure() { - } /** diff --git a/OAuth/ResourceOwner/AzureResourceOwner.php b/OAuth/ResourceOwner/AzureResourceOwner.php index c340107dc..49f8742fe 100644 --- a/OAuth/ResourceOwner/AzureResourceOwner.php +++ b/OAuth/ResourceOwner/AzureResourceOwner.php @@ -12,7 +12,6 @@ namespace HWI\Bundle\OAuthBundle\OAuth\ResourceOwner; use Symfony\Component\OptionsResolver\OptionsResolver; - use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken; /** diff --git a/OAuth/ResourceOwner/Bitbucket2ResourceOwner.php b/OAuth/ResourceOwner/Bitbucket2ResourceOwner.php index 2dcbe1fcb..663cfd4bc 100644 --- a/OAuth/ResourceOwner/Bitbucket2ResourceOwner.php +++ b/OAuth/ResourceOwner/Bitbucket2ResourceOwner.php @@ -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; - } -} \ No newline at end of file + return $response; + } +} diff --git a/OAuth/ResourceOwner/DeezerResourceOwner.php b/OAuth/ResourceOwner/DeezerResourceOwner.php index a4ca35166..421d67f9b 100644 --- a/OAuth/ResourceOwner/DeezerResourceOwner.php +++ b/OAuth/ResourceOwner/DeezerResourceOwner.php @@ -48,4 +48,3 @@ protected function configureOptions(OptionsResolver $resolver) )); } } - diff --git a/OAuth/ResourceOwner/DiscogsResourceOwner.php b/OAuth/ResourceOwner/DiscogsResourceOwner.php index 126126abc..9d33c8056 100644 --- a/OAuth/ResourceOwner/DiscogsResourceOwner.php +++ b/OAuth/ResourceOwner/DiscogsResourceOwner.php @@ -28,4 +28,4 @@ protected function configureOptions(OptionsResolver $resolver) 'infos_url' => 'http://api.discogs.com/oauth/identity', )); } -} +} diff --git a/OAuth/ResourceOwner/GenericOAuth2ResourceOwner.php b/OAuth/ResourceOwner/GenericOAuth2ResourceOwner.php index 02f1a2407..3bd8571d5 100644 --- a/OAuth/ResourceOwner/GenericOAuth2ResourceOwner.php +++ b/OAuth/ResourceOwner/GenericOAuth2ResourceOwner.php @@ -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'], diff --git a/OAuth/ResourceOwner/SpotifyResourceOwner.php b/OAuth/ResourceOwner/SpotifyResourceOwner.php index de47a2302..e17c834b7 100644 --- a/OAuth/ResourceOwner/SpotifyResourceOwner.php +++ b/OAuth/ResourceOwner/SpotifyResourceOwner.php @@ -61,4 +61,4 @@ protected function configureOptions(OptionsResolver $resolver) 'infos_url' => 'https://api.spotify.com/v1/me' )); } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index cfb543dcf..73d126885 100644 --- a/composer.json +++ b/composer.json @@ -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": {