yiisoft /
yii-debug
| 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( |
||||
| 14 | private readonly ClientInterface $decorated, |
||||
| 15 | private readonly HttpClientCollector $collector |
||||
| 16 | ) { |
||||
| 17 | } |
||||
| 18 | |||||
| 19 | public function sendRequest(RequestInterface $request): ResponseInterface |
||||
| 20 | { |
||||
| 21 | /** @psalm-var array{file: string, line: int} $callStack */ |
||||
| 22 | $callStack = debug_backtrace()[0]; |
||||
| 23 | |||||
| 24 | $uniqueId = random_bytes(36); |
||||
| 25 | $startTime = microtime(true); |
||||
| 26 | $this->collector->collect($request, $startTime, $callStack['file'] . ':' . $callStack['line'], $uniqueId); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 27 | |||||
| 28 | $response = null; |
||||
|
0 ignored issues
–
show
|
|||||
| 29 | try { |
||||
| 30 | $response = $this->decorated->sendRequest($request); |
||||
| 31 | } finally { |
||||
| 32 | $endTime = microtime(true); |
||||
| 33 | $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...
|
|||||
| 34 | } |
||||
| 35 | |||||
| 36 | return $response; |
||||
| 37 | } |
||||
| 38 | } |
||||
| 39 |