22
33namespace M6Web \Bundle \StatsdBundle \DependencyInjection ;
44
5+ use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
6+ use Symfony \Component \Config \FileLocator ;
57use Symfony \Component \DependencyInjection \ContainerBuilder ;
6- use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
78use Symfony \Component \DependencyInjection \ContainerInterface ;
89use Symfony \Component \DependencyInjection \Definition ;
9- use Symfony \Component \DependencyInjection \Reference ;
10- use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
1110use Symfony \Component \DependencyInjection \Loader ;
12- use Symfony \Component \Config \FileLocator ;
11+ use Symfony \Component \DependencyInjection \Reference ;
12+ use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
1313
1414/**
1515 * This is the class that loads and manages your bundle configuration
@@ -24,9 +24,9 @@ class M6WebStatsdExtension extends Extension
2424 public function load (array $ configs , ContainerBuilder $ container )
2525 {
2626 $ configuration = new Configuration ();
27- $ config = $ this ->processConfiguration ($ configuration , $ configs );
28- $ servers = isset ($ config ['servers ' ]) ? $ config ['servers ' ] : [];
29- $ clients = isset ($ config ['clients ' ]) ? $ config ['clients ' ] : [];
27+ $ config = $ this ->processConfiguration ($ configuration , $ configs );
28+ $ servers = isset ($ config ['servers ' ]) ? $ config ['servers ' ] : [];
29+ $ clients = isset ($ config ['clients ' ]) ? $ config ['clients ' ] : [];
3030
3131 $ loader = new Loader \YamlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
3232 $ loader ->load ('services.yml ' );
@@ -49,15 +49,15 @@ public function load(array $configs, ContainerBuilder $container)
4949 'data_collector ' ,
5050 [
5151 'template ' => '@M6WebStatsd/Collector/statsd.html.twig ' ,
52- 'id ' => 'statsd '
52+ 'id ' => 'statsd ' ,
5353 ]
5454 );
5555
5656 $ definition ->addTag (
5757 'kernel.event_listener ' ,
5858 [
5959 'event ' => 'kernel.response ' ,
60- 'method ' => 'onKernelResponse '
60+ 'method ' => 'onKernelResponse ' ,
6161 ]
6262 );
6363
@@ -98,15 +98,16 @@ public function load(array $configs, ContainerBuilder $container)
9898 * @param string $alias Alias of the client
9999 * @param array $config Base config of the client
100100 * @param array $servers List of available servers as describe in the config file
101- * @param boolean $baseEvents Register base events
101+ * @param bool $baseEvents Register base events
102102 *
103103 * @throws InvalidConfigurationException
104+ *
104105 * @return string the service name
105106 */
106107 protected function loadClient ($ container , $ alias , array $ config , array $ servers , $ baseEvents )
107108 {
108- $ usedServers = [];
109- $ events = $ config ['events ' ];
109+ $ usedServers = [];
110+ $ events = $ config ['events ' ];
110111 $ matchedServers = [];
111112
112113 if ($ config ['servers ' ][0 ] == 'all ' ) {
@@ -115,7 +116,6 @@ protected function loadClient($container, $alias, array $config, array $servers,
115116 } else {
116117 // Use only declared servers
117118 foreach ($ config ['servers ' ] as $ serverAlias ) {
118-
119119 // Named server
120120 if (array_key_exists ($ serverAlias , $ servers )) {
121121 $ matchedServers [] = $ serverAlias ;
@@ -127,7 +127,7 @@ protected function loadClient($container, $alias, array $config, array $servers,
127127 foreach (array_keys ($ servers ) as $ key ) {
128128 if (fnmatch ($ serverAlias , $ key )) {
129129 $ matchedServers [] = $ key ;
130- $ found = true ;
130+ $ found = true ;
131131 }
132132 }
133133
@@ -146,12 +146,12 @@ protected function loadClient($container, $alias, array $config, array $servers,
146146 foreach ($ matchedServers as $ serverAlias ) {
147147 $ usedServers [] = [
148148 'address ' => $ servers [$ serverAlias ]['address ' ],
149- 'port ' => $ servers [$ serverAlias ]['port ' ]
149+ 'port ' => $ servers [$ serverAlias ]['port ' ],
150150 ];
151151 }
152152
153153 // Add the statsd client configured
154- $ serviceId = ($ alias == 'default ' ) ? 'm6_statsd ' : 'm6_statsd. ' .$ alias ;
154+ $ serviceId = ($ alias == 'default ' ) ? 'm6_statsd ' : 'm6_statsd. ' .$ alias ;
155155 $ definition = new Definition ('M6Web\Bundle\StatsdBundle\Client\Client ' );
156156 $ definition ->setPublic (true );
157157 $ definition ->addArgument ($ usedServers );
@@ -176,26 +176,26 @@ protected function loadClient($container, $alias, array $config, array $servers,
176176 $ definition ->addArgument (new Reference ($ serviceId ));
177177 $ definition ->addArgument (new Reference ('event_dispatcher ' ));
178178 $ definition ->addTag ('kernel.event_listener ' , [
179- 'event ' => 'kernel.terminate ' ,
180- 'method ' => 'onKernelTerminate ' ,
181- 'priority ' => -100
179+ 'event ' => 'kernel.terminate ' ,
180+ 'method ' => 'onKernelTerminate ' ,
181+ 'priority ' => -100 ,
182182 ]);
183183 $ definition ->addTag ('kernel.event_listener ' , [
184- 'event ' => 'console.terminate ' ,
185- 'method ' => 'onConsoleTerminate ' ,
186- 'priority ' => -100
184+ 'event ' => 'console.terminate ' ,
185+ 'method ' => 'onConsoleTerminate ' ,
186+ 'priority ' => -100 ,
187187 ]);
188188
189189 if ($ baseEvents ) {
190190 $ definition ->addTag ('kernel.event_listener ' , [
191191 'event ' => 'kernel.terminate ' ,
192192 'method ' => 'dispatchBaseEvents ' ,
193- 'priority ' => 0
193+ 'priority ' => 0 ,
194194 ]);
195195 $ definition ->addTag ('kernel.event_listener ' , [
196196 'event ' => 'kernel.exception ' ,
197197 'method ' => 'onKernelException ' ,
198- 'priority ' => 0
198+ 'priority ' => 0 ,
199199 ]);
200200 }
201201 $ container ->setDefinition ($ serviceListenerId , $ definition );
@@ -208,10 +208,8 @@ protected function loadClient($container, $alias, array $config, array $servers,
208208 *
209209 * trick allowing bypassing the Bundle::getContainerExtension check on getAlias
210210 * not very clean, to investigate
211- *
212- * @return string
213211 */
214- public function getAlias ()
212+ public function getAlias (): string
215213 {
216214 return 'm6_statsd ' ;
217215 }
0 commit comments