Skip to content

Commit 0daec9b

Browse files
authored
Merge pull request #23 from php-http/static-analysis
run phpstan
2 parents 5291dee + eb2d254 commit 0daec9b

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/static.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
phpstan:
11+
name: PHPStan
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: PHPStan
19+
uses: docker://oskarstark/phpstan-ga
20+
with:
21+
args: analyze --no-progress

phpstan.neon.dist

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src

src/StopwatchPlugin.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Http\Client\Common\Plugin;
66
use Http\Client\Exception;
7+
use Http\Promise\Promise;
78
use Psr\Http\Message\RequestInterface;
89
use Psr\Http\Message\ResponseInterface;
910
use Symfony\Component\Stopwatch\Stopwatch;
@@ -29,17 +30,20 @@ public function __construct(Stopwatch $stopwatch)
2930
$this->stopwatch = $stopwatch;
3031
}
3132

33+
/**
34+
* @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient)
35+
*/
3236
protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)
3337
{
3438
$eventName = $this->getStopwatchEventName($request);
3539
$this->stopwatch->start($eventName, self::CATEGORY);
3640

3741
return $next($request)->then(function (ResponseInterface $response) use ($eventName) {
38-
$this->stopwatch->stop($eventName, self::CATEGORY);
42+
$this->stopwatch->stop($eventName);
3943

4044
return $response;
4145
}, function (Exception $exception) use ($eventName) {
42-
$this->stopwatch->stop($eventName, self::CATEGORY);
46+
$this->stopwatch->stop($eventName);
4347

4448
throw $exception;
4549
});

0 commit comments

Comments
 (0)