From e0832390ce83bdf7707c2f2a9f722cb557543af2 Mon Sep 17 00:00:00 2001 From: Alexander Pankratov Date: Wed, 20 May 2020 23:15:52 +0300 Subject: [PATCH] Type fixes --- src/danog/MadelineProto/Db/MysqlArray.php | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/danog/MadelineProto/Db/MysqlArray.php b/src/danog/MadelineProto/Db/MysqlArray.php index 85c14e00a..801a680bf 100644 --- a/src/danog/MadelineProto/Db/MysqlArray.php +++ b/src/danog/MadelineProto/Db/MysqlArray.php @@ -40,6 +40,14 @@ class MysqlArray implements DbArray } + /** + * @param string $name + * @param DbArray|array|null $value + * @param string $tablePrefix + * @param array $settings + * + * @return Promise + */ public static function getInstance(string $name, $value = null, string $tablePrefix = '', array $settings = []): Promise { $instance = new static(); @@ -58,7 +66,13 @@ class MysqlArray implements DbArray }); } - private static function renameTmpTable(MysqlArray $instance, ?DbArray $value): \Generator + /** + * @param MysqlArray $instance + * @param DbArray|array|null $value + * + * @return \Generator + */ + private static function renameTmpTable(MysqlArray $instance, $value): \Generator { if ($value instanceof static && $value->table) { if ( @@ -72,13 +86,18 @@ class MysqlArray implements DbArray } } - private static function migrateDataToDb(MysqlArray $instance, ?DbArray $value): \Generator + /** + * @param MysqlArray $instance + * @param DbArray|array|null $value + * + * @return \Generator + * @throws \Throwable + */ + private static function migrateDataToDb(MysqlArray $instance, $value): \Generator { if (!empty($value) && !$value instanceof static) { Logger::log('Converting database.', Logger::ERROR); - if ($value instanceof DbArray) { - $value = $value->getArrayCopy(); - } + $value = (array) $value; $counter = 0; $total = count($value);