Skip to content

Commit a709b8d

Browse files
committed
fixed CS
1 parent 5943ec1 commit a709b8d

12 files changed

+98
-98
lines changed

Firewall/AbstractAuthenticationListener.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
6666
/**
6767
* @throws \InvalidArgumentException
6868
*/
69-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
69+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = [], LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
7070
{
7171
if (empty($providerKey)) {
7272
throw new \InvalidArgumentException('$providerKey must not be empty.');
@@ -78,7 +78,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
7878
$this->providerKey = $providerKey;
7979
$this->successHandler = $successHandler;
8080
$this->failureHandler = $failureHandler;
81-
$this->options = array_merge(array(
81+
$this->options = array_merge([
8282
'check_path' => '/login_check',
8383
'login_path' => '/login',
8484
'always_use_default_target_path' => false,
@@ -88,7 +88,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
8888
'failure_path' => null,
8989
'failure_forward' => false,
9090
'require_previous_session' => true,
91-
), $options);
91+
], $options);
9292
$this->logger = $logger;
9393
$this->dispatcher = $dispatcher;
9494
$this->httpUtils = $httpUtils;
@@ -171,7 +171,7 @@ abstract protected function attemptAuthentication(Request $request);
171171
private function onFailure(Request $request, AuthenticationException $failed)
172172
{
173173
if (null !== $this->logger) {
174-
$this->logger->info('Authentication request failed.', array('exception' => $failed));
174+
$this->logger->info('Authentication request failed.', ['exception' => $failed]);
175175
}
176176

177177
$token = $this->tokenStorage->getToken();
@@ -191,7 +191,7 @@ private function onFailure(Request $request, AuthenticationException $failed)
191191
private function onSuccess(Request $request, TokenInterface $token)
192192
{
193193
if (null !== $this->logger) {
194-
$this->logger->info('User has been authenticated successfully.', array('username' => $token->getUsername()));
194+
$this->logger->info('User has been authenticated successfully.', ['username' => $token->getUsername()]);
195195
}
196196

197197
$this->tokenStorage->setToken($token);

Firewall/ContextListener.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function setLogoutOnUserChange($logoutOnUserChange)
7979
public function handle(GetResponseEvent $event)
8080
{
8181
if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) {
82-
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
82+
$this->dispatcher->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
8383
$this->registered = true;
8484
}
8585

@@ -95,17 +95,17 @@ public function handle(GetResponseEvent $event)
9595
$token = $this->safelyUnserialize($token);
9696

9797
if (null !== $this->logger) {
98-
$this->logger->debug('Read existing security token from the session.', array(
98+
$this->logger->debug('Read existing security token from the session.', [
9999
'key' => $this->sessionKey,
100100
'token_class' => \is_object($token) ? \get_class($token) : null,
101-
));
101+
]);
102102
}
103103

104104
if ($token instanceof TokenInterface) {
105105
$token = $this->refreshUser($token);
106106
} elseif (null !== $token) {
107107
if (null !== $this->logger) {
108-
$this->logger->warning('Expected a security token from the session, got something else.', array('key' => $this->sessionKey, 'received' => $token));
108+
$this->logger->warning('Expected a security token from the session, got something else.', ['key' => $this->sessionKey, 'received' => $token]);
109109
}
110110

111111
$token = null;
@@ -129,7 +129,7 @@ public function onKernelResponse(FilterResponseEvent $event)
129129
return;
130130
}
131131

132-
$this->dispatcher->removeListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
132+
$this->dispatcher->removeListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
133133
$this->registered = false;
134134
$session = $request->getSession();
135135

@@ -141,7 +141,7 @@ public function onKernelResponse(FilterResponseEvent $event)
141141
$session->set($this->sessionKey, serialize($token));
142142

143143
if (null !== $this->logger) {
144-
$this->logger->debug('Stored the security token in the session.', array('key' => $this->sessionKey));
144+
$this->logger->debug('Stored the security token in the session.', ['key' => $this->sessionKey]);
145145
}
146146
}
147147
}
@@ -178,7 +178,7 @@ protected function refreshUser(TokenInterface $token)
178178
$userDeauthenticated = true;
179179

180180
if (null !== $this->logger) {
181-
$this->logger->debug('Cannot refresh token because user has changed.', array('username' => $refreshedUser->getUsername(), 'provider' => \get_class($provider)));
181+
$this->logger->debug('Cannot refresh token because user has changed.', ['username' => $refreshedUser->getUsername(), 'provider' => \get_class($provider)]);
182182
}
183183

184184
continue;
@@ -187,7 +187,7 @@ protected function refreshUser(TokenInterface $token)
187187
$token->setUser($refreshedUser);
188188

189189
if (null !== $this->logger) {
190-
$context = array('provider' => \get_class($provider), 'username' => $refreshedUser->getUsername());
190+
$context = ['provider' => \get_class($provider), 'username' => $refreshedUser->getUsername()];
191191

192192
foreach ($token->getRoles() as $role) {
193193
if ($role instanceof SwitchUserRole) {
@@ -204,7 +204,7 @@ protected function refreshUser(TokenInterface $token)
204204
// let's try the next user provider
205205
} catch (UsernameNotFoundException $e) {
206206
if (null !== $this->logger) {
207-
$this->logger->warning('Username could not be found in the selected user provider.', array('username' => $e->getUsername(), 'provider' => \get_class($provider)));
207+
$this->logger->warning('Username could not be found in the selected user provider.', ['username' => $e->getUsername(), 'provider' => \get_class($provider)]);
208208
}
209209

210210
$userNotFoundByProvider = true;
@@ -230,7 +230,7 @@ private function safelyUnserialize($serializedToken)
230230
{
231231
$e = $token = null;
232232
$prevUnserializeHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
233-
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$prevErrorHandler) {
233+
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler) {
234234
if (__FILE__ === $file) {
235235
throw new \UnexpectedValueException($msg, 0x37313bc);
236236
}
@@ -249,7 +249,7 @@ private function safelyUnserialize($serializedToken)
249249
throw $e;
250250
}
251251
if ($this->logger) {
252-
$this->logger->warning('Failed to unserialize the security token from the session.', array('key' => $this->sessionKey, 'received' => $serializedToken, 'exception' => $e));
252+
$this->logger->warning('Failed to unserialize the security token from the session.', ['key' => $this->sessionKey, 'received' => $serializedToken, 'exception' => $e]);
253253
}
254254
}
255255

Firewall/SimpleFormAuthenticationListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
4040
/**
4141
* @throws \InvalidArgumentException In case no simple authenticator is provided
4242
*/
43-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null)
43+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = [], LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null)
4444
{
4545
if (!$simpleAuthenticator) {
4646
throw new \InvalidArgumentException('Missing simple authenticator');
@@ -49,13 +49,13 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
4949
$this->simpleAuthenticator = $simpleAuthenticator;
5050
$this->csrfTokenManager = $csrfTokenManager;
5151

52-
$options = array_merge(array(
52+
$options = array_merge([
5353
'username_parameter' => '_username',
5454
'password_parameter' => '_password',
5555
'csrf_parameter' => '_csrf_token',
5656
'csrf_token_id' => 'authenticate',
5757
'post_only' => true,
58-
), $options);
58+
], $options);
5959

6060
parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, $options, $logger, $dispatcher);
6161
}

Firewall/SwitchUserListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ private function attemptSwitchUser(Request $request, $username)
128128

129129
$user = $this->provider->loadUserByUsername($username);
130130

131-
if (false === $this->accessDecisionManager->decide($token, array($this->role), $user)) {
131+
if (false === $this->accessDecisionManager->decide($token, [$this->role], $user)) {
132132
$exception = new AccessDeniedException();
133133
$exception->setAttributes($this->role);
134134

135135
throw $exception;
136136
}
137137

138138
if (null !== $this->logger) {
139-
$this->logger->info('Attempting to switch to user.', array('username' => $username));
139+
$this->logger->info('Attempting to switch to user.', ['username' => $username]);
140140
}
141141

142142
$this->userChecker->checkPostAuth($user);

Firewall/UsernamePasswordFormAuthenticationListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
3939
{
4040
private $csrfTokenManager;
4141

42-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null)
42+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = [], LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null)
4343
{
44-
parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge(array(
44+
parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge([
4545
'username_parameter' => '_username',
4646
'password_parameter' => '_password',
4747
'csrf_parameter' => '_csrf_token',
4848
'csrf_token_id' => 'authenticate',
4949
'post_only' => true,
50-
), $options), $logger, $dispatcher);
50+
], $options), $logger, $dispatcher);
5151

5252
$this->csrfTokenManager = $csrfTokenManager;
5353
}

Firewall/UsernamePasswordJsonAuthenticationListener.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class UsernamePasswordJsonAuthenticationListener implements ListenerInterface
5555
private $propertyAccessor;
5656
private $sessionStrategy;
5757

58-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $eventDispatcher = null, PropertyAccessorInterface $propertyAccessor = null)
58+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, array $options = [], LoggerInterface $logger = null, EventDispatcherInterface $eventDispatcher = null, PropertyAccessorInterface $propertyAccessor = null)
5959
{
6060
$this->tokenStorage = $tokenStorage;
6161
$this->authenticationManager = $authenticationManager;
@@ -65,7 +65,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
6565
$this->failureHandler = $failureHandler;
6666
$this->logger = $logger;
6767
$this->eventDispatcher = $eventDispatcher;
68-
$this->options = array_merge(array('username_path' => 'username', 'password_path' => 'password'), $options);
68+
$this->options = array_merge(['username_path' => 'username', 'password_path' => 'password'], $options);
6969
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
7070
}
7171

@@ -138,7 +138,7 @@ public function handle(GetResponseEvent $event)
138138
private function onSuccess(Request $request, TokenInterface $token)
139139
{
140140
if (null !== $this->logger) {
141-
$this->logger->info('User has been authenticated successfully.', array('username' => $token->getUsername()));
141+
$this->logger->info('User has been authenticated successfully.', ['username' => $token->getUsername()]);
142142
}
143143

144144
$this->migrateSession($request, $token);
@@ -166,7 +166,7 @@ private function onSuccess(Request $request, TokenInterface $token)
166166
private function onFailure(Request $request, AuthenticationException $failed)
167167
{
168168
if (null !== $this->logger) {
169-
$this->logger->info('Authentication request failed.', array('exception' => $failed));
169+
$this->logger->info('Authentication request failed.', ['exception' => $failed]);
170170
}
171171

172172
$token = $this->tokenStorage->getToken();
@@ -175,7 +175,7 @@ private function onFailure(Request $request, AuthenticationException $failed)
175175
}
176176

177177
if (!$this->failureHandler) {
178-
return new JsonResponse(array('error' => $failed->getMessageKey()), 401);
178+
return new JsonResponse(['error' => $failed->getMessageKey()], 401);
179179
}
180180

181181
$response = $this->failureHandler->onAuthenticationFailure($request, $failed);

HttpUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function createRedirectResponse(Request $request, $path, $status = 302)
7676
*/
7777
public function createRequest(Request $request, $path)
7878
{
79-
$newRequest = Request::create($this->generateUri($request, $path), 'get', array(), $request->cookies->all(), array(), $request->server->all());
79+
$newRequest = Request::create($this->generateUri($request, $path), 'get', [], $request->cookies->all(), [], $request->server->all());
8080

8181
static $setSession;
8282

Logout/LogoutUrlGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class LogoutUrlGenerator
2828
private $requestStack;
2929
private $router;
3030
private $tokenStorage;
31-
private $listeners = array();
31+
private $listeners = [];
3232
private $currentFirewall;
3333

3434
public function __construct(RequestStack $requestStack = null, UrlGeneratorInterface $router = null, TokenStorageInterface $tokenStorage = null)
@@ -50,7 +50,7 @@ public function __construct(RequestStack $requestStack = null, UrlGeneratorInter
5050
*/
5151
public function registerListener($key, $logoutPath, $csrfTokenId, $csrfParameter, CsrfTokenManagerInterface $csrfTokenManager = null, string $context = null)
5252
{
53-
$this->listeners[$key] = array($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager, $context);
53+
$this->listeners[$key] = [$logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager, $context];
5454
}
5555

5656
/**
@@ -83,7 +83,7 @@ public function getLogoutUrl($key = null)
8383
*/
8484
public function setCurrentFirewall($key, $context = null)
8585
{
86-
$this->currentFirewall = array($key, $context);
86+
$this->currentFirewall = [$key, $context];
8787
}
8888

8989
/**
@@ -102,7 +102,7 @@ private function generateLogoutUrl($key, $referenceType)
102102
throw new \LogicException('Unable to generate the logout URL without a path.');
103103
}
104104

105-
$parameters = null !== $csrfTokenManager ? array($csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)) : array();
105+
$parameters = null !== $csrfTokenManager ? [$csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)] : [];
106106

107107
if ('/' === $logoutPath[0]) {
108108
if (!$this->requestStack) {

0 commit comments

Comments
 (0)