Fixed defaults handling.
This commit is contained in:
parent
d86291abf8
commit
3684fc3b0c
2 changed files with 8 additions and 8 deletions
|
@ -3,10 +3,10 @@ use Misuzu\Request\RequestVar;
|
||||||
|
|
||||||
require_once '../misuzu.php';
|
require_once '../misuzu.php';
|
||||||
|
|
||||||
$changelogChange = RequestVar::get()->select('c')->int();
|
$changelogChange = RequestVar::get()->select('c')->int(0);
|
||||||
$changelogDate = RequestVar::get()->select('d')->string();
|
$changelogDate = RequestVar::get()->select('d')->string('');
|
||||||
$changelogUser = RequestVar::get()->select('u')->int();
|
$changelogUser = RequestVar::get()->select('u')->int(0);
|
||||||
$changelogTags = RequestVar::get()->select('t')->string();
|
$changelogTags = RequestVar::get()->select('t')->string('');
|
||||||
|
|
||||||
tpl_var('comments_perms', $commentPerms = comments_get_perms(user_session_current('user_id', 0)));
|
tpl_var('comments_perms', $commentPerms = comments_get_perms(user_session_current('user_id', 0)));
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ namespace Misuzu\Request;
|
||||||
|
|
||||||
class RequestVar
|
class RequestVar
|
||||||
{
|
{
|
||||||
private $value;
|
private $value = null;
|
||||||
private $valueCasted = null;
|
private $valueCasted = null;
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
|
@ -90,17 +90,17 @@ class RequestVar
|
||||||
|
|
||||||
public function int(?int $default = null): ?int
|
public function int(?int $default = null): ?int
|
||||||
{
|
{
|
||||||
return (int)$this->value == $this->value ? (int)$this->value : $default;
|
return empty($this->value) ? $default : (int)$this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bool(?bool $default = null): bool
|
public function bool(?bool $default = null): bool
|
||||||
{
|
{
|
||||||
return (bool)$this->value == $this->value ? (bool)$this->value : $default;
|
return empty($this->value) ? $default : (bool)$this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function float(?float $default = null): float
|
public function float(?float $default = null): float
|
||||||
{
|
{
|
||||||
return (float)$this->value == $this->value ? (float)$this->value : $default;
|
return empty($this->value) ? $default : (float)$this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid using when possible
|
// avoid using when possible
|
||||||
|
|
Loading…
Add table
Reference in a new issue