diff --git a/src/Connection/UdpConnection.php b/src/Connection/UdpConnection.php index 1a25af0af..dac804107 100644 --- a/src/Connection/UdpConnection.php +++ b/src/Connection/UdpConnection.php @@ -45,31 +45,15 @@ class UdpConnection extends ConnectionInterface implements JsonSerializable */ public string $transport = 'udp'; - /** - * Udp socket. - * - * @var resource - */ - protected $socket; - - /** - * Remote address. - * - * @var string - */ - protected string $remoteAddress = ''; - /** * Construct. * * @param resource $socket * @param string $remoteAddress */ - public function __construct($socket, string $remoteAddress) - { - $this->socket = $socket; - $this->remoteAddress = $remoteAddress; - } + public function __construct( + protected $socket, + protected string $remoteAddress) {} /** * Sends data on the connection. diff --git a/src/Protocols/Http/Chunk.php b/src/Protocols/Http/Chunk.php index f9a7394d7..2c7a2a8f8 100644 --- a/src/Protocols/Http/Chunk.php +++ b/src/Protocols/Http/Chunk.php @@ -27,30 +27,11 @@ */ class Chunk implements Stringable { - /** - * Chunk buffer. - * - * @var string - */ - protected string $buffer; - /** - * Chunk constructor. - * - * @param string $buffer - */ - public function __construct(string $buffer) - { - $this->buffer = $buffer; - } + public function __construct(protected string $buffer) {} - /** - * __toString - * - * @return string - */ public function __toString(): string { return dechex(strlen($this->buffer)) . "\r\n$this->buffer\r\n"; } -} \ No newline at end of file +} diff --git a/src/Protocols/Http/Request.php b/src/Protocols/Http/Request.php index 08b7d7a6d..548735828 100644 --- a/src/Protocols/Http/Request.php +++ b/src/Protocols/Http/Request.php @@ -78,13 +78,6 @@ class Request implements Stringable */ public array $properties = []; - /** - * Http buffer. - * - * @var string - */ - protected string $buffer; - /** * Request data. * @@ -116,12 +109,8 @@ class Request implements Stringable /** * Request constructor. * - * @param string $buffer */ - public function __construct(string $buffer) - { - $this->buffer = $buffer; - } + public function __construct(protected string $buffer) {} /** * Get query. diff --git a/src/Protocols/Http/ServerSentEvents.php b/src/Protocols/Http/ServerSentEvents.php index ad4a4ffa4..6b70b10a8 100644 --- a/src/Protocols/Http/ServerSentEvents.php +++ b/src/Protocols/Http/ServerSentEvents.php @@ -26,27 +26,12 @@ */ class ServerSentEvents implements Stringable { - /** - * Data. - * @var array - */ - protected array $data; - /** * ServerSentEvents constructor. * $data for example ['event'=>'ping', 'data' => 'some thing', 'id' => 1000, 'retry' => 5000] - * @param array $data */ - public function __construct(array $data) - { - $this->data = $data; - } + public function __construct(protected array $data) {} - /** - * __toString. - * - * @return string - */ public function __toString(): string { $buffer = ''; @@ -66,6 +51,6 @@ public function __toString(): string if (isset($data['data'])) { $buffer .= 'data: ' . str_replace("\n", "\ndata: ", $data['data']) . "\n"; } - return $buffer . "\n"; + return "$buffer\n"; } }