Skip to content

Commit

Permalink
Merge pull request #11 from Kanti/bugfix/undefined-property
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti authored Oct 8, 2022
2 parents 06aac44 + 36e6361 commit bd2c0b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Classes/Middleware/FirstMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

class FirstMiddleware implements MiddlewareInterface
{
/** @var StopWatch|null */
public static $stopWatchOutward = null;

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$stop = TimingUtility::stopWatch('middleware', 'Inward');
$request = $request->withAttribute('server-timing:middleware:inward', $stop);
$this->registerSqlLogger();
$response = $handler->handle($request);
// @phpstan-ignore-next-line
$stop = $response->stopWatch;
$stop = self::$stopWatchOutward;
if ($stop instanceof StopWatch) {
$stop();
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/Middleware/LastMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$stop = TimingUtility::stopWatch('requestHandler');
$response = $handler->handle($request);
$stop();
// @phpstan-ignore-next-line
$response->stopWatch = TimingUtility::stopWatch('middleware', 'Outward');
\Kanti\ServerTiming\Middleware\FirstMiddleware::$stopWatchOutward = TimingUtility::stopWatch('middleware', 'Outward');
return $response;
}
}

0 comments on commit bd2c0b8

Please sign in to comment.