From 04da87022d691e778be520fb34c53d8898b2769f Mon Sep 17 00:00:00 2001 From: whwyy Date: Mon, 18 Dec 2023 02:33:08 +0800 Subject: [PATCH] eee --- src/Validator/Types/ArrayProxy.php | 5 +---- src/Validator/Types/BoolProxy.php | 9 +++------ src/Validator/Types/FloatProxy.php | 7 ++----- src/Validator/Types/IntProxy.php | 7 ++----- src/Validator/Types/StringProxy.php | 7 ++----- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Validator/Types/ArrayProxy.php b/src/Validator/Types/ArrayProxy.php index eb88aa5..5938ecb 100644 --- a/src/Validator/Types/ArrayProxy.php +++ b/src/Validator/Types/ArrayProxy.php @@ -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); diff --git a/src/Validator/Types/BoolProxy.php b/src/Validator/Types/BoolProxy.php index 8c452a4..7440a22 100644 --- a/src/Validator/Types/BoolProxy.php +++ b/src/Validator/Types/BoolProxy.php @@ -1,6 +1,6 @@ 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'])) { diff --git a/src/Validator/Types/FloatProxy.php b/src/Validator/Types/FloatProxy.php index 72c4b07..6cf8706 100644 --- a/src/Validator/Types/FloatProxy.php +++ b/src/Validator/Types/FloatProxy.php @@ -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); } diff --git a/src/Validator/Types/IntProxy.php b/src/Validator/Types/IntProxy.php index d675d57..667b5b7 100644 --- a/src/Validator/Types/IntProxy.php +++ b/src/Validator/Types/IntProxy.php @@ -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); } diff --git a/src/Validator/Types/StringProxy.php b/src/Validator/Types/StringProxy.php index 24fbcf6..f5d254c 100644 --- a/src/Validator/Types/StringProxy.php +++ b/src/Validator/Types/StringProxy.php @@ -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); }