mirror of
https://github.com/openvk/openvk
synced 2024-11-15 19:49:14 +03:00
Fix settype to allow Null
This commit is contained in:
parent
ba2e00adac
commit
31f0d184e7
2 changed files with 28 additions and 5 deletions
|
@ -485,8 +485,7 @@ final class Audio extends VKAPIRequestHandler
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
$this->willExecuteWriteAction();
|
$this->willExecuteWriteAction();
|
||||||
|
|
||||||
if(!is_null($album_id)) // Думаю ?int $album_id = NULL возвращает 0 из-за ?int
|
if(!is_null($album_id))
|
||||||
if($album_id > 0)
|
|
||||||
$this->fail(10, "album_id not implemented");
|
$this->fail(10, "album_id not implemented");
|
||||||
|
|
||||||
// TODO get rid of dups
|
// TODO get rid of dups
|
||||||
|
|
|
@ -234,8 +234,32 @@ final class VKAPIPresenter extends OpenVKPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
settype($val, $parameter->getType()->getName());
|
// Проверка типа параметра
|
||||||
|
$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;
|
$params[] = $val;
|
||||||
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// Just ignore the exception, since
|
// Just ignore the exception, since
|
||||||
// some args are intended for internal use
|
// some args are intended for internal use
|
||||||
|
|
Loading…
Reference in a new issue