Add type hints to Transmitter

This commit is contained in:
PJ Dietz 2020-08-09 14:30:19 -04:00
parent ca204a07e7
commit 98014d8c59
2 changed files with 7 additions and 9 deletions

View File

@ -27,7 +27,7 @@ class Transmitter implements TransmitterInterface
public function transmit( public function transmit(
ServerRequestInterface $request, ServerRequestInterface $request,
ResponseInterface $response ResponseInterface $response
) { ): void {
// Prepare the response for output. // Prepare the response for output.
$response = $this->prepareResponse($request, $response); $response = $this->prepareResponse($request, $response);
@ -48,10 +48,7 @@ class Transmitter implements TransmitterInterface
} }
} }
/** public function setChunkSize(int $chunkSize): void
* @param int $chunkSize
*/
public function setChunkSize($chunkSize)
{ {
$this->chunkSize = $chunkSize; $this->chunkSize = $chunkSize;
} }
@ -59,7 +56,8 @@ class Transmitter implements TransmitterInterface
protected function prepareResponse( protected function prepareResponse(
ServerRequestInterface $request, ServerRequestInterface $request,
ResponseInterface $response ResponseInterface $response
) { ): ResponseInterface {
// Add a Content-length header to the response when all of these are true: // Add a Content-length header to the response when all of these are true:
// //
// - Response does not have a Content-length header // - Response does not have a Content-length header
@ -77,7 +75,7 @@ class Transmitter implements TransmitterInterface
return $response; return $response;
} }
private function getStatusLine(ResponseInterface $response) private function getStatusLine(ResponseInterface $response): string
{ {
$protocol = $response->getProtocolVersion(); $protocol = $response->getProtocolVersion();
$statusCode = $response->getStatusCode(); $statusCode = $response->getStatusCode();
@ -89,7 +87,7 @@ class Transmitter implements TransmitterInterface
} }
} }
private function outputBody(StreamInterface $body) private function outputBody(StreamInterface $body): void
{ {
if ($this->chunkSize > 0) { if ($this->chunkSize > 0) {
if ($body->isSeekable()) { if ($body->isSeekable()) {

View File

@ -18,5 +18,5 @@ interface TransmitterInterface
* @param ServerRequestInterface $request * @param ServerRequestInterface $request
* @param ResponseInterface $response Response to output * @param ResponseInterface $response Response to output
*/ */
public function transmit(ServerRequestInterface $request, ResponseInterface $response); public function transmit(ServerRequestInterface $request, ResponseInterface $response): void;
} }