From 7b1444c9ed84195535dee612f035bc8a86078dce Mon Sep 17 00:00:00 2001 From: David Maicher Date: Thu, 20 Apr 2023 14:15:27 +0200 Subject: [PATCH] add PHP cs fixer to CI --- .github/workflows/ci.yml | 68 +++-- .gitignore | 1 + .php-cs-fixer.php | 8 + src/ClientRegistry.php | 20 +- src/DependencyInjection/Configuration.php | 12 +- .../NelmioSolariumExtension.php | 36 ++- src/Logger.php | 38 +-- tests/NelmioSolariumExtensionTest.php | 252 +++++++++--------- 8 files changed, 225 insertions(+), 210 deletions(-) create mode 100644 .php-cs-fixer.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb1c3fd..2da7a8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Build -on: [pull_request] +on: [ pull_request ] jobs: tests: @@ -10,33 +10,43 @@ jobs: fail-fast: false matrix: include: - - php: 7.3 - - php: 7.4 - SYMFONY_REQUIRE: 5.4.* - - php: 8.0 - - php: 8.1 - - php: 8.2 + - php: 7.3 + - php: 7.4 + SYMFONY_REQUIRE: 5.4.* + - php: 8.0 + - php: 8.1 + - php: 8.2 steps: - - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - coverage: none - - - name: Configure Composer minimum stability - if: matrix.stability - run: composer config minimum-stability ${{ matrix.stability }} - - - name: Install symfony/flex - run: composer global config allow-plugins.symfony/flex true && composer global require symfony/flex - - - name: Install dependencies - env: - SYMFONY_REQUIRE: "${{ matrix.SYMFONY_REQUIRE }}" - run: composer update ${{ matrix.composer-flags }} --prefer-dist - - - name: Phpunit - run: ./vendor/bin/simple-phpunit + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + coverage: none + + - name: Configure Composer minimum stability + if: matrix.stability + run: composer config minimum-stability ${{ matrix.stability }} + + - name: Install symfony/flex + run: composer global config allow-plugins.symfony/flex true && composer global require symfony/flex + + - name: Install dependencies + env: + SYMFONY_REQUIRE: "${{ matrix.SYMFONY_REQUIRE }}" + run: composer update ${{ matrix.composer-flags }} --prefer-dist + + - name: Phpunit + run: ./vendor/bin/simple-phpunit + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.php --diff --dry-run diff --git a/.gitignore b/.gitignore index 3d7e132..aa2d78d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock .phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..2df8e65 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,8 @@ +setRules([ + '@Symfony' => true, + 'yoda_style' => false, + ]) +; diff --git a/src/ClientRegistry.php b/src/ClientRegistry.php index fc9fc1f..914f65a 100644 --- a/src/ClientRegistry.php +++ b/src/ClientRegistry.php @@ -5,11 +5,9 @@ use Solarium\Client; /** - * Class ClientRegistry + * Class ClientRegistry. * * Service to access all the clients configured by the bundle - * - * @package Nelmio\SolariumBundle */ class ClientRegistry { @@ -28,7 +26,7 @@ public function __construct(array $clients, $defaultClientName) /** * Gets the default client name. * - * @return string The default client name. + * @return string the default client name */ public function getDefaultClientName() { @@ -38,10 +36,11 @@ public function getDefaultClientName() /** * Gets the named client. * - * @param string $name The client name (null for the default one). + * @param string $name the client name (null for the default one) * - * @throws \InvalidArgumentException * @return Client + * + * @throws \InvalidArgumentException */ public function getClient($name = null) { @@ -53,13 +52,13 @@ public function getClient($name = null) return $this->clients[$name]; } - throw new \InvalidArgumentException(($name === null ? 'default client' : 'client ' . $name) . ' not configured'); + throw new \InvalidArgumentException(($name === null ? 'default client' : 'client '.$name).' not configured'); } /** * Gets an array of all registered clients. * - * @return array An array of Client instances. + * @return array an array of Client instances */ public function getClients() { @@ -69,11 +68,10 @@ public function getClients() /** * Gets all client names. * - * @return array An array of client names. + * @return array an array of client names */ public function getClientNames() { return array_keys($this->clients); } - -} \ No newline at end of file +} diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index bfb420c..a2dbba8 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -70,12 +70,12 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('default_endpoint')->end() ->arrayNode('load_balancer') ->addDefaultsIfNotSet() - ->treatFalseLike(array('enabled' => false)) - ->treatTrueLike(array('enabled' => true)) - ->treatNullLike(array('enabled' => true)) + ->treatFalseLike(['enabled' => false]) + ->treatTrueLike(['enabled' => true]) + ->treatNullLike(['enabled' => true]) ->beforeNormalization() ->ifArray() - ->then(function($v) { + ->then(function ($v) { $v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true; return $v; @@ -93,7 +93,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->always(function (array $endpoints) { // the values should be the weight and the keys the endpoints name // handle the case where people just list the endpoints like [endpoint1, endpoint2] - $normalizedEndpoints = array(); + $normalizedEndpoints = []; foreach ($endpoints as $name => $weight) { if (!is_string($name)) { $name = $weight; @@ -109,7 +109,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->prototype('scalar')->end() ->end() ->arrayNode('blocked_query_types') - ->defaultValue(array(Client::QUERY_UPDATE)) + ->defaultValue([Client::QUERY_UPDATE]) ->beforeNormalization() ->ifString() ->then($this->getNormalizeListToArrayClosure()) diff --git a/src/DependencyInjection/NelmioSolariumExtension.php b/src/DependencyInjection/NelmioSolariumExtension.php index 4b6b4ab..44e0dea 100644 --- a/src/DependencyInjection/NelmioSolariumExtension.php +++ b/src/DependencyInjection/NelmioSolariumExtension.php @@ -42,7 +42,7 @@ public function load(array $configs, ContainerBuilder $container) $defaultClient = $config['default_client']; if (!count($config['clients'])) { - $config['clients'][$defaultClient] = array(); + $config['clients'][$defaultClient] = []; } elseif (count($config['clients']) === 1) { $defaultClient = key($config['clients']); } @@ -50,7 +50,7 @@ public function load(array $configs, ContainerBuilder $container) // Configure the Solarium endpoints $endpointReferences = $this->configureEndpoints($config['endpoints'], $container); - $clients = array(); + $clients = []; foreach ($config['clients'] as $name => $clientOptions) { $clientName = sprintf('solarium.client.%s', $name); @@ -73,10 +73,10 @@ public function load(array $configs, ContainerBuilder $container) $options = []; - //If some specific endpoints are given + // If some specific endpoints are given if ($endpointReferences) { if (isset($clientOptions['endpoints']) && !empty($clientOptions['endpoints'])) { - $endpoints = array(); + $endpoints = []; foreach ($clientOptions['endpoints'] as $endpointName) { if (isset($endpointReferences[$endpointName])) { $endpoints[] = $endpointReferences[$endpointName]; @@ -89,7 +89,6 @@ public function load(array $configs, ContainerBuilder $container) $options['endpoint'] = $endpoints; } - if (isset($clientOptions['adapter_service'])) { $adapterName = $clientOptions['adapter_service']; } else { @@ -103,26 +102,25 @@ public function load(array $configs, ContainerBuilder $container) $clientDefinition->setArguments([ new Reference($adapterName), new Reference('event_dispatcher'), - $options + $options, ]); // Configure the Load-Balancer for the current client $this->configureLoadBalancerForClient($clientName, $clientOptions, $clientDefinition, $container); - //Default endpoint + // Default endpoint if (isset($clientOptions['default_endpoint'], $endpointReferences[$clientOptions['default_endpoint']])) { - $clientDefinition->addMethodCall('setDefaultEndpoint', array($clientOptions['default_endpoint'])); + $clientDefinition->addMethodCall('setDefaultEndpoint', [$clientOptions['default_endpoint']]); } - //Add the optional adapter class + // Add the optional adapter class if (isset($clientOptions['adapter_class'])) { - $clientDefinition->addMethodCall('setAdapter', array($clientOptions['adapter_class'])); + $clientDefinition->addMethodCall('setAdapter', [$clientOptions['adapter_class']]); } // Configure the Plugins for the current client $this->configurePluginsForClient($clientOptions, $clientDefinition); - if ($isDebug) { // If debug, associate the logger to this client $this->configureLoggerForClient($clientName, $container); @@ -139,14 +137,14 @@ public function load(array $configs, ContainerBuilder $container) private function configureEndpoints(array $endpoints, ContainerBuilder $container): array { - $endpointReferences = array(); + $endpointReferences = []; foreach ($endpoints as $name => $endpointOptions) { $endpointName = sprintf('solarium.client.endpoint.%s', $name); $endpointOptions['key'] = $name; $container ->setDefinition($endpointName, new Definition(Endpoint::class)) - ->setArguments(array($endpointOptions)); + ->setArguments([$endpointOptions]); $endpointReferences[$name] = new Reference($endpointName); } @@ -156,7 +154,7 @@ private function configureEndpoints(array $endpoints, ContainerBuilder $containe private function configureLoggerForClient(string $clientName, ContainerBuilder $container): void { $logger = new Reference('solarium.data_collector'); - $container->getDefinition($clientName)->addMethodCall('registerPlugin', array($clientName . '.logger', $logger)); + $container->getDefinition($clientName)->addMethodCall('registerPlugin', [$clientName.'.logger', $logger]); } private function configureLoadBalancerForClient( @@ -168,19 +166,19 @@ private function configureLoadBalancerForClient( if (isset($clientOptions['load_balancer']) && $clientOptions['load_balancer']['enabled']) { $loadBalancerDefinition = new Definition(Loadbalancer::class); $loadBalancerDefinition - ->addMethodCall('addEndpoints', array($clientOptions['load_balancer']['endpoints'])) + ->addMethodCall('addEndpoints', [$clientOptions['load_balancer']['endpoints']]) ; if (isset($clientOptions['load_balancer']['blocked_query_types'])) { $loadBalancerDefinition - ->addMethodCall('setBlockedQueryTypes', array($clientOptions['load_balancer']['blocked_query_types'])) + ->addMethodCall('setBlockedQueryTypes', [$clientOptions['load_balancer']['blocked_query_types']]) ; } - $loadBalancerName = $clientName . '.load_balancer'; + $loadBalancerName = $clientName.'.load_balancer'; $container->setDefinition($loadBalancerName, $loadBalancerDefinition); $clientDefinition - ->addMethodCall('registerPlugin', array('loadbalancer', new Reference($loadBalancerName))) + ->addMethodCall('registerPlugin', ['loadbalancer', new Reference($loadBalancerName)]) ; } } @@ -194,7 +192,7 @@ private function configurePluginsForClient(array $clientOptions, Definition $cli } else { $plugin = new Reference($pluginOptions['plugin_service']); } - $clientDefinition->addMethodCall('registerPlugin', array($pluginName, $plugin)); + $clientDefinition->addMethodCall('registerPlugin', [$pluginName, $plugin]); } } } diff --git a/src/Logger.php b/src/Logger.php index 03b9283..07d9fea 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -3,12 +3,12 @@ namespace Nelmio\SolariumBundle; use Psr\Log\LoggerInterface; -use Solarium\Core\Client\Request as SolariumRequest; use Solarium\Core\Client\Endpoint as SolariumEndpoint; -use Solarium\Core\Plugin\AbstractPlugin as SolariumPlugin; +use Solarium\Core\Client\Request as SolariumRequest; use Solarium\Core\Event\Events as SolariumEvents; -use Solarium\Core\Event\PreExecuteRequest as SolariumPreExecuteRequestEvent; use Solarium\Core\Event\PostExecuteRequest as SolariumPostExecuteRequestEvent; +use Solarium\Core\Event\PreExecuteRequest as SolariumPreExecuteRequestEvent; +use Solarium\Core\Plugin\AbstractPlugin as SolariumPlugin; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request as HttpRequest; use Symfony\Component\HttpFoundation\Response as HttpResponse; @@ -17,18 +17,18 @@ class Logger extends SolariumPlugin implements DataCollectorInterface, \Serializable { - private $data = array(); - private $queries = array(); + private $data = []; + private $queries = []; private $currentRequest; private $currentStartTime; private $currentEndpoint; private $logger; private $stopwatch; - private $eventDispatchers = array(); + private $eventDispatchers = []; /** - * Plugin init function + * Plugin init function. * * Register event listeners */ @@ -37,8 +37,8 @@ protected function initPluginType() $dispatcher = $this->client->getEventDispatcher(); if (!in_array($dispatcher, $this->eventDispatchers, true)) { if ($dispatcher instanceof EventDispatcherInterface) { - $dispatcher->addListener(SolariumEvents::PRE_EXECUTE_REQUEST, array($this, 'preExecuteRequest'), 1000); - $dispatcher->addListener(SolariumEvents::POST_EXECUTE_REQUEST, array($this, 'postExecuteRequest'), -1000); + $dispatcher->addListener(SolariumEvents::PRE_EXECUTE_REQUEST, [$this, 'preExecuteRequest'], 1000); + $dispatcher->addListener(SolariumEvents::POST_EXECUTE_REQUEST, [$this, 'postExecuteRequest'], -1000); } $this->eventDispatchers[] = $dispatcher; } @@ -56,12 +56,12 @@ public function setStopwatch(Stopwatch $stopwatch) public function log(SolariumRequest $request, $response, SolariumEndpoint $endpoint, $duration) { - $this->queries[] = array( + $this->queries[] = [ 'request' => $request, 'response' => $response, 'duration' => $duration, 'base_uri' => $this->getEndpointBaseUrl($endpoint), - ); + ]; } public function collect(HttpRequest $request, HttpResponse $response, /** \Throwable */ $exception = null) @@ -74,10 +74,10 @@ public function collect(HttpRequest $request, HttpResponse $response, /** \Throw foreach ($this->queries as $queryStruct) { $time += $queryStruct['duration']; } - $this->data = array( - 'queries' => $this->queries, - 'total_time' => $time, - ); + $this->data = [ + 'queries' => $this->queries, + 'total_time' => $time, + ]; } public function getName(): string @@ -87,7 +87,7 @@ public function getName(): string public function getQueries() { - return array_key_exists('queries', $this->data) ? $this->data['queries'] : array(); + return array_key_exists('queries', $this->data) ? $this->data['queries'] : []; } public function getQueryCount() @@ -114,7 +114,7 @@ public function preExecuteRequest(SolariumPreExecuteRequestEvent $event) $this->currentEndpoint = $event->getEndpoint(); if (null !== $this->logger) { - $this->logger->debug($this->getEndpointBaseUrl($this->currentEndpoint) . $this->currentRequest->getUri()); + $this->logger->debug($this->getEndpointBaseUrl($this->currentEndpoint).$this->currentRequest->getUri()); } $this->currentStartTime = microtime(true); } @@ -170,8 +170,8 @@ public function unserialize($data) */ public function reset() { - $this->data = array(); - $this->queries = array(); + $this->data = []; + $this->queries = []; } public function __serialize(): array diff --git a/tests/NelmioSolariumExtensionTest.php b/tests/NelmioSolariumExtensionTest.php index 1bc230c..9436e12 100644 --- a/tests/NelmioSolariumExtensionTest.php +++ b/tests/NelmioSolariumExtensionTest.php @@ -32,11 +32,11 @@ class NelmioSolariumExtensionTest extends TestCase { public function testLoadEmptyConfiguration() { - $config = array( - 'clients' => array( - 'default' => array() - ) - ); + $config = [ + 'clients' => [ + 'default' => [], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -57,11 +57,11 @@ public function testLoadEmptyConfiguration() public function testNoClients() { - $config = array( - 'endpoints' => array( - 'default' => array() - ) - ); + $config = [ + 'endpoints' => [ + 'default' => [], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -82,13 +82,13 @@ public function testNoClients() public function testLoadCustomClient() { - $config = array( - 'clients' => array( - 'default' => array( - 'client_class' => StubClient::class - ) - ) - ); + $config = [ + 'clients' => [ + 'default' => [ + 'client_class' => StubClient::class, + ], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -98,15 +98,15 @@ public function testLoadCustomClient() public function testDefaultClient() { - $config = array( + $config = [ 'default_client' => 'client2', - 'clients' => array( - 'client1' => array(), - 'client2' => array( - 'client_class' => StubClient::class - ) - ), - ); + 'clients' => [ + 'client1' => [], + 'client2' => [ + 'client_class' => StubClient::class, + ], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -117,15 +117,15 @@ public function testDefaultClient() public function testPlugins() { - $config = array( - 'clients' => array( - 'client' => array( - 'plugins' => array('plugin1' => array('plugin_service' => 'my_plugin'), 'plugin2' => array('plugin_class' => MyPluginClass::class)) - ) - ), - ); + $config = [ + 'clients' => [ + 'client' => [ + 'plugins' => ['plugin1' => ['plugin_service' => 'my_plugin'], 'plugin2' => ['plugin_class' => MyPluginClass::class]], + ], + ], + ]; - $container = $this->createCompiledContainerForConfig($config, true, array('my_plugin' => new Definition(MyPluginClass::class))); + $container = $this->createCompiledContainerForConfig($config, true, ['my_plugin' => new Definition(MyPluginClass::class)]); $client = $container->get('solarium.client'); $plugin1 = $client->getPlugin('plugin1'); @@ -137,29 +137,29 @@ public function testPlugins() public function testEndpoints() { - $config = array( - 'endpoints' => array( - 'endpoint1' => array( + $config = [ + 'endpoints' => [ + 'endpoint1' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core1', - ), - 'endpoint2' => array( + ], + 'endpoint2' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core2', - ), - 'endpoint3' => array( + ], + 'endpoint3' => [ 'scheme' => 'https', 'host' => 'localhost', 'port' => 123, 'core' => 'core3', - ) - ), - 'clients' => array( - 'client1' => array() - ), - ); + ], + ], + 'clients' => [ + 'client1' => [], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -201,25 +201,25 @@ public function testEndpoints() public function testSpecificEndpoints() { - $config = array( - 'endpoints' => array( - 'endpoint1' => array( + $config = [ + 'endpoints' => [ + 'endpoint1' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core1', - ), - 'endpoint2' => array( + ], + 'endpoint2' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core2', - ) - ), - 'clients' => array( - 'client1' => array( - 'endpoints' => array('endpoint2'), - ) - ), - ); + ], + ], + 'clients' => [ + 'client1' => [ + 'endpoints' => ['endpoint2'], + ], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -238,26 +238,26 @@ public function testSpecificEndpoints() public function testDefaultEndpoint() { - $config = array( - 'endpoints' => array( - 'endpoint1' => array( + $config = [ + 'endpoints' => [ + 'endpoint1' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core1', - ), - 'endpoint2' => array( + ], + 'endpoint2' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core2', - 'path' =>'/custom_prefix', - ) - ), - 'clients' => array( - 'client1' => array( + 'path' => '/custom_prefix', + ], + ], + 'clients' => [ + 'client1' => [ 'default_endpoint' => 'endpoint2', - ) - ), - ); + ], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -295,33 +295,33 @@ public function testDefaultEndpoint() public function testClientRegistry() { - $config = array( - 'endpoints' => array( - 'endpoint1' => array( + $config = [ + 'endpoints' => [ + 'endpoint1' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core1', - ), - 'endpoint2' => array( + ], + 'endpoint2' => [ 'host' => 'localhost', 'port' => 123, 'core' => 'core2', - ) - ), - 'clients' => array( - 'client1' => array( - 'endpoints' => array('endpoint1'), - ), - 'client2' => array( - 'endpoints' => array('endpoint2'), - ) - ), - ); + ], + ], + 'clients' => [ + 'client1' => [ + 'endpoints' => ['endpoint1'], + ], + 'client2' => [ + 'endpoints' => ['endpoint2'], + ], + ], + ]; $container = $this->createCompiledContainerForConfig($config); $clientRegistry = $container->get('solarium.client_registry'); $this->assertInstanceOf(ClientRegistry::class, $clientRegistry); $this->assertInstanceOf(Client::class, $clientRegistry->getClient('client1')); - $this->assertEquals(array('client1', 'client2'), $clientRegistry->getClientNames()); + $this->assertEquals(['client1', 'client2'], $clientRegistry->getClientNames()); $this->expectException(\InvalidArgumentException::class); $this->assertNotNull($clientRegistry->getClient()); @@ -329,7 +329,7 @@ public function testClientRegistry() public function testLogger() { - $config = array(); + $config = []; $container = $this->createCompiledContainerForConfig($config, true); @@ -350,31 +350,31 @@ public function testLogger() public function testLoadBalancer() { - $config = array( - 'endpoints' => array( - 'master' => array( + $config = [ + 'endpoints' => [ + 'master' => [ 'host' => 'localhost', 'port' => 123, - ), - 'slave1' => array( + ], + 'slave1' => [ 'host' => 'localhost', 'port' => 124, - ), - 'slave2' => array( + ], + 'slave2' => [ 'host' => 'localhost', 'port' => 125, - ) - ), - 'clients' => array( - 'client1' => array( + ], + ], + 'clients' => [ + 'client1' => [ 'endpoints' => ['master'], - 'load_balancer' => array( - 'endpoints' => array('slave1', 'slave2' => 5), - 'blocked_query_types' => array('ping'), - ), - ) - ), - ); + 'load_balancer' => [ + 'endpoints' => ['slave1', 'slave2' => 5], + 'blocked_query_types' => ['ping'], + ], + ], + ], + ]; $container = $this->createCompiledContainerForConfig($config); @@ -397,10 +397,10 @@ public function testLoadBalancer() $loadBalancedEndpoints = $loadBalancerPlugin->getEndpoints(); $this->assertCount(2, $loadBalancedEndpoints); $this->assertEquals( - array( + [ 'slave1' => 1, 'slave2' => 5, - ), + ], $loadBalancedEndpoints ); } @@ -411,8 +411,8 @@ public function testAdapterTimeout(): void 'clients' => [ 'default' => [ 'adapter_timeout' => 10, - ] - ] + ], + ], ]; $container = $this->createCompiledContainerForConfig($config); @@ -426,8 +426,8 @@ public function testAdapterService(): void 'clients' => [ 'default' => [ 'adapter_service' => 'foo', - ] - ] + ], + ], ]; $container = $this->createCompiledContainerForConfig($config, false, ['foo' => new Definition(Http::class)]); @@ -442,15 +442,15 @@ public function testAdapterTimeoutAndServiceNotSupported(): void 'default' => [ 'adapter_timeout' => 10, 'adapter_service' => 'foo', - ] - ] + ], + ], ]; $this->expectExceptionMessage('Setting "adapter_timeout" is only supported for the default adapter and not in combination with "adapter_service"'); $this->createCompiledContainerForConfig($config); } - private function createCompiledContainerForConfig($config, $debug = false, $extraServices = array()) + private function createCompiledContainerForConfig($config, $debug = false, $extraServices = []) { $container = $this->createContainer($debug); $container->registerExtension(new FrameworkExtension()); @@ -467,21 +467,21 @@ private function createCompiledContainerForConfig($config, $debug = false, $extr private function createContainer($debug = false) { - return new ContainerBuilder(new ParameterBag(array( - 'kernel.cache_dir' => __DIR__, - 'kernel.charset' => 'UTF-8', - 'kernel.debug' => $debug, + return new ContainerBuilder(new ParameterBag([ + 'kernel.cache_dir' => __DIR__, + 'kernel.charset' => 'UTF-8', + 'kernel.debug' => $debug, 'kernel.container_class' => 'dummy', - 'kernel.project_dir' => __DIR__, - 'kernel.build_dir' => __DIR__, + 'kernel.project_dir' => __DIR__, + 'kernel.build_dir' => __DIR__, 'debug.file_link_format' => 'foo', - ))); + ])); } private function compileContainer(ContainerBuilder $container) { - $container->getCompilerPassConfig()->setOptimizationPasses(array()); - $container->getCompilerPassConfig()->setRemovingPasses(array()); + $container->getCompilerPassConfig()->setOptimizationPasses([]); + $container->getCompilerPassConfig()->setRemovingPasses([]); $container->compile(); } }