Skip to content

Commit

Permalink
switched array() to []
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 16, 2019
1 parent e3dc131 commit ef9cb05
Show file tree
Hide file tree
Showing 57 changed files with 472 additions and 472 deletions.
10 changes: 5 additions & 5 deletions AccessMap.php
Expand Up @@ -22,16 +22,16 @@
*/
class AccessMap implements AccessMapInterface
{
private $map = array();
private $map = [];

/**
* @param RequestMatcherInterface $requestMatcher A RequestMatcherInterface instance
* @param array $attributes An array of attributes to pass to the access decision manager (like roles)
* @param string|null $channel The channel to enforce (http, https, or null)
*/
public function add(RequestMatcherInterface $requestMatcher, array $attributes = array(), $channel = null)
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], $channel = null)
{
$this->map[] = array($requestMatcher, $attributes, $channel);
$this->map[] = [$requestMatcher, $attributes, $channel];
}

/**
Expand All @@ -41,10 +41,10 @@ public function getPatterns(Request $request)
{
foreach ($this->map as $elements) {
if (null === $elements[0] || $elements[0]->matches($request)) {
return array($elements[1], $elements[2]);
return [$elements[1], $elements[2]];
}
}

return array(null, null);
return [null, null];
}
}
10 changes: 5 additions & 5 deletions Authentication/DefaultAuthenticationFailureHandler.php
Expand Up @@ -35,14 +35,14 @@ class DefaultAuthenticationFailureHandler implements AuthenticationFailureHandle
protected $httpUtils;
protected $logger;
protected $options;
protected $defaultOptions = array(
protected $defaultOptions = [
'failure_path' => null,
'failure_forward' => false,
'login_path' => '/login',
'failure_path_parameter' => '_failure_path',
);
];

public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtils, array $options = array(), LoggerInterface $logger = null)
public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtils, array $options = [], LoggerInterface $logger = null)
{
$this->httpKernel = $httpKernel;
$this->httpUtils = $httpUtils;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio

if ($this->options['failure_forward']) {
if (null !== $this->logger) {
$this->logger->debug('Authentication failure, forward triggered.', array('failure_path' => $this->options['failure_path']));
$this->logger->debug('Authentication failure, forward triggered.', ['failure_path' => $this->options['failure_path']]);
}

$subRequest = $this->httpUtils->createRequest($request, $this->options['failure_path']);
Expand All @@ -90,7 +90,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
}

if (null !== $this->logger) {
$this->logger->debug('Authentication failure, redirect triggered.', array('failure_path' => $this->options['failure_path']));
$this->logger->debug('Authentication failure, redirect triggered.', ['failure_path' => $this->options['failure_path']]);
}

$request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
Expand Down
6 changes: 3 additions & 3 deletions Authentication/DefaultAuthenticationSuccessHandler.php
Expand Up @@ -31,19 +31,19 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle
protected $httpUtils;
protected $options;
protected $providerKey;
protected $defaultOptions = array(
protected $defaultOptions = [
'always_use_default_target_path' => false,
'default_target_path' => '/',
'login_path' => '/login',
'target_path_parameter' => '_target_path',
'use_referer' => false,
);
];

/**
* @param HttpUtils $httpUtils
* @param array $options Options for processing a successful authentication attempt
*/
public function __construct(HttpUtils $httpUtils, array $options = array())
public function __construct(HttpUtils $httpUtils, array $options = [])
{
$this->httpUtils = $httpUtils;
$this->setOptions($options);
Expand Down
4 changes: 2 additions & 2 deletions Authentication/SimpleAuthenticationHandler.php
Expand Up @@ -55,7 +55,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
if ($this->simpleAuthenticator instanceof AuthenticationSuccessHandlerInterface) {
if ($this->logger) {
$this->logger->debug('Selected an authentication success handler.', array('handler' => \get_class($this->simpleAuthenticator)));
$this->logger->debug('Selected an authentication success handler.', ['handler' => \get_class($this->simpleAuthenticator)]);
}

$response = $this->simpleAuthenticator->onAuthenticationSuccess($request, $token);
Expand All @@ -82,7 +82,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
{
if ($this->simpleAuthenticator instanceof AuthenticationFailureHandlerInterface) {
if ($this->logger) {
$this->logger->debug('Selected an authentication failure handler.', array('handler' => \get_class($this->simpleAuthenticator)));
$this->logger->debug('Selected an authentication failure handler.', ['handler' => \get_class($this->simpleAuthenticator)]);
}

$response = $this->simpleAuthenticator->onAuthenticationFailure($request, $exception);
Expand Down
2 changes: 1 addition & 1 deletion EntryPoint/DigestAuthenticationEntryPoint.php
Expand Up @@ -58,7 +58,7 @@ public function start(Request $request, AuthenticationException $authException =
}

if (null !== $this->logger) {
$this->logger->debug('WWW-Authenticate header sent.', array('header' => $authenticateHeader));
$this->logger->debug('WWW-Authenticate header sent.', ['header' => $authenticateHeader]);
}

$response = new Response();
Expand Down
6 changes: 3 additions & 3 deletions Firewall.php
Expand Up @@ -99,10 +99,10 @@ public function onKernelFinishRequest(FinishRequestEvent $event)
*/
public static function getSubscribedEvents()
{
return array(
KernelEvents::REQUEST => array('onKernelRequest', 8),
return [
KernelEvents::REQUEST => ['onKernelRequest', 8],
KernelEvents::FINISH_REQUEST => 'onKernelFinishRequest',
);
];
}

protected function handleRequest(GetResponseEvent $event, $listeners)
Expand Down
10 changes: 5 additions & 5 deletions Firewall/AbstractAuthenticationListener.php
Expand Up @@ -78,7 +78,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
*
* @throws \InvalidArgumentException
*/
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = [], LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
if (empty($providerKey)) {
throw new \InvalidArgumentException('$providerKey must not be empty.');
Expand All @@ -90,7 +90,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
$this->providerKey = $providerKey;
$this->successHandler = $successHandler;
$this->failureHandler = $failureHandler;
$this->options = array_merge(array(
$this->options = array_merge([
'check_path' => '/login_check',
'login_path' => '/login',
'always_use_default_target_path' => false,
Expand All @@ -100,7 +100,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
'failure_path' => null,
'failure_forward' => false,
'require_previous_session' => true,
), $options);
], $options);
$this->logger = $logger;
$this->dispatcher = $dispatcher;
$this->httpUtils = $httpUtils;
Expand Down Expand Up @@ -183,7 +183,7 @@ abstract protected function attemptAuthentication(Request $request);
private function onFailure(Request $request, AuthenticationException $failed)
{
if (null !== $this->logger) {
$this->logger->info('Authentication request failed.', array('exception' => $failed));
$this->logger->info('Authentication request failed.', ['exception' => $failed]);
}

$token = $this->tokenStorage->getToken();
Expand All @@ -203,7 +203,7 @@ private function onFailure(Request $request, AuthenticationException $failed)
private function onSuccess(Request $request, TokenInterface $token)
{
if (null !== $this->logger) {
$this->logger->info('User has been authenticated successfully.', array('username' => $token->getUsername()));
$this->logger->info('User has been authenticated successfully.', ['username' => $token->getUsername()]);
}

$this->tokenStorage->setToken($token);
Expand Down
8 changes: 4 additions & 4 deletions Firewall/AbstractPreAuthenticatedListener.php
Expand Up @@ -66,7 +66,7 @@ final public function handle(GetResponseEvent $event)
}

if (null !== $this->logger) {
$this->logger->debug('Checking current security token.', array('token' => (string) $this->tokenStorage->getToken()));
$this->logger->debug('Checking current security token.', ['token' => (string) $this->tokenStorage->getToken()]);
}

if (null !== $token = $this->tokenStorage->getToken()) {
Expand All @@ -76,14 +76,14 @@ final public function handle(GetResponseEvent $event)
}

if (null !== $this->logger) {
$this->logger->debug('Trying to pre-authenticate user.', array('username' => (string) $user));
$this->logger->debug('Trying to pre-authenticate user.', ['username' => (string) $user]);
}

try {
$token = $this->authenticationManager->authenticate(new PreAuthenticatedToken($user, $credentials, $this->providerKey));

if (null !== $this->logger) {
$this->logger->info('Pre-authentication successful.', array('token' => (string) $token));
$this->logger->info('Pre-authentication successful.', ['token' => (string) $token]);
}

$this->migrateSession($request, $token);
Expand Down Expand Up @@ -119,7 +119,7 @@ private function clearToken(AuthenticationException $exception)
$this->tokenStorage->setToken(null);

if (null !== $this->logger) {
$this->logger->info('Cleared security token due to an exception.', array('exception' => $exception));
$this->logger->info('Cleared security token due to an exception.', ['exception' => $exception]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Firewall/AnonymousAuthenticationListener.php
Expand Up @@ -49,7 +49,7 @@ public function handle(GetResponseEvent $event)
}

try {
$token = new AnonymousToken($this->secret, 'anon.', array());
$token = new AnonymousToken($this->secret, 'anon.', []);
if (null !== $this->authenticationManager) {
$token = $this->authenticationManager->authenticate($token);
}
Expand All @@ -61,7 +61,7 @@ public function handle(GetResponseEvent $event)
}
} catch (AuthenticationException $failed) {
if (null !== $this->logger) {
$this->logger->info('Anonymous authentication failed.', array('exception' => $failed));
$this->logger->info('Anonymous authentication failed.', ['exception' => $failed]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Firewall/BasicAuthenticationListener.php
Expand Up @@ -69,7 +69,7 @@ public function handle(GetResponseEvent $event)
}

if (null !== $this->logger) {
$this->logger->info('Basic authentication Authorization header found for user.', array('username' => $username));
$this->logger->info('Basic authentication Authorization header found for user.', ['username' => $username]);
}

try {
Expand All @@ -85,7 +85,7 @@ public function handle(GetResponseEvent $event)
}

if (null !== $this->logger) {
$this->logger->info('Basic authentication failed for user.', array('username' => $username, 'exception' => $e));
$this->logger->info('Basic authentication failed for user.', ['username' => $username, 'exception' => $e]);
}

if ($this->ignoreFailure) {
Expand Down
22 changes: 11 additions & 11 deletions Firewall/ContextListener.php
Expand Up @@ -79,7 +79,7 @@ public function setLogoutOnUserChange($logoutOnUserChange)
public function handle(GetResponseEvent $event)
{
if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) {
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
$this->dispatcher->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
$this->registered = true;
}

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

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

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

$token = null;
Expand All @@ -129,7 +129,7 @@ public function onKernelResponse(FilterResponseEvent $event)
return;
}

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

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

if (null !== $this->logger) {
$this->logger->debug('Stored the security token in the session.', array('key' => $this->sessionKey));
$this->logger->debug('Stored the security token in the session.', ['key' => $this->sessionKey]);
}
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ protected function refreshUser(TokenInterface $token)
$userDeauthenticated = true;

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

continue;
Expand All @@ -191,7 +191,7 @@ protected function refreshUser(TokenInterface $token)
$token->setUser($refreshedUser);

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

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

$userNotFoundByProvider = true;
Expand All @@ -234,7 +234,7 @@ private function safelyUnserialize($serializedToken)
{
$e = $token = null;
$prevUnserializeHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$prevErrorHandler) {
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler) {
if (__FILE__ === $file) {
throw new \UnexpectedValueException($msg, 0x37313bc);
}
Expand All @@ -254,7 +254,7 @@ private function safelyUnserialize($serializedToken)
throw $e;
}
if ($this->logger) {
$this->logger->warning('Failed to unserialize the security token from the session.', array('key' => $this->sessionKey, 'received' => $serializedToken, 'exception' => $e));
$this->logger->warning('Failed to unserialize the security token from the session.', ['key' => $this->sessionKey, 'received' => $serializedToken, 'exception' => $e]);
}
}

Expand Down

0 comments on commit ef9cb05

Please sign in to comment.