This commit is contained in:
2023-12-18 02:33:08 +08:00
parent f17381c4de
commit 04da87022d
5 changed files with 10 additions and 25 deletions
+1 -4
View File
@@ -16,10 +16,7 @@ class ArrayProxy extends TypesProxy
public function dispatch(object $form, string $field, mixed $value): bool
{
if (is_null($value)) {
if (!$this->allowsNull) {
return false;
}
$form->{$field} = [];
$form->{$field} = !$this->allowsNull ? [] : null;
return true;
}
return $value == ($form->{$field} = $value);
+3 -6
View File
@@ -1,6 +1,6 @@
<?php
namespace Kiri\Router\Validator\Types;
namespace Kiri\Router\Validator\Types;
class BoolProxy extends TypesProxy
@@ -16,11 +16,8 @@ class BoolProxy extends TypesProxy
public function dispatch(object $form, string $field, mixed $value): bool
{
if (is_null($value)) {
if (!$this->allowsNull) {
return false;
}
$form->{$field} = false;
return false;
$form->{$field} = !$this->allowsNull ? false : null;
return true;
}
// TODO: Implement dispatch() method.
if (in_array($value, ['false', 'true'])) {
+2 -5
View File
@@ -15,11 +15,8 @@ class FloatProxy extends TypesProxy
public function dispatch(object $form, string $field, mixed $value): bool
{
if (is_null($value)) {
if (!$this->allowsNull) {
return false;
}
$form->{$field} = 0;
return false;
$form->{$field} = !$this->allowsNull ? 0 : null;
return true;
}
return $value == ($form->{$field} = (float)$value);
}
+2 -5
View File
@@ -15,11 +15,8 @@ class IntProxy extends TypesProxy
public function dispatch(object $form, string $field, mixed $value): bool
{
if (is_null($value)) {
if (!$this->allowsNull) {
return false;
}
$form->{$field} = 0;
return false;
$form->{$field} = !$this->allowsNull ? 0 : null;
return true;
}
return $value == ($form->{$field} = (int)$value);
}
+2 -5
View File
@@ -16,11 +16,8 @@ class StringProxy extends TypesProxy
public function dispatch(object $form, string $field, mixed $value): bool
{
if (is_null($value)) {
if (!$this->allowsNull) {
return false;
}
$form->{$field} = '';
return false;
$form->{$field} = !$this->allowsNull ? '' : null;
return true;
}
return $value == ($form->{$field} = (string)$value);
}