1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Yiisoft\Yii\Debug\Collector; |
||||
6 | |||||
7 | use Psr\Http\Client\ClientInterface; |
||||
8 | use Psr\Http\Message\RequestInterface; |
||||
9 | use Psr\Http\Message\ResponseInterface; |
||||
10 | |||||
11 | final class HttpClientInterfaceProxy implements ClientInterface |
||||
12 | { |
||||
13 | public function __construct(private ClientInterface $decorated, private HttpClientCollector $collector) |
||||
14 | { |
||||
15 | } |
||||
16 | |||||
17 | public function sendRequest(RequestInterface $request): ResponseInterface |
||||
18 | { |
||||
19 | /** @psalm-var array{file: string, line: int} $callStack */ |
||||
20 | $callStack = debug_backtrace()[0]; |
||||
21 | |||||
22 | $uniqueId = random_bytes(36); |
||||
23 | $startTime = microtime(true); |
||||
24 | $this->collector->collect($request, $startTime, $callStack['file'] . ':' . $callStack['line'], $uniqueId); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
25 | |||||
26 | $response = null; |
||||
0 ignored issues
–
show
|
|||||
27 | try { |
||||
28 | $response = $this->decorated->sendRequest($request); |
||||
29 | } finally { |
||||
30 | $endTime = microtime(true); |
||||
31 | $this->collector->collectTotalTime($response, $endTime, $uniqueId); |
||||
0 ignored issues
–
show
It seems like
$endTime can also be of type string ; however, parameter $endTime of Yiisoft\Yii\Debug\Collec...tor::collectTotalTime() does only seem to accept double , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
32 | } |
||||
33 | |||||
34 | return $response; |
||||
35 | } |
||||
36 | } |
||||
37 |