diff --git a/Collector/Collector.php b/Collector/Collector.php index 1a02d9c3..6258c1c0 100644 --- a/Collector/Collector.php +++ b/Collector/Collector.php @@ -62,7 +62,7 @@ public function getName() */ public function activateStack(Stack $stack) { - if ($this->activeStack !== null) { + if (null !== $this->activeStack) { $stack->setParent($this->activeStack); } @@ -141,7 +141,7 @@ public function getFailedStacks() public function getClients() { $stacks = array_filter($this->data['stacks'], function (Stack $stack) { - return $stack->getParent() === null; + return null === $stack->getParent(); }); return array_unique(array_map(function (Stack $stack) { @@ -157,7 +157,7 @@ public function getClients() public function getClientRootStacks($client) { return array_filter($this->data['stacks'], function (Stack $stack) use ($client) { - return $stack->getClient() == $client && $stack->getParent() == null; + return $stack->getClient() == $client && null == $stack->getParent(); }); } diff --git a/Collector/ProfileClient.php b/Collector/ProfileClient.php index 5e92244d..2cb35930 100644 --- a/Collector/ProfileClient.php +++ b/Collector/ProfileClient.php @@ -77,7 +77,7 @@ public function sendAsyncRequest(RequestInterface $request) { $activateStack = true; $stack = $this->collector->getActiveStack(); - if ($stack === null) { + if (null === $stack) { //When using a discovered client not wrapped in a PluginClient, we don't have a stack from StackPlugin. So //we create our own stack and activate it! $stack = new Stack('Default', $this->formatter->formatRequest($request)); @@ -120,7 +120,7 @@ public function sendAsyncRequest(RequestInterface $request) public function sendRequest(RequestInterface $request) { $stack = $this->collector->getActiveStack(); - if ($stack === null) { + if (null === $stack) { //When using a discovered client not wrapped in a PluginClient, we don't have a stack from StackPlugin. So //we create our own stack but don't activate it. $stack = new Stack('Default', $this->formatter->formatRequest($request)); diff --git a/Collector/Stack.php b/Collector/Stack.php index a5d467ce..815b1239 100644 --- a/Collector/Stack.php +++ b/Collector/Stack.php @@ -120,7 +120,7 @@ public function getParent() /** * @param Stack $parent */ - public function setParent(Stack $parent) + public function setParent(self $parent) { $this->parent = $parent; } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 107e8c42..227df718 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -175,7 +175,7 @@ private function configureClients(ArrayNodeDefinition $root) ->end() ->validate() ->ifTrue(function ($config) { - return $config['factory'] === 'httplug.factory.auto' && !empty($config['config']); + return 'httplug.factory.auto' === $config['factory'] && !empty($config['config']); }) ->thenInvalid('If you want to use the "config" key you must also specify a valid "factory".') ->end() diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php index 1abaa70a..e8afe492 100644 --- a/DependencyInjection/HttplugExtension.php +++ b/DependencyInjection/HttplugExtension.php @@ -89,7 +89,7 @@ private function configureClients(ContainerBuilder $container, array $config) $clients = []; foreach ($config['clients'] as $name => $arguments) { - if ($first === null) { + if (null === $first) { // Save the name of the first configured client. $first = $name; } @@ -99,7 +99,7 @@ private function configureClients(ContainerBuilder $container, array $config) } // If we have clients configured - if ($first !== null) { + if (null !== $first) { // If we do not have a client named 'default' if (!isset($config['clients']['default'])) { // Alias the first client to httplug.client.default @@ -153,6 +153,7 @@ private function configurePluginByName($name, Definition $definition, array $con ->replaceArgument(0, new Reference($config['cache_pool'])) ->replaceArgument(1, new Reference($config['stream_factory'])) ->replaceArgument(2, $options); + break; case 'cookie': $definition->replaceArgument(0, new Reference($config['cookie_jar'])); @@ -369,7 +370,7 @@ private function createUri(ContainerBuilder $container, $serviceId, $uri) private function configureAutoDiscoveryClients(ContainerBuilder $container, array $config) { $httpClient = $config['discovery']['client']; - if ($httpClient !== 'auto') { + if ('auto' !== $httpClient) { $container->removeDefinition('httplug.auto_discovery.auto_discovered_client'); $container->removeDefinition('httplug.collector.auto_discovered_client'); @@ -380,7 +381,7 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra } $asyncHttpClient = $config['discovery']['async_client']; - if ($asyncHttpClient !== 'auto') { + if ('auto' !== $asyncHttpClient) { $container->removeDefinition('httplug.auto_discovery.auto_discovered_async'); $container->removeDefinition('httplug.collector.auto_discovered_async'); diff --git a/Discovery/ConfiguredClientsStrategy.php b/Discovery/ConfiguredClientsStrategy.php index 75f76007..cec82c4b 100644 --- a/Discovery/ConfiguredClientsStrategy.php +++ b/Discovery/ConfiguredClientsStrategy.php @@ -43,13 +43,13 @@ public function __construct(HttpClient $httpClient = null, HttpAsyncClient $asyn */ public static function getCandidates($type) { - if ($type === HttpClient::class && self::$client !== null) { + if (HttpClient::class === $type && null !== self::$client) { return [['class' => function () { return self::$client; }]]; } - if ($type === HttpAsyncClient::class && self::$asyncClient !== null) { + if (HttpAsyncClient::class === $type && null !== self::$asyncClient) { return [['class' => function () { return self::$asyncClient; }]];