Skip to content
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

Response construct use property promotion #1050

Merged
merged 2 commits into from
Aug 8, 2024
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
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
Loading