From b3156b107cd67380d6bb46a4afc9458cb088de44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 30 Jun 2018 15:47:08 +0100 Subject: [PATCH] Added php function calls namespace prefixing --- .../Compiler/PluginsPass.php | 6 +-- .../Compiler/RoutePass.php | 30 ++++++------ src/DependencyInjection/Configuration.php | 32 ++++++------- .../ProophServiceBusExtension.php | 46 +++++++++---------- src/Exception/CompilerPassException.php | 6 +-- .../DefaultMessageDataConverter.php | 2 +- src/Plugin/DataCollector.php | 10 ++-- src/Plugin/DataCollectorPlugin.php | 6 +-- src/Plugin/PsrLoggerPlugin.php | 4 +- src/Plugin/StopwatchPlugin.php | 4 +- .../AbstractServiceBusExtensionTestCase.php | 6 +-- test/DependencyInjection/ContainerBuilder.php | 20 ++++---- 12 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/DependencyInjection/Compiler/PluginsPass.php b/src/DependencyInjection/Compiler/PluginsPass.php index f98e4b7..53d021a 100644 --- a/src/DependencyInjection/Compiler/PluginsPass.php +++ b/src/DependencyInjection/Compiler/PluginsPass.php @@ -29,10 +29,10 @@ public function process(ContainerBuilder $container) foreach ($buses as $name => $bus) { $globalPlugins = $container->findTaggedServiceIds('prooph_service_bus.plugin'); - $typePlugins = $container->findTaggedServiceIds(sprintf('prooph_service_bus.%s.plugin', $type . '_bus')); - $localPlugins = $container->findTaggedServiceIds(sprintf('prooph_service_bus.%s.plugin', $name)); + $typePlugins = $container->findTaggedServiceIds(\sprintf('prooph_service_bus.%s.plugin', $type . '_bus')); + $localPlugins = $container->findTaggedServiceIds(\sprintf('prooph_service_bus.%s.plugin', $name)); - $plugins = array_merge(array_keys($globalPlugins), array_keys($typePlugins), array_keys($localPlugins)); + $plugins = \array_merge(\array_keys($globalPlugins), \array_keys($typePlugins), \array_keys($localPlugins)); $busDefinition = $container->getDefinition($bus); diff --git a/src/DependencyInjection/Compiler/RoutePass.php b/src/DependencyInjection/Compiler/RoutePass.php index 2143fe9..68eca87 100644 --- a/src/DependencyInjection/Compiler/RoutePass.php +++ b/src/DependencyInjection/Compiler/RoutePass.php @@ -38,22 +38,22 @@ public function process(ContainerBuilder $container) $buses = $container->getParameter('prooph_service_bus.' . $type . '_buses'); foreach ($buses as $name => $bus) { - $routerServiceId = sprintf('prooph_service_bus.%s.decorated_router', $name); + $routerServiceId = \sprintf('prooph_service_bus.%s.decorated_router', $name); if (! $container->has($routerServiceId)) { - $routerServiceId = sprintf('prooph_service_bus.%s.router', $name); + $routerServiceId = \sprintf('prooph_service_bus.%s.router', $name); } $router = $container->findDefinition($routerServiceId); $routerArguments = $router->getArguments(); - $serviceLocator = $container->findDefinition(sprintf('%s.plugin.service_locator.locator', $name)); + $serviceLocator = $container->findDefinition(\sprintf('%s.plugin.service_locator.locator', $name)); $serviceLocatorServices = $serviceLocator->getArgument(0); - $handlers = $container->findTaggedServiceIds(sprintf('prooph_service_bus.%s.route_target', $name)); + $handlers = $container->findTaggedServiceIds(\sprintf('prooph_service_bus.%s.route_target', $name)); foreach ($handlers as $id => $args) { $serviceLocatorServices[$id] = new Reference($id); // Safeguard to have only one tag per command / query - if ($type !== 'event' && count($args) > 1) { + if ($type !== 'event' && \count($args) > 1) { throw CompilerPassException::tagCountExceeded($type, $id, $bus); } foreach ($args as $eachArgs) { @@ -66,15 +66,15 @@ public function process(ContainerBuilder $container) : $this->recognizeMessageNames($container, $container->getDefinition($id), $id, $type); if ($type === 'event') { - $routerArguments[0] = array_merge_recursive( + $routerArguments[0] = \array_merge_recursive( $routerArguments[0], - array_combine($messageNames, array_fill(0, count($messageNames), [$id])) + \array_combine($messageNames, \array_fill(0, \count($messageNames), [$id])) ); - $routerArguments[0] = array_map('array_unique', $routerArguments[0]); + $routerArguments[0] = \array_map('array_unique', $routerArguments[0]); } else { - $routerArguments[0] = array_merge( + $routerArguments[0] = \array_merge( $routerArguments[0], - array_combine($messageNames, array_fill(0, count($messageNames), $id)) + \array_combine($messageNames, \array_fill(0, \count($messageNames), $id)) ); } } @@ -83,10 +83,10 @@ public function process(ContainerBuilder $container) $serviceLocator->setArgument(0, $serviceLocatorServices); // Update route configuration parameter - $configId = sprintf('prooph_service_bus.%s.configuration', $name); + $configId = \sprintf('prooph_service_bus.%s.configuration', $name); - $routes = is_array($routerArguments[0]) ? $routerArguments[0] : []; - $config = array_replace($container->getParameter($configId), ['router' => ['routes' => $routes]]); + $routes = \is_array($routerArguments[0]) ? $routerArguments[0] : []; + $config = \array_replace($container->getParameter($configId), ['router' => ['routes' => $routes]]); $container->setParameter($configId, $config); } @@ -106,7 +106,7 @@ private function recognizeMessageNames( throw CompilerPassException::unknownHandlerClass($routeClass, $routeId, $busType); } - $methodsWithMessageParameter = array_filter( + $methodsWithMessageParameter = \array_filter( $handlerReflection->getMethods(ReflectionMethod::IS_PUBLIC), function (ReflectionMethod $method) { return ($method->getNumberOfRequiredParameters() === 1 || $method->getNumberOfRequiredParameters() === 2) @@ -118,7 +118,7 @@ function (ReflectionMethod $method) { } ); - return array_unique(array_map(function (ReflectionMethod $method) { + return \array_unique(\array_map(function (ReflectionMethod $method) { return self::detectMessageName($method->getParameters()[0]->getClass()); }, $methodsWithMessageParameter)); } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index aca74b2..1df2bdd 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -66,10 +66,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->prototype('scalar') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->end(); @@ -77,10 +77,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): $handlerNode ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end(); } @@ -98,10 +98,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->scalarNode('message_factory') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->defaultValue('prooph_service_bus.message_factory') @@ -109,10 +109,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->scalarNode('message_data_converter') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->defaultValue('prooph_service_bus.message_data_converter.' . $type) @@ -120,10 +120,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->scalarNode('message_converter') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->defaultValue('prooph_service_bus.message_converter') @@ -138,10 +138,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->prototype('scalar') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->end() @@ -153,10 +153,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->scalarNode('type') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->defaultValue('prooph_service_bus.' . $type . '_bus_router') @@ -164,10 +164,10 @@ private function addServiceBusSection(string $type, ArrayNodeDefinition $node): ->scalarNode('async_switch') ->beforeNormalization() ->ifTrue(function ($v) { - return strpos($v, '@') === 0; + return \strpos($v, '@') === 0; }) ->then(function ($v) { - return substr($v, 1); + return \substr($v, 1); }) ->end() ->end() diff --git a/src/DependencyInjection/ProophServiceBusExtension.php b/src/DependencyInjection/ProophServiceBusExtension.php index ef972be..ca4d36e 100644 --- a/src/DependencyInjection/ProophServiceBusExtension.php +++ b/src/DependencyInjection/ProophServiceBusExtension.php @@ -76,21 +76,21 @@ private function busLoad( $loader->load($type . '_bus.xml'); $serviceBuses = []; - foreach (array_keys($config) as $name) { + foreach (\array_keys($config) as $name) { $serviceBuses[$name] = 'prooph_service_bus.' . $name; } $container->setParameter("prooph_service_bus.{$type}_buses", $serviceBuses); // Add DataCollector - if ($type !== 'query' && $container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) { + if ($type !== 'query' && $container->getParameter('kernel.debug') && \class_exists(Stopwatch::class)) { $container ->setDefinition( - sprintf('prooph_service_bus.plugin.symfony_data_collector.%s_bus', $type), + \sprintf('prooph_service_bus.plugin.symfony_data_collector.%s_bus', $type), new ChildDefinition('prooph_service_bus.plugin.symfony_data_collector') ) ->addArgument($type) ->addTag('data_collector', [ - 'id' => sprintf('prooph.%s_bus', $type), + 'id' => \sprintf('prooph.%s_bus', $type), 'template' => '@ProophServiceBus/Collector/debug_view.html.twig', ]); } @@ -120,7 +120,7 @@ private function loadBus(string $type, string $name, array $options, ContainerBu new ChildDefinition('prooph_service_bus.' . $type . '_bus') ); $serviceBusDefinition->setPublic(true); - if (in_array(NamedMessageBus::class, class_implements($container->getDefinition('prooph_service_bus.'.$type.'_bus')->getClass()))) { + if (\in_array(NamedMessageBus::class, \class_implements($container->getDefinition('prooph_service_bus.'.$type.'_bus')->getClass()))) { $serviceBusDefinition->addMethodCall('setBusName', [$name]); $serviceBusDefinition->addMethodCall('setBusType', [$type]); } @@ -138,35 +138,35 @@ private function loadBus(string $type, string $name, array $options, ContainerBu ) ->addArgument(new Reference($options['message_converter'])); - $contextFactoryId = sprintf('prooph_service_bus.message_context_factory.%s', $serviceBusId); + $contextFactoryId = \sprintf('prooph_service_bus.message_context_factory.%s', $serviceBusId); $container ->setDefinition($contextFactoryId, new ChildDefinition('prooph_service_bus.message_context_factory')) ->addArgument(new Reference($options['message_data_converter'])); // Collecting data for each configured service bus - if ($type !== 'query' && $container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) { + if ($type !== 'query' && $container->getParameter('kernel.debug') && \class_exists(Stopwatch::class)) { $container ->setDefinition( - sprintf('%s.plugin.data_collector', $serviceBusId), + \sprintf('%s.plugin.data_collector', $serviceBusId), new ChildDefinition('prooph_service_bus.plugin.data_collector') ) ->addArgument(new Reference($contextFactoryId)) - ->addArgument(new Reference(sprintf('prooph_service_bus.plugin.symfony_data_collector.%s_bus', $type))) + ->addArgument(new Reference(\sprintf('prooph_service_bus.plugin.symfony_data_collector.%s_bus', $type))) ->addTag("prooph_service_bus.{$type}_bus.plugin"); } // Logging for each configured service bus $container ->setDefinition( - sprintf('%s.plugin.psr_logger', $serviceBusId), + \sprintf('%s.plugin.psr_logger', $serviceBusId), new ChildDefinition('prooph_service_bus.plugin.psr_logger') ) ->setArguments([ new Reference($contextFactoryId), new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), ]) - ->addTag('monolog.logger', ['channel' => sprintf('%s_bus.%s', $type, $name)]) - ->addTag(sprintf('prooph_service_bus.%s.plugin', $name)); + ->addTag('monolog.logger', ['channel' => \sprintf('%s_bus.%s', $type, $name)]) + ->addTag(\sprintf('prooph_service_bus.%s.plugin', $name)); // define message factory $messageFactoryId = 'prooph_service_bus.message_factory.' . $name; @@ -176,7 +176,7 @@ private function loadBus(string $type, string $name, array $options, ContainerBu $messageFactoryPluginId = 'prooph_service_bus.message_factory_plugin.' . $name; $messageFactoryPluginDefinition = new ChildDefinition('prooph_service_bus.message_factory_plugin'); $messageFactoryPluginDefinition->setArguments([new Reference($messageFactoryId)]); - $messageFactoryPluginDefinition->addTag(sprintf('prooph_service_bus.%s.plugin', $name)); + $messageFactoryPluginDefinition->addTag(\sprintf('prooph_service_bus.%s.plugin', $name)); $container->setDefinition($messageFactoryPluginId, $messageFactoryPluginDefinition); @@ -198,30 +198,30 @@ private function loadBus(string $type, string $name, array $options, ContainerBu new Reference($options['router']['async_switch']), ]); } - $routerDefinition->addTag(sprintf('prooph_service_bus.%s.plugin', $name)); + $routerDefinition->addTag(\sprintf('prooph_service_bus.%s.plugin', $name)); $container->setDefinition($routerId, $routerDefinition); } // define service locator - $routeTargets = array_values($options['router']['routes'] ?? []); + $routeTargets = \array_values($options['router']['routes'] ?? []); if ($type === 'event') { - $routeTargets = array_merge([], ...$routeTargets); + $routeTargets = \array_merge([], ...$routeTargets); } - $routeTargets = array_unique($routeTargets); - $serviceLocatorId = sprintf('%s.plugin.service_locator.locator', $name); + $routeTargets = \array_unique($routeTargets); + $serviceLocatorId = \sprintf('%s.plugin.service_locator.locator', $name); $serviceLocator = $container->register($serviceLocatorId, ServiceLocator::class); $serviceLocator->addTag('container.service_locator'); - $serviceLocator->setArgument(0, array_map(function (string $id) { + $serviceLocator->setArgument(0, \array_map(function (string $id) { return new Reference($id); - }, array_combine($routeTargets, $routeTargets))); + }, \array_combine($routeTargets, $routeTargets))); // and the plugin for it $serviceLocatorPlugin = new ChildDefinition('prooph_service_bus.plugin.service_locator'); $serviceLocatorPlugin->setArgument(0, new Reference($serviceLocatorId)); - $serviceLocatorPlugin->addTag(sprintf('prooph_service_bus.%s.plugin', $name)); - $container->setDefinition(sprintf('%s.plugin.service_locator', $name), $serviceLocatorPlugin); + $serviceLocatorPlugin->addTag(\sprintf('prooph_service_bus.%s.plugin', $name)); + $container->setDefinition(\sprintf('%s.plugin.service_locator', $name), $serviceLocatorPlugin); - $container->setParameter(sprintf('prooph_service_bus.%s.configuration', $name), $options); + $container->setParameter(\sprintf('prooph_service_bus.%s.configuration', $name), $options); } } diff --git a/src/Exception/CompilerPassException.php b/src/Exception/CompilerPassException.php index 1a096a6..21392fb 100644 --- a/src/Exception/CompilerPassException.php +++ b/src/Exception/CompilerPassException.php @@ -8,7 +8,7 @@ class CompilerPassException extends RuntimeException { public static function messageTagMissing(string $serviceId): self { - return new self(sprintf( + return new self(\sprintf( 'The "message" tag key is missing from tag. ' . 'Either provide a "message" tag or enable "message_detection" for service "%s"', $serviceId @@ -17,7 +17,7 @@ public static function messageTagMissing(string $serviceId): self public static function tagCountExceeded(string $type, string $serviceId, string $busName): self { - return new self(sprintf( + return new self(\sprintf( 'More than 1 %s handler tagged on service "%s" with tag "%s". Only events can have multiple handlers', $type, $serviceId, @@ -27,7 +27,7 @@ public static function tagCountExceeded(string $type, string $serviceId, string public static function unknownHandlerClass(string $className, string $serviceId, string $busName): self { - return new self(sprintf( + return new self(\sprintf( 'Service %s has been tagged as %s handler, but its class %s does not exist', $serviceId, $busName, diff --git a/src/MessageContext/DefaultMessageDataConverter.php b/src/MessageContext/DefaultMessageDataConverter.php index 440b62a..70fa633 100644 --- a/src/MessageContext/DefaultMessageDataConverter.php +++ b/src/MessageContext/DefaultMessageDataConverter.php @@ -29,7 +29,7 @@ public function convertMessageToArray($message): array } } - if (is_array($message)) { + if (\is_array($message)) { return $message; } diff --git a/src/Plugin/DataCollector.php b/src/Plugin/DataCollector.php index 375427e..3c4b267 100644 --- a/src/Plugin/DataCollector.php +++ b/src/Plugin/DataCollector.php @@ -31,7 +31,7 @@ public function collect(Request $request, Response $response, Exception $excepti { foreach ($this->busNames as $busName) { $this->data['config'][$busName] = $this->container->getParameter( - sprintf('prooph_service_bus.%s.configuration', $busName) + \sprintf('prooph_service_bus.%s.configuration', $busName) ); } } @@ -46,12 +46,12 @@ public function reset(): void public function totalMessageCount(): int { - return array_sum(array_map('count', $this->data['messages'])); + return \array_sum(\array_map('count', $this->data['messages'])); } public function totalBusCount(): int { - return count($this->data['messages']); + return \count($this->data['messages']); } public function messages(): array @@ -76,7 +76,7 @@ public function config(string $busName): array public function totalBusDuration(): int { - return array_sum($this->data['duration']); + return \array_sum($this->data['duration']); } public function busType(): string @@ -86,7 +86,7 @@ public function busType(): string public function getName(): string { - return sprintf('prooph.%s_bus', $this->data['bus_type']); + return \sprintf('prooph.%s_bus', $this->data['bus_type']); } public function addMessageBus(string $busName): void diff --git a/src/Plugin/DataCollectorPlugin.php b/src/Plugin/DataCollectorPlugin.php index 2cede75..0688396 100644 --- a/src/Plugin/DataCollectorPlugin.php +++ b/src/Plugin/DataCollectorPlugin.php @@ -45,9 +45,9 @@ public function attachToMessageBus(MessageBus $messageBus): void } if (! $messageBus instanceof NamedMessageBus) { - throw new RuntimeException(sprintf( + throw new RuntimeException(\sprintf( 'To use the Symfony DataCollector, the Bus "%s" needs to implement "%s"', - get_class($messageBus), + \get_class($messageBus), NamedMessageBus::class )); } @@ -100,7 +100,7 @@ public function attachToMessageBus(MessageBus $messageBus): void $log = [ 'id' => (string) $message->uuid(), 'message' => $messageName, - 'handler' => is_object($handler) ? get_class($handler) : (string) $handler, + 'handler' => \is_object($handler) ? \get_class($handler) : (string) $handler, ]; foreach ($actionEvent->getParam('event-listeners', []) as $handler) { $this->data->addCallstack($messageBus->busName(), $log); diff --git a/src/Plugin/PsrLoggerPlugin.php b/src/Plugin/PsrLoggerPlugin.php index 0f4ced2..482f797 100644 --- a/src/Plugin/PsrLoggerPlugin.php +++ b/src/Plugin/PsrLoggerPlugin.php @@ -36,8 +36,8 @@ public function attachToMessageBus(MessageBus $messageBus): void $message = 'Dispatching {bus-type} "{message-name}"'; if ($context['message-handler'] !== null) { $message .= ' to handler "{message-handler}"'; - } else if (count($context['event-listeners']) > 0) { - $context['event-listeners'] = implode(', ', $context['event-listeners']); + } elseif (\count($context['event-listeners']) > 0) { + $context['event-listeners'] = \implode(', ', $context['event-listeners']); $message .= ' to listeners "{event-listeners}"'; } $this->logger->info($message, $context); diff --git a/src/Plugin/StopwatchPlugin.php b/src/Plugin/StopwatchPlugin.php index 532b01c..b0a4dd5 100644 --- a/src/Plugin/StopwatchPlugin.php +++ b/src/Plugin/StopwatchPlugin.php @@ -35,7 +35,7 @@ public function attachToMessageBus(MessageBus $messageBus): void $message = $event->getParam(MessageBus::EVENT_PARAM_MESSAGE); $messageBus = $event->getTarget(); if ($messageBus instanceof NamedMessageBus) { - return sprintf( + return \sprintf( '%s:%s:%s', $message->messageType(), $messageBus->busName(), @@ -43,7 +43,7 @@ public function attachToMessageBus(MessageBus $messageBus): void ); } - return sprintf( + return \sprintf( '%s:%s', $message->messageType(), $event->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME) diff --git a/test/DependencyInjection/AbstractServiceBusExtensionTestCase.php b/test/DependencyInjection/AbstractServiceBusExtensionTestCase.php index 7278969..0b7329c 100644 --- a/test/DependencyInjection/AbstractServiceBusExtensionTestCase.php +++ b/test/DependencyInjection/AbstractServiceBusExtensionTestCase.php @@ -496,7 +496,7 @@ private function dump(string $configFile) } else { $dumper = new YamlDumper($container); } - self::assertInstanceOf(Dumper::class, $dumper, sprintf('Test type "%s" not supported', get_class($this))); + self::assertInstanceOf(Dumper::class, $dumper, \sprintf('Test type "%s" not supported', \get_class($this))); self::assertNotEmpty($dumper->dump()); self::assertNotEmpty((new PhpDumper($container))->dump(), 'PHP cache cannot be warmuped correctly.'); @@ -504,7 +504,7 @@ private function dump(string $configFile) private static function assertHasPlugin(string $className, CommandBus $bus) { - $plugins = array_filter(array_column($bus->plugins(), 'plugin'), function (Plugin $plugin) use ($className) { + $plugins = \array_filter(\array_column($bus->plugins(), 'plugin'), function (Plugin $plugin) use ($className) { return $plugin instanceof $className; }); self::assertCount(1, $plugins, "No plugin of class $className has been attached"); @@ -512,7 +512,7 @@ private static function assertHasPlugin(string $className, CommandBus $bus) private static function assertNotHasPlugin(string $className, CommandBus $bus) { - $plugins = array_filter(array_column($bus->plugins(), 'plugin'), function (Plugin $plugin) use ($className) { + $plugins = \array_filter(\array_column($bus->plugins(), 'plugin'), function (Plugin $plugin) use ($className) { return $plugin instanceof $className; }); self::assertCount(0, $plugins, "A plugin of class $className has been attached"); diff --git a/test/DependencyInjection/ContainerBuilder.php b/test/DependencyInjection/ContainerBuilder.php index 2397f23..3371a85 100644 --- a/test/DependencyInjection/ContainerBuilder.php +++ b/test/DependencyInjection/ContainerBuilder.php @@ -52,7 +52,7 @@ private function __construct(callable $fileLoaderFactory, string $fileExtension) $this->parameters = [ 'kernel.debug' => false, 'kernel.bundles' => [], - 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.cache_dir' => \sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.root_dir' => __DIR__ . '/../../src', ]; @@ -60,28 +60,28 @@ private function __construct(callable $fileLoaderFactory, string $fileExtension) public function withParameters(array $parameters): self { - $this->parameters = array_merge($this->parameters, $parameters); + $this->parameters = \array_merge($this->parameters, $parameters); return $this; } public function withExtensions(ExtensionInterface ...$extensions): self { - $this->extensions = array_merge($this->extensions, $extensions); + $this->extensions = \array_merge($this->extensions, $extensions); return $this; } public function withCompilerPasses(CompilerPassInterface ...$compilerPasses): self { - $this->compilerPasses = array_merge($this->compilerPasses, $compilerPasses); + $this->compilerPasses = \array_merge($this->compilerPasses, $compilerPasses); return $this; } public function withConfigFiles(string ...$fileNames): self { - $this->configFiles = array_merge($this->configFiles, $fileNames); + $this->configFiles = \array_merge($this->configFiles, $fileNames); return $this; } @@ -89,17 +89,17 @@ public function withConfigFiles(string ...$fileNames): self public function compile(): SymfonyContainerBuilder { $container = new SymfonyContainerBuilder(new ParameterBag($this->parameters)); - array_walk($this->extensions, [$container, 'registerExtension']); + \array_walk($this->extensions, [$container, 'registerExtension']); - $fileLoader = call_user_func($this->fileLoaderFactory, $container); - array_walk($this->configFiles, function (string $fileName) use ($fileLoader) { + $fileLoader = \call_user_func($this->fileLoaderFactory, $container); + \array_walk($this->configFiles, function (string $fileName) use ($fileLoader) { $fileLoader->load("$fileName.{$this->fileExtension}"); }); // array_walk is impossible here because the key will be passed as second parameter - array_map([$container, 'addCompilerPass'], $this->compilerPasses); + \array_map([$container, 'addCompilerPass'], $this->compilerPasses); - if (class_exists(ResolveChildDefinitionsPass::class)) { + if (\class_exists(ResolveChildDefinitionsPass::class)) { $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveChildDefinitionsPass()]); } else { $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveDefinitionTemplatesPass()]);