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

This commit is contained in:
origami11@yandex.ru 2025-10-21 15:55:49 +03:00
parent 1e27648a12
commit e2ba6bd46e
2 changed files with 20 additions and 11 deletions

View file

@ -7,12 +7,8 @@ namespace ctiso;
*/
class Collection implements \ArrayAccess
{
/**
* Holds collective request data
*
* @var array
*/
protected $data = array();
/** @var array */
protected $data = [];
/**
* Преобразование массива в коллекцию
@ -34,8 +30,7 @@ class Collection implements \ArrayAccess
}
/**
* Store "request data" in GPC order.
*
* @param string $key
* @param mixed $value
*
@ -50,7 +45,6 @@ class Collection implements \ArrayAccess
* Read stored "request data" by referencing a key.
*
* @param string $key
*
* @return mixed
*/
public function get($key, $default = null)
@ -58,12 +52,22 @@ class Collection implements \ArrayAccess
return isset($this->data[$key]) && $this->data[$key] != '' ? $this->data[$key] : $default;
}
/**
* @param string $key
* @param int $default
* @return int
*/
public function getInt($key, $default = 0)
{
return (int)$this->get($key, $default);
}
public function getString($key, $default = '')
/**
* @param string $key
* @param string $default
* @return string
*/
public function getString(string $key, string $default = ''): string
{
return (string)$this->get($key, $default);
}

View file

@ -48,7 +48,7 @@ class HttpRequest extends Collection
}
/**
* @param T $key
* @param string $key
* @return mixed
*/
function get($key, $default = null)
@ -56,6 +56,11 @@ class HttpRequest extends Collection
return parent::get('data')->get($key, $default);
}
function getString(string $key, string $default = ''): string
{
return parent::get('data')->getString($key, $default);
}
function session(?Session $value = null)
{
if ($value) {