chore: Аннотации к типам

This commit is contained in:
origami11@yandex.ru 2025-10-27 16:39:44 +03:00
parent 730a608f9b
commit 89913de4fe
19 changed files with 124 additions and 24 deletions

View file

@ -8,15 +8,21 @@ class HttpRequest
const POST = "POST";
const GET = "GET";
private $param = []; // Параметры запроса
public $data = null; // Содержание
public $url; // Адресс
public $method; // Метод
/** @var array Параметры запроса */
private $param = [];
/** @var string Содержание */
public $data = null;
/** @var string Адресс */
public $url;
/** @var string Метод */
public $method;
/** @var int */
public $port = 80;
/** @var string */
public $host = "";
/** @var ?string */
public $proxy_host = null;
/** @var ?int */
public $proxy_port = null;
/** @var string */
public $http_version = 'HTTP/1.1';

View file

@ -7,11 +7,17 @@ namespace ctiso\Connection;
class HttpResponse
{
/** @var int */
private $offset;
/** @var array */
private $param = [];
/** @var int */
private $code;
/** @var string */
public $response;
/** @var string */
public $version;
/** @var string */
public $data;
public function __construct($response)
@ -28,7 +34,7 @@ class HttpResponse
{
$http = explode(" ", $this->getLine());
$this->version = $http[0];
$this->code = $http[1];
$this->code = (int)$http[1];
$line = $this->getLine();
while ($offset = strpos($line, ":")) {
@ -55,7 +61,7 @@ class HttpResponse
/**
* Обработка строки HTTP ответа
*/
private function getLine()
private function getLine(): string
{
$begin = $this->offset;
$offset = strpos($this->response, "\r\n", $this->offset);
@ -67,12 +73,12 @@ class HttpResponse
/**
* Значение параметра HTTP ответа
*/
public function getParameter($name)
public function getParameter($name): string
{
return $this->param[$name];
}
public function getData()
public function getData(): string
{
return $this->data;
}
@ -80,7 +86,7 @@ class HttpResponse
/**
* Состояние
*/
public function getCode()
public function getCode(): int
{
return $this->code;
}