Skip to content

run phpstan #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: max
paths:
- src
8 changes: 6 additions & 2 deletions src/StopwatchPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stopwatch::stop never expected the second argument, only start has that.

$this->stopwatch->stop($eventName);

return $response;
}, function (Exception $exception) use ($eventName) {
$this->stopwatch->stop($eventName, self::CATEGORY);
$this->stopwatch->stop($eventName);

throw $exception;
});
Expand Down