chore: Аннотации к типам
This commit is contained in:
parent
1e27648a12
commit
e2ba6bd46e
2 changed files with 20 additions and 11 deletions
|
|
@ -7,12 +7,8 @@ namespace ctiso;
|
||||||
*/
|
*/
|
||||||
class Collection implements \ArrayAccess
|
class Collection implements \ArrayAccess
|
||||||
{
|
{
|
||||||
/**
|
/** @var array */
|
||||||
* Holds collective request data
|
protected $data = [];
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $data = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Преобразование массива в коллекцию
|
* Преобразование массива в коллекцию
|
||||||
|
|
@ -34,8 +30,7 @@ class Collection implements \ArrayAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store "request data" in GPC order.
|
|
||||||
*
|
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*
|
*
|
||||||
|
|
@ -50,7 +45,6 @@ class Collection implements \ArrayAccess
|
||||||
* Read stored "request data" by referencing a key.
|
* Read stored "request data" by referencing a key.
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
*
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($key, $default = null)
|
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;
|
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)
|
public function getInt($key, $default = 0)
|
||||||
{
|
{
|
||||||
return (int)$this->get($key, $default);
|
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);
|
return (string)$this->get($key, $default);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class HttpRequest extends Collection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param T $key
|
* @param string $key
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function get($key, $default = null)
|
function get($key, $default = null)
|
||||||
|
|
@ -56,6 +56,11 @@ class HttpRequest extends Collection
|
||||||
return parent::get('data')->get($key, $default);
|
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)
|
function session(?Session $value = null)
|
||||||
{
|
{
|
||||||
if ($value) {
|
if ($value) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue