Skip to content

Commit

Permalink
Code style change
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jul 2, 2023
1 parent 2c297e1 commit 022ace9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions src/Connection/Internal/Http1Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ public function parse(string $data = null): ?Response

if (!$this->bodyStarted && \in_array($this->state, [self::BODY_CHUNKS, self::BODY_IDENTITY, self::BODY_IDENTITY_EOF], true)) {
$this->bodyStarted = true;

$eventInvoker = events();
\assert($this->response !== null);
$eventInvoker->responseBodyStart($this->request, $this->stream, $this->response);
$response = $this->response;
\assert($response !== null);
events()->responseBodyStart($this->request, $this->stream, $response);
}

switch ($this->state) {
Expand Down
16 changes: 8 additions & 8 deletions src/Connection/Internal/Http2ConnectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,15 +779,15 @@ public function handleData(int $streamId, string $data): void
return;
}

$eventInvoker = events();
\assert($stream->response !== null);
$response = $stream->response;
\assert($response !== null);

if (!$stream->bodyStarted) {
$stream->bodyStarted = true;
$eventInvoker->responseBodyStart($stream->request, $stream->stream, $stream->response);
events()->responseBodyStart($stream->request, $stream->stream, $response);
}

$eventInvoker->responseBodyProgress($stream->request, $stream->stream, $stream->response);
events()->responseBodyProgress($stream->request, $stream->stream, $response);

$stream->body?->pushAsync($data)->map(function () use ($streamId, $length): void {
$stream = $this->streams[$streamId] ?? null;
Expand Down Expand Up @@ -842,15 +842,15 @@ public function handleStreamEnd(int $streamId): void
$stream->body->complete();
$stream->body = null;

$eventInvoker = events();
$response = $stream->response;
\assert($response !== null);

if (EventInvoker::getPhase($stream->request) === Phase::ResponseHeaders) {
\assert($stream->response !== null);
$eventInvoker->responseBodyStart($stream->request, $stream->stream, $stream->response);
events()->responseBodyStart($stream->request, $stream->stream, $response);
}

\assert($stream->response !== null);
$eventInvoker->responseBodyEnd($stream->request, $stream->stream, $stream->response);
events()->responseBodyEnd($stream->request, $stream->stream, $response);

// Trailers may have been received in handleHeaders(); if not, resolve with an empty set of trailers.
if ($stream->trailers !== null) {
Expand Down

0 comments on commit 022ace9

Please sign in to comment.