Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Jan 3, 2021
1 parent 96ac247 commit 73d20b4
Show file tree
Hide file tree
Showing 72 changed files with 191 additions and 397 deletions.
25 changes: 9 additions & 16 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(array(__DIR__))
;
$finder = PhpCsFixer\Finder::create()->in([__DIR__]);

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers(array(
'-phpdoc_scalar',
'-extra_empty_lines',
'-unalign_double_arrow',
'-unalign_equals',
'align_double_arrow',
'newline_after_open_tag',
'ordered_use',
'short_array_syntax',
))
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'ordered_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'phpdoc_scalar' => false,
])
->setUsingCache(false)
->finder($finder)
->setFinder($finder);
;
2 changes: 1 addition & 1 deletion Command/CheckConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CheckConfigCommand extends Command

public function __construct(KeyLoaderInterface $keyLoader, $signatureAlgorithm)
{
$this->keyLoader = $keyLoader;
$this->keyLoader = $keyLoader;
$this->signatureAlgorithm = $signatureAlgorithm;

parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion Command/GenerateTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(JWTTokenManagerInterface $tokenManager, \Traversable
{
parent::__construct();

$this->tokenManager = $tokenManager;
$this->tokenManager = $tokenManager;
$this->userProviders = $userProviders;
}

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getConfigTreeBuilder()
private function getTokenExtractorsNode()
{
$builder = new TreeBuilder('token_extractors');
$node = \method_exists(TreeBuilder::class, 'getRootNode') ? $builder->getRootNode() : $builder->root('token_extractors');
$node = $builder->getRootNode();
$node
->addDefaultsIfNotSet()
->children()
Expand Down
3 changes: 1 addition & 2 deletions DependencyInjection/LexikJWTAuthenticationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LexikJWTAuthenticationExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$config = $this->processConfiguration($configuration, $configs);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

Expand Down Expand Up @@ -63,7 +63,6 @@ public function load(array $configs, ContainerBuilder $container)
$e->setPath('lexik_jwt_authentication');

throw $e;

}

$container->setParameter('lexik_jwt_authentication.pass_phrase', $config['pass_phrase']);
Expand Down
5 changes: 2 additions & 3 deletions DependencyInjection/Security/Factory/JWTFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ public function addConfiguration(NodeDefinition $node)
/**
* Create an entry point, by default it sends a 401 header and ends the request.
*
* @param ContainerBuilder $container
* @param string $id
* @param mixed $defaultEntryPoint
* @param string $id
* @param mixed $defaultEntryPoint
*
* @return string
*/
Expand Down
3 changes: 0 additions & 3 deletions Encoder/HeaderAwareJWTEncoderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
interface HeaderAwareJWTEncoderInterface extends JWTEncoderInterface
{
/**
* @param array $data
* @param array $header
*
* @return string the encoded token string
*
* @throws JWTEncodeFailureException If an error occurred while trying to create
Expand Down
2 changes: 0 additions & 2 deletions Encoder/JWTEncoderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
interface JWTEncoderInterface
{
/**
* @param array $data
*
* @return string the encoded token string
*
* @throws JWTEncodeFailureException If an error occurred while trying to create
Expand Down
3 changes: 0 additions & 3 deletions Encoder/LcobucciJWTEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class LcobucciJWTEncoder implements JWTEncoderInterface, HeaderAwareJWTEncoderIn
*/
protected $jwsProvider;

/**
* @param JWSProviderInterface $jwsProvider
*/
public function __construct(JWSProviderInterface $jwsProvider)
{
$this->jwsProvider = $jwsProvider;
Expand Down
9 changes: 1 addition & 8 deletions Event/AuthenticationFailureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ class AuthenticationFailureEvent extends Event
*/
protected $response;

/**
* @param AuthenticationException $exception
* @param Response $response
*/
public function __construct(AuthenticationException $exception, Response $response)
{
$this->exception = $exception;
$this->response = $response;
$this->response = $response;
}

/**
Expand All @@ -50,9 +46,6 @@ public function getResponse()
return $this->response;
}

/**
* @param Response $response
*/
public function setResponse(Response $response)
{
$this->response = $response;
Expand Down
12 changes: 2 additions & 10 deletions Event/AuthenticationSuccessEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ class AuthenticationSuccessEvent extends Event
*/
protected $response;

/**
* @param array $data
* @param UserInterface $user
* @param Response $response
*/
public function __construct(array $data, UserInterface $user, Response $response)
{
$this->data = $data;
$this->user = $user;
$this->data = $data;
$this->user = $user;
$this->response = $response;
}

Expand All @@ -48,9 +43,6 @@ public function getData()
return $this->data;
}

/**
* @param array $data
*/
public function setData(array $data)
{
$this->data = $data;
Expand Down
9 changes: 1 addition & 8 deletions Event/JWTAuthenticatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ class JWTAuthenticatedEvent extends Event
*/
protected $token;

/**
* @param array $payload
* @param TokenInterface $token
*/
public function __construct(array $payload, TokenInterface $token)
{
$this->payload = $payload;
$this->token = $token;
$this->token = $token;
}

/**
Expand All @@ -38,9 +34,6 @@ public function getPayload()
return $this->payload;
}

/**
* @param array $payload
*/
public function setPayload(array $payload)
{
$this->payload = $payload;
Expand Down
15 changes: 2 additions & 13 deletions Event/JWTCreatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ class JWTCreatedEvent extends Event
*/
protected $user;

/**
* @param array $data
* @param UserInterface $user
* @param array $header
*/
public function __construct(array $data, UserInterface $user, array $header = [])
{
$this->data = $data;
$this->user = $user;
$this->data = $data;
$this->user = $user;
$this->header = $header;
}

Expand All @@ -45,9 +40,6 @@ public function getHeader()
return $this->header;
}

/**
* @param array $header
*/
public function setHeader(array $header)
{
$this->header = $header;
Expand All @@ -61,9 +53,6 @@ public function getData()
return $this->data;
}

/**
* @param array $data
*/
public function setData(array $data)
{
$this->data = $data;
Expand Down
6 changes: 0 additions & 6 deletions Event/JWTDecodedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class JWTDecodedEvent extends Event
*/
protected $isValid;

/**
* @param array $payload
*/
public function __construct(array $payload)
{
$this->payload = $payload;
Expand All @@ -38,9 +35,6 @@ public function getPayload()
return $this->payload;
}

/**
* @param array $payload
*/
public function setPayload(array $payload)
{
$this->payload = $payload;
Expand Down
2 changes: 0 additions & 2 deletions Event/JWTFailureEventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function getException();
/**
* Calling this allows to return a custom Response immediately after
* the corresponding implementation of this event is dispatched.
*
* @param Response $response
*/
public function setResponse(Response $response);
}
6 changes: 1 addition & 5 deletions Event/JWTNotFoundEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
*/
class JWTNotFoundEvent extends AuthenticationFailureEvent implements JWTFailureEventInterface
{
/**
* @param AuthenticationException|null $exception
* @param Response|null $response
*/
public function __construct(AuthenticationException $exception = null, Response $response = null)
{
$this->exception = $exception;
$this->response = $response;
$this->response = $response;
}
}
4 changes: 2 additions & 2 deletions Exception/JWTDecodeFailureException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
class JWTDecodeFailureException extends JWTFailureException
{
const INVALID_TOKEN = 'invalid_token';
const INVALID_TOKEN = 'invalid_token';

const UNVERIFIED_TOKEN = 'unverified_token';

const EXPIRED_TOKEN = 'expired_token';
const EXPIRED_TOKEN = 'expired_token';
}
2 changes: 1 addition & 1 deletion Exception/UserNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UserNotFoundException extends AuthenticationException
public function __construct(string $userIdentityField, string $identity)
{
$this->userIdentityField = $userIdentityField;
$this->identity = $identity;
$this->identity = $identity;
}

/**
Expand Down
1 change: 1 addition & 0 deletions Helper/JWTSplitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(string $jwt)

/**
* @param array $parts
*
* @return string
*/
public function getParts($parts = [])
Expand Down
4 changes: 3 additions & 1 deletion Response/JWTAuthenticationFailureResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
*/
final class JWTAuthenticationFailureResponse extends JsonResponse
{
public function __construct(string $message = 'Bad credentials', string $statusCode = JsonResponse::HTTP_UNAUTHORIZED)
private $message;

public function __construct(string $message = 'Bad credentials', int $statusCode = JsonResponse::HTTP_UNAUTHORIZED)
{
$this->message = $message;

Expand Down
1 change: 0 additions & 1 deletion Response/JWTAuthenticationSuccessResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Lexik\Bundle\JWTAuthenticationBundle\Response;

use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\JsonResponse;

/**
Expand Down
17 changes: 6 additions & 11 deletions Security/Authentication/Provider/JWTProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Lexik\Bundle\JWTAuthenticationBundle\Security\Authentication\Token\JWTUserToken;
use Lexik\Bundle\JWTAuthenticationBundle\Security\Guard\JWTTokenAuthenticator;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTManagerInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* JWTProvider.
Expand Down Expand Up @@ -50,10 +50,7 @@ class JWTProvider implements AuthenticationProviderInterface
private $userIdClaim;

/**
* @param UserProviderInterface $userProvider
* @param JWTManagerInterface $jwtManager
* @param EventDispatcherInterface $dispatcher
* @param string $userIdClaim
* @param string $userIdClaim
*/
public function __construct(
UserProviderInterface $userProvider,
Expand All @@ -63,11 +60,11 @@ public function __construct(
) {
@trigger_error(sprintf('The "%s" class is deprecated since version 2.0 and will be removed in 3.0. See "%s" instead.', __CLASS__, JWTTokenAuthenticator::class), E_USER_DEPRECATED);

$this->userProvider = $userProvider;
$this->jwtManager = $jwtManager;
$this->dispatcher = $dispatcher;
$this->userProvider = $userProvider;
$this->jwtManager = $jwtManager;
$this->dispatcher = $dispatcher;
$this->userIdentityField = 'username';
$this->userIdClaim = $userIdClaim;
$this->userIdClaim = $userIdClaim;
}

/**
Expand Down Expand Up @@ -99,8 +96,6 @@ public function authenticate(TokenInterface $token)
* Load user from payload, using username by default.
* Override this to load by another property.
*
* @param array $payload
*
* @return \Symfony\Component\Security\Core\User\UserInterface
*/
protected function getUserFromPayload(array $payload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

interface PreAuthenticationJWTUserTokenInterface extends GuardTokenInterface
{

/**
* @param array $payload
* @return void
*/
public function setPayload(array $payload);
Expand Down
Loading

0 comments on commit 73d20b4

Please sign in to comment.