4141 */
4242class SecurityExtension extends Extension implements PrependExtensionInterface
4343{
44- private $ requestMatchers = array () ;
45- private $ expressions = array () ;
46- private $ contextListeners = array () ;
47- private $ listenerPositions = array ( 'pre_auth ' , 'form ' , 'http ' , 'remember_me ' ) ;
48- private $ factories = array () ;
49- private $ userProviderFactories = array () ;
50- private $ statelessFirewallKeys = array () ;
44+ private $ requestMatchers = [] ;
45+ private $ expressions = [] ;
46+ private $ contextListeners = [] ;
47+ private $ listenerPositions = [ 'pre_auth ' , 'form ' , 'http ' , 'remember_me ' ] ;
48+ private $ factories = [] ;
49+ private $ userProviderFactories = [] ;
50+ private $ statelessFirewallKeys = [] ;
5151
5252 public function __construct ()
5353 {
5454 foreach ($ this ->listenerPositions as $ position ) {
55- $ this ->factories [$ position ] = array () ;
55+ $ this ->factories [$ position ] = [] ;
5656 }
5757 }
5858
@@ -183,7 +183,7 @@ private function createAuthorization($config, ContainerBuilder $container)
183183 }
184184
185185 $ container ->getDefinition ('security.access_map ' )
186- ->addMethodCall ('add ' , array ( $ matcher , $ attributes , $ access ['requires_channel ' ]) );
186+ ->addMethodCall ('add ' , [ $ matcher , $ attributes , $ access ['requires_channel ' ]] );
187187 }
188188
189189 // allow cache warm-up for expressions
@@ -207,7 +207,7 @@ private function createFirewalls($config, ContainerBuilder $container)
207207 // make the ContextListener aware of the configured user providers
208208 $ contextListenerDefinition = $ container ->getDefinition ('security.context_listener ' );
209209 $ arguments = $ contextListenerDefinition ->getArguments ();
210- $ userProviders = array () ;
210+ $ userProviders = [] ;
211211 foreach ($ providerIds as $ userProviderId ) {
212212 $ userProviders [] = new Reference ($ userProviderId );
213213 }
@@ -222,7 +222,7 @@ private function createFirewalls($config, ContainerBuilder $container)
222222
223223 // load firewall map
224224 $ mapDef = $ container ->getDefinition ('security.firewall.map ' );
225- $ map = $ authenticationProviders = $ contextRefs = array () ;
225+ $ map = $ authenticationProviders = $ contextRefs = [] ;
226226 foreach ($ firewalls as $ name => $ firewall ) {
227227 if (isset ($ firewall ['user_checker ' ]) && 'security.user_checker ' !== $ firewall ['user_checker ' ]) {
228228 $ customUserChecker = true ;
@@ -275,7 +275,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
275275 } elseif (isset ($ firewall ['pattern ' ]) || isset ($ firewall ['host ' ])) {
276276 $ pattern = isset ($ firewall ['pattern ' ]) ? $ firewall ['pattern ' ] : null ;
277277 $ host = isset ($ firewall ['host ' ]) ? $ firewall ['host ' ] : null ;
278- $ methods = isset ($ firewall ['methods ' ]) ? $ firewall ['methods ' ] : array () ;
278+ $ methods = isset ($ firewall ['methods ' ]) ? $ firewall ['methods ' ] : [] ;
279279 $ matcher = $ this ->createRequestMatcher ($ container , $ pattern , $ host , null , $ methods );
280280 }
281281
@@ -284,7 +284,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
284284
285285 // Security disabled?
286286 if (false === $ firewall ['security ' ]) {
287- return array ( $ matcher , array () , null , null ) ;
287+ return [ $ matcher , [] , null , null ] ;
288288 }
289289
290290 $ config ->replaceArgument (4 , $ firewall ['stateless ' ]);
@@ -303,8 +303,8 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
303303 $ config ->replaceArgument (5 , $ defaultProvider );
304304
305305 // Register listeners
306- $ listeners = array () ;
307- $ listenerKeys = array () ;
306+ $ listeners = [] ;
307+ $ listenerKeys = [] ;
308308
309309 // Channel listener
310310 $ listeners [] = new Reference ('security.channel_listener ' );
@@ -328,11 +328,11 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
328328 if (isset ($ firewall ['logout ' ])) {
329329 $ logoutListenerId = 'security.logout_listener. ' .$ id ;
330330 $ logoutListener = $ container ->setDefinition ($ logoutListenerId , new ChildDefinition ('security.logout_listener ' ));
331- $ logoutListener ->replaceArgument (3 , array (
331+ $ logoutListener ->replaceArgument (3 , [
332332 'csrf_parameter ' => $ firewall ['logout ' ]['csrf_parameter ' ],
333333 'csrf_token_id ' => $ firewall ['logout ' ]['csrf_token_id ' ],
334334 'logout_path ' => $ firewall ['logout ' ]['path ' ],
335- ) );
335+ ] );
336336
337337 // add logout success handler
338338 if (isset ($ firewall ['logout ' ]['success_handler ' ])) {
@@ -351,7 +351,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
351351
352352 // add session logout handler
353353 if (true === $ firewall ['logout ' ]['invalidate_session ' ] && false === $ firewall ['stateless ' ]) {
354- $ logoutListener ->addMethodCall ('addHandler ' , array ( new Reference ('security.logout.handler.session ' )) );
354+ $ logoutListener ->addMethodCall ('addHandler ' , [ new Reference ('security.logout.handler.session ' )] );
355355 }
356356
357357 // add cookie logout handler
@@ -360,25 +360,25 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
360360 $ cookieHandler = $ container ->setDefinition ($ cookieHandlerId , new ChildDefinition ('security.logout.handler.cookie_clearing ' ));
361361 $ cookieHandler ->addArgument ($ firewall ['logout ' ]['delete_cookies ' ]);
362362
363- $ logoutListener ->addMethodCall ('addHandler ' , array ( new Reference ($ cookieHandlerId )) );
363+ $ logoutListener ->addMethodCall ('addHandler ' , [ new Reference ($ cookieHandlerId )] );
364364 }
365365
366366 // add custom handlers
367367 foreach ($ firewall ['logout ' ]['handlers ' ] as $ handlerId ) {
368- $ logoutListener ->addMethodCall ('addHandler ' , array ( new Reference ($ handlerId )) );
368+ $ logoutListener ->addMethodCall ('addHandler ' , [ new Reference ($ handlerId )] );
369369 }
370370
371371 // register with LogoutUrlGenerator
372372 $ container
373373 ->getDefinition ('security.logout_url_generator ' )
374- ->addMethodCall ('registerListener ' , array (
374+ ->addMethodCall ('registerListener ' , [
375375 $ id ,
376376 $ firewall ['logout ' ]['path ' ],
377377 $ firewall ['logout ' ]['csrf_token_id ' ],
378378 $ firewall ['logout ' ]['csrf_parameter ' ],
379379 isset ($ firewall ['logout ' ]['csrf_token_generator ' ]) ? new Reference ($ firewall ['logout ' ]['csrf_token_generator ' ]) : null ,
380380 false === $ firewall ['stateless ' ] && isset ($ firewall ['context ' ]) ? $ firewall ['context ' ] : null ,
381- ) )
381+ ] )
382382 ;
383383 }
384384
@@ -425,7 +425,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
425425 $ config ->replaceArgument (10 , $ listenerKeys );
426426 $ config ->replaceArgument (11 , isset ($ firewall ['switch_user ' ]) ? $ firewall ['switch_user ' ] : null );
427427
428- return array ( $ matcher , $ listeners , $ exceptionListener , null !== $ logoutListenerId ? new Reference ($ logoutListenerId ) : null ) ;
428+ return [ $ matcher , $ listeners , $ exceptionListener , null !== $ logoutListenerId ? new Reference ($ logoutListenerId ) : null ] ;
429429 }
430430
431431 private function createContextListener ($ container , $ contextKey )
@@ -443,7 +443,7 @@ private function createContextListener($container, $contextKey)
443443
444444 private function createAuthenticationListeners ($ container , $ id , $ firewall , &$ authenticationProviders , $ defaultProvider = null , array $ providerIds , $ defaultEntryPoint )
445445 {
446- $ listeners = array () ;
446+ $ listeners = [] ;
447447 $ hasListeners = false ;
448448
449449 foreach ($ this ->listenerPositions as $ position ) {
@@ -505,19 +505,19 @@ private function createAuthenticationListeners($container, $id, $firewall, &$aut
505505 throw new InvalidConfigurationException (sprintf ('No authentication listener registered for firewall "%s". ' , $ id ));
506506 }
507507
508- return array ( $ listeners , $ defaultEntryPoint) ;
508+ return [ $ listeners , $ defaultEntryPoint] ;
509509 }
510510
511511 private function createEncoders ($ encoders , ContainerBuilder $ container )
512512 {
513- $ encoderMap = array () ;
513+ $ encoderMap = [] ;
514514 foreach ($ encoders as $ class => $ encoder ) {
515515 $ encoderMap [$ class ] = $ this ->createEncoder ($ encoder , $ container );
516516 }
517517
518518 $ container
519519 ->getDefinition ('security.encoder_factory.generic ' )
520- ->setArguments (array ( $ encoderMap) )
520+ ->setArguments ([ $ encoderMap] )
521521 ;
522522 }
523523
@@ -530,33 +530,33 @@ private function createEncoder($config, ContainerBuilder $container)
530530
531531 // plaintext encoder
532532 if ('plaintext ' === $ config ['algorithm ' ]) {
533- $ arguments = array ( $ config ['ignore_case ' ]) ;
533+ $ arguments = [ $ config ['ignore_case ' ]] ;
534534
535- return array (
535+ return [
536536 'class ' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder ' ,
537537 'arguments ' => $ arguments ,
538- ) ;
538+ ] ;
539539 }
540540
541541 // pbkdf2 encoder
542542 if ('pbkdf2 ' === $ config ['algorithm ' ]) {
543- return array (
543+ return [
544544 'class ' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder ' ,
545- 'arguments ' => array (
545+ 'arguments ' => [
546546 $ config ['hash_algorithm ' ],
547547 $ config ['encode_as_base64 ' ],
548548 $ config ['iterations ' ],
549549 $ config ['key_length ' ],
550- ) ,
551- ) ;
550+ ] ,
551+ ] ;
552552 }
553553
554554 // bcrypt encoder
555555 if ('bcrypt ' === $ config ['algorithm ' ]) {
556- return array (
556+ return [
557557 'class ' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder ' ,
558- 'arguments ' => array ( $ config ['cost ' ]) ,
559- ) ;
558+ 'arguments ' => [ $ config ['cost ' ]] ,
559+ ] ;
560560 }
561561
562562 // Argon2i encoder
@@ -569,14 +569,14 @@ private function createEncoder($config, ContainerBuilder $container)
569569 throw new InvalidConfigurationException ('Argon2i algorithm is not supported. Install the libsodium extension or use BCrypt instead. ' );
570570 }
571571
572- return array (
572+ return [
573573 'class ' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder ' ,
574- 'arguments ' => array (
574+ 'arguments ' => [
575575 $ config ['memory_cost ' ],
576576 $ config ['time_cost ' ],
577577 $ config ['threads ' ],
578- ) ,
579- ) ;
578+ ] ,
579+ ] ;
580580 }
581581
582582 // run-time configured encoder
@@ -586,7 +586,7 @@ private function createEncoder($config, ContainerBuilder $container)
586586 // Parses user providers and returns an array of their ids
587587 private function createUserProviders ($ config , ContainerBuilder $ container )
588588 {
589- $ providerIds = array () ;
589+ $ providerIds = [] ;
590590 foreach ($ config ['providers ' ] as $ name => $ provider ) {
591591 $ id = $ this ->createUserDaoProvider ($ name , $ provider , $ container );
592592 $ providerIds [str_replace ('- ' , '_ ' , $ name )] = $ id ;
@@ -620,7 +620,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
620620
621621 // Chain provider
622622 if (isset ($ provider ['chain ' ])) {
623- $ providers = array () ;
623+ $ providers = [] ;
624624 foreach ($ provider ['chain ' ]['providers ' ] as $ providerName ) {
625625 $ providers [] = new Reference ($ this ->getUserProviderId ($ providerName ));
626626 }
@@ -697,20 +697,20 @@ private function createExpression($container, $expression)
697697 return $ this ->expressions [$ id ] = new Reference ($ id );
698698 }
699699
700- private function createRequestMatcher ($ container , $ path = null , $ host = null , int $ port = null , $ methods = array () , $ ip = null , array $ attributes = array () )
700+ private function createRequestMatcher ($ container , $ path = null , $ host = null , int $ port = null , $ methods = [] , $ ip = null , array $ attributes = [] )
701701 {
702702 if ($ methods ) {
703703 $ methods = array_map ('strtoupper ' , (array ) $ methods );
704704 }
705705
706- $ id = '.security.request_matcher. ' .ContainerBuilder::hash (array ( $ path , $ host , $ port , $ methods , $ ip , $ attributes) );
706+ $ id = '.security.request_matcher. ' .ContainerBuilder::hash ([ $ path , $ host , $ port , $ methods , $ ip , $ attributes] );
707707
708708 if (isset ($ this ->requestMatchers [$ id ])) {
709709 return $ this ->requestMatchers [$ id ];
710710 }
711711
712712 // only add arguments that are necessary
713- $ arguments = array ( $ path , $ host , $ methods , $ ip , $ attributes , null , $ port) ;
713+ $ arguments = [ $ path , $ host , $ methods , $ ip , $ attributes , null , $ port] ;
714714 while (\count ($ arguments ) > 0 && !end ($ arguments )) {
715715 array_pop ($ arguments );
716716 }
0 commit comments