diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..4e821aa --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,21 @@ +name: Static analysis + +on: + push: + branches: + - master + pull_request: + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: PHPStan + uses: docker://oskarstark/phpstan-ga + with: + args: analyze --no-progress diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..776ccd8 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,4 @@ +parameters: + level: max + paths: + - src diff --git a/src/StopwatchPlugin.php b/src/StopwatchPlugin.php index 96d35a2..01c2b52 100644 --- a/src/StopwatchPlugin.php +++ b/src/StopwatchPlugin.php @@ -4,6 +4,7 @@ use Http\Client\Common\Plugin; use Http\Client\Exception; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Symfony\Component\Stopwatch\Stopwatch; @@ -29,17 +30,20 @@ public function __construct(Stopwatch $stopwatch) $this->stopwatch = $stopwatch; } + /** + * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient) + */ protected function doHandleRequest(RequestInterface $request, callable $next, callable $first) { $eventName = $this->getStopwatchEventName($request); $this->stopwatch->start($eventName, self::CATEGORY); return $next($request)->then(function (ResponseInterface $response) use ($eventName) { - $this->stopwatch->stop($eventName, self::CATEGORY); + $this->stopwatch->stop($eventName); return $response; }, function (Exception $exception) use ($eventName) { - $this->stopwatch->stop($eventName, self::CATEGORY); + $this->stopwatch->stop($eventName); throw $exception; });