This commit is contained in:
2023-12-18 02:21:27 +08:00
parent f7bf87fdca
commit cf3aad6001
6 changed files with 18 additions and 0 deletions
+3
View File
@@ -15,6 +15,9 @@ class ArrayProxy extends TypesProxy
*/ */
public function dispatch(object $form, string $field, mixed $value): bool public function dispatch(object $form, string $field, mixed $value): bool
{ {
if (is_null($value) && !$this->allowsNull) {
return false;
}
return $value == ($form->{$field} = $value); return $value == ($form->{$field} = $value);
} }
+3
View File
@@ -15,6 +15,9 @@ class BoolProxy extends TypesProxy
*/ */
public function dispatch(object $form, string $field, mixed $value): bool public function dispatch(object $form, string $field, mixed $value): bool
{ {
if (is_null($value) && !$this->allowsNull) {
return false;
}
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
if (in_array($value, ['false', 'true'])) { if (in_array($value, ['false', 'true'])) {
$form->{$field} = $value === 'true'; $form->{$field} = $value === 'true';
+3
View File
@@ -14,6 +14,9 @@ class FloatProxy extends TypesProxy
*/ */
public function dispatch(object $form, string $field, mixed $value): bool public function dispatch(object $form, string $field, mixed $value): bool
{ {
if (is_null($value) && !$this->allowsNull) {
return false;
}
return $value == ($form->{$field} = (float)$value); return $value == ($form->{$field} = (float)$value);
} }
} }
+3
View File
@@ -14,6 +14,9 @@ class IntProxy extends TypesProxy
*/ */
public function dispatch(object $form, string $field, mixed $value): bool public function dispatch(object $form, string $field, mixed $value): bool
{ {
if (is_null($value) && !$this->allowsNull) {
return false;
}
return $value == ($form->{$field} = (int)$value); return $value == ($form->{$field} = (int)$value);
} }
+3
View File
@@ -19,6 +19,9 @@ class MixedProxy extends TypesProxy
public function dispatch(object $form, string $field, mixed $value): bool public function dispatch(object $form, string $field, mixed $value): bool
{ {
try { try {
if (is_null($value) && !$this->allowsNull) {
return false;
}
return $value == ($form->{$field} = $value); return $value == ($form->{$field} = $value);
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
return false; return false;
+3
View File
@@ -15,6 +15,9 @@ class StringProxy extends TypesProxy
*/ */
public function dispatch(object $form, string $field, mixed $value): bool public function dispatch(object $form, string $field, mixed $value): bool
{ {
if (is_null($value) && !$this->allowsNull) {
return false;
}
return $value == ($form->{$field} = (string)$value); return $value == ($form->{$field} = (string)$value);
} }