mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
PHP/Core
* enforced v7.1 compliance, preparations for v7.2 * removed deprecated usage of each() * prefer array deconstruction via [] instead of calling list() * try to catch failed session_start() * prefer ... - Token instead of calling func_get_args() func_num_args() * enforce return types in AjaxHandler * revision push
This commit is contained in:
@@ -28,7 +28,7 @@ class AjaxHandler
|
||||
$v = isset($_GET[$k]) ? filter_input(INPUT_GET, $k, $v[0], $v[1]) : null;
|
||||
}
|
||||
|
||||
public function handle(&$out)
|
||||
public function handle(string &$out) : bool
|
||||
{
|
||||
if (!$this->handler)
|
||||
return false;
|
||||
@@ -43,46 +43,56 @@ class AjaxHandler
|
||||
}
|
||||
|
||||
$h = $this->handler;
|
||||
$out = (string)$this->$h();
|
||||
$out = $this->$h();
|
||||
if ($out === null)
|
||||
$out = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getContentType()
|
||||
public function getContentType() : string
|
||||
{
|
||||
return $this->contentType;
|
||||
}
|
||||
|
||||
protected function checkEmptySet($val)
|
||||
protected function checkEmptySet(string $val) : bool
|
||||
{
|
||||
return $val === ''; // parameter is expected to be empty
|
||||
}
|
||||
|
||||
protected function checkLocale($val)
|
||||
protected function checkLocale(string $val) : int
|
||||
{
|
||||
if (preg_match('/^'.implode('|', array_keys(array_filter(Util::$localeStrings))).'$/', $val))
|
||||
return intval($val);
|
||||
return intVal($val);
|
||||
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected function checkInt($val)
|
||||
protected function checkInt(string $val) : int
|
||||
{
|
||||
if (preg_match('/^-?\d+$/', $val))
|
||||
return intval($val);
|
||||
return intVal($val);
|
||||
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function checkIdList($val)
|
||||
protected function checkIdList(string $val) : array
|
||||
{
|
||||
if (preg_match('/^-?\d+(,-?\d+)*$/', $val))
|
||||
return array_map('intval', explode(',', $val));
|
||||
return array_map('intVal', explode(',', $val));
|
||||
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function checkFulltext($val)
|
||||
protected function checkIdListUnsigned(string $val) : array
|
||||
{
|
||||
if (preg_match('/\d+(,\d+)*/', $val))
|
||||
return array_map('intVal', explode(',', $val));
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function checkFulltext(string $val) : string
|
||||
{
|
||||
// trim non-printable chars
|
||||
return preg_replace('/[\p{C}]/ui', '', $val);
|
||||
|
||||
Reference in New Issue
Block a user