| @@ -55,9 +55,9 @@ | ||
| 55 | 55 | * sensitive data to what the scrubbed value should be. The value of any |
| 56 | 56 | * headers contained in this array will be replaced with the if |
| 57 | 57 | * "scrub_auth" is set to true. |
| 58 | 58 | */ |
| 59 | - public function __construct(array $config = [], Service $service = null) | |
| 59 | + public function __construct(array $config = [], ?Service $service = null) | |
| 60 | 60 | { |
| 61 | 61 | $this->config = $config + ['logfn' => function ($value) { |
| 62 | 62 | echo $value; |
| 63 | 63 | }, 'stream_size' => 524288, 'scrub_auth' => \true, 'http' => \true, 'auth_strings' => [], 'auth_headers' => []]; |
| @@ -68,9 +68,9 @@ | ||
| 68 | 68 | public function __invoke($step, $name) |
| 69 | 69 | { |
| 70 | 70 | $this->prevOutput = $this->prevInput = []; |
| 71 | 71 | return function (callable $next) use($step, $name) { |
| 72 | - return function (CommandInterface $command, RequestInterface $request = null) use($next, $step, $name) { | |
| 72 | + return function (CommandInterface $command, $request = null) use($next, $step, $name) { | |
| 73 | 73 | $this->createHttpDebug($command); |
| 74 | 74 | $start = \microtime(\true); |
| 75 | 75 | $this->stepInput(['step' => $step, 'name' => $name, 'request' => $this->requestArray($request), 'command' => $this->commandArray($command)]); |
| 76 | 76 | return $next($command, $request)->then(function ($value) use($step, $name, $command, $start) { |
| @@ -116,13 +116,13 @@ | ||
| 116 | 116 | private function commandArray(CommandInterface $cmd) |
| 117 | 117 | { |
| 118 | 118 | return ['instance' => \spl_object_hash($cmd), 'name' => $cmd->getName(), 'params' => $this->getRedactedArray($cmd)]; |
| 119 | 119 | } |
| 120 | - private function requestArray(RequestInterface $request = null) | |
| 120 | + private function requestArray($request = null) | |
| 121 | 121 | { |
| 122 | - return !$request ? [] : \array_filter(['instance' => \spl_object_hash($request), 'method' => $request->getMethod(), 'headers' => $this->redactHeaders($request->getHeaders()), 'body' => $this->streamStr($request->getBody()), 'scheme' => $request->getUri()->getScheme(), 'port' => $request->getUri()->getPort(), 'path' => $request->getUri()->getPath(), 'query' => $request->getUri()->getQuery()]); | |
| 122 | + return !$request instanceof RequestInterface ? [] : \array_filter(['instance' => \spl_object_hash($request), 'method' => $request->getMethod(), 'headers' => $this->redactHeaders($request->getHeaders()), 'body' => $this->streamStr($request->getBody()), 'scheme' => $request->getUri()->getScheme(), 'port' => $request->getUri()->getPort(), 'path' => $request->getUri()->getPath(), 'query' => $request->getUri()->getQuery()]); | |
| 123 | 123 | } |
| 124 | - private function responseArray(ResponseInterface $response = null) | |
| 124 | + private function responseArray(?ResponseInterface $response = null) | |
| 125 | 125 | { |
| 126 | 126 | return !$response ? [] : ['instance' => \spl_object_hash($response), 'statusCode' => $response->getStatusCode(), 'headers' => $this->redactHeaders($response->getHeaders()), 'body' => $this->streamStr($response->getBody())]; |
| 127 | 127 | } |
| 128 | 128 | private function resultArray($value) |