Skip to content

Commit

Permalink
Merge pull request #1050 from joanhey/response-property-promotion
Browse files Browse the repository at this point in the history
Response construct use property promotion
  • Loading branch information
walkor authored Aug 8, 2024
2 parents dae4bc7 + 870220d commit fea0569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Protocols/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static function encode(mixed $response, TcpConnection $connection): strin
}
$handler = fopen($file, 'r');
if (false === $handler) {
$connection->close(new Response(403, null, '403 Forbidden'));
$connection->close(new Response(403, [], '403 Forbidden'));
return '';
}
$connection->send((string)$response, true);
Expand Down
37 changes: 6 additions & 31 deletions src/Protocols/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@
*/
class Response implements Stringable
{
/**
* Header data.
*
* @var array
*/
protected array $headers = [];

/**
* Http status.
*
* @var int
*/
protected int $status;

/**
* Http reason.
Expand All @@ -67,13 +54,6 @@ class Response implements Stringable
*/
protected string $version = '1.1';

/**
* Http body.
*
* @var string
*/
protected string $body = '';

/**
* Send file info
*
Expand Down Expand Up @@ -177,20 +157,15 @@ public static function init(): void
/**
* Response constructor.
*
* @param int $status
* @param array|null $headers
* @param int $status
* @param array $headers
* @param string $body
*/
public function __construct(
int $status = 200,
?array $headers = [],
string $body = ''
)
{
$this->status = $status;
$this->headers = $headers;
$this->body = $body;
}
protected int $status = 200,
protected array $headers = [],
protected string $body = ''
) {}

/**
* Set header.
Expand Down

0 comments on commit fea0569

Please sign in to comment.