From 3ba420a8583332a951199b8fa36674b5e748faff Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 14:26:41 +0100 Subject: [PATCH 1/2] Complete removal of debug_plugins --- spec/PluginClientSpec.php | 43 --------------------------------------- src/PluginClient.php | 13 +----------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/spec/PluginClientSpec.php b/spec/PluginClientSpec.php index addb2e8..88406ae 100644 --- a/spec/PluginClientSpec.php +++ b/spec/PluginClientSpec.php @@ -87,47 +87,4 @@ function it_throws_loop_exception(HttpClient $httpClient, RequestInterface $requ $this->shouldThrow('Http\Client\Common\Exception\LoopException')->duringSendRequest($request); } - - function it_injects_debug_plugins(HttpClient $httpClient, ResponseInterface $response, RequestInterface $request, Plugin $plugin0, Plugin $plugin1, Plugin $debugPlugin) - { - $plugin0 - ->handleRequest( - $request, - Argument::type('callable'), - Argument::type('callable') - ) - ->shouldBeCalledTimes(1) - ->will(function ($args) { - return $args[1]($args[0]); - }) - ; - $plugin1 - ->handleRequest( - $request, - Argument::type('callable'), - Argument::type('callable') - ) - ->shouldBeCalledTimes(1) - ->will(function ($args) { - return $args[1]($args[0]); - }) - ; - - $debugPlugin - ->handleRequest( - $request, - Argument::type('callable'), - Argument::type('callable') - ) - ->shouldBeCalledTimes(3) - ->will(function ($args) { - return $args[1]($args[0]); - }) - ; - - $httpClient->sendRequest($request)->willReturn($response); - - $this->beConstructedWith($httpClient, [$plugin0, $plugin1], ['debug_plugins'=>[$debugPlugin]]); - $this->sendRequest($request); - } } diff --git a/src/PluginClient.php b/src/PluginClient.php index 70419e3..5cc0737 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -44,9 +44,7 @@ final class PluginClient implements HttpClient, HttpAsyncClient * @param HttpClient|HttpAsyncClient $client * @param Plugin[] $plugins * @param array $options { - * * @var int $max_restarts - * @var Plugin[] $debug_plugins an array of plugins that are injected between each normal plugin * } * * @throws \RuntimeException if client is not an instance of HttpClient or HttpAsyncClient @@ -131,16 +129,7 @@ private function createPluginChain($pluginList, callable $clientCallable) { $firstCallable = $lastCallable = $clientCallable; - /* - * Inject debug plugins between each plugin. - */ - $pluginListWithDebug = $this->options['debug_plugins']; - foreach ($pluginList as $plugin) { - $pluginListWithDebug[] = $plugin; - $pluginListWithDebug = array_merge($pluginListWithDebug, $this->options['debug_plugins']); - } - - while ($plugin = array_pop($pluginListWithDebug)) { + while ($plugin = array_pop($pluginList)) { $lastCallable = function (RequestInterface $request) use ($plugin, $lastCallable, &$firstCallable) { return $plugin->handleRequest($request, $lastCallable, $firstCallable); }; From a59d62f882ca43886ff9249276eab803983baa10 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 14:29:36 +0100 Subject: [PATCH 2/2] Fix CS --- src/PluginClient.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PluginClient.php b/src/PluginClient.php index 5cc0737..c3a5641 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -44,6 +44,7 @@ final class PluginClient implements HttpClient, HttpAsyncClient * @param HttpClient|HttpAsyncClient $client * @param Plugin[] $plugins * @param array $options { + * * @var int $max_restarts * } *