Skip to content

Apply fixes from StyleCI #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Collector/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getName()
*/
public function activateStack(Stack $stack)
{
if ($this->activeStack !== null) {
if (null !== $this->activeStack) {
$stack->setParent($this->activeStack);
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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();
});
}

Expand Down
4 changes: 2 additions & 2 deletions Collector/ProfileClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion Collector/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getParent()
/**
* @param Stack $parent
*/
public function setParent(Stack $parent)
public function setParent(self $parent)
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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']));
Expand Down Expand Up @@ -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');

Expand All @@ -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');

Expand Down
4 changes: 2 additions & 2 deletions Discovery/ConfiguredClientsStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}]];
Expand Down