From 5fae56f6bfd142f4a749cd8780604e87a0119a09 Mon Sep 17 00:00:00 2001 From: Ry0 <43928323+xRy0@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:49:41 +0000 Subject: [PATCH] thx celestora <3 --- Web/Presenters/VKAPIPresenter.php | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/Web/Presenters/VKAPIPresenter.php b/Web/Presenters/VKAPIPresenter.php index 4b57fe68..62f95723 100644 --- a/Web/Presenters/VKAPIPresenter.php +++ b/Web/Presenters/VKAPIPresenter.php @@ -236,30 +236,10 @@ final class VKAPIPresenter extends OpenVKPresenter try { // Проверка типа параметра $type = $parameter->getType(); - if ($type && !$type->isBuiltin()) { - $params[] = $val; // Пользовательские типы оставляем как есть - } else if (is_null($val)) { - $params[] = $val; // Если значение NULL, то оставляем его NULL - } else { - switch ($type->getName()) { - case 'int': - $val = (int)$val; - break; - case 'float': - $val = (float)$val; - break; - case 'bool': - $val = (bool)$val; - break; - case 'string': - $val = (string)$val; - break; - // Добавить другие типы при необходимости - default: - settype($val, $type->getName()); - } - $params[] = $val; - } + if (($type && !$type->isBuiltin()) || is_null($val)) + $params[] = $val; + else + $params[] = settype($val, $type->getName()); } catch (\Throwable $e) { // Just ignore the exception, since // some args are intended for internal use