diff options
author | Andrew Dolgov <[email protected]> | 2021-11-14 22:53:07 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-11-14 22:53:07 +0300 |
commit | fc5f5e4e5017180222cc3f9ee0ac26310f29c7c1 (patch) | |
tree | cc81a86f5fa0d0ea0c3377aaa2fcdc452822fd07 | |
parent | 841bea895d4831ca2d8b2f3903d3df9e4755c21a (diff) |
fix phpstan warnings
-rw-r--r-- | init.php | 54 |
1 files changed, 43 insertions, 11 deletions
@@ -1,7 +1,7 @@ <?php class Data_Migration extends Plugin { - private $DATA_FORMAT_VERSION = 1; + const DATA_FORMAT_VERSION = 1; function init($host) { $host->add_command("data-user", "set username for import/export", $this, ":", "USER"); @@ -18,15 +18,28 @@ class Data_Migration extends Plugin { "https://git.tt-rss.org/fox/ttrss-data-migration/wiki"); } - function data_only_marked($args) { + /** + * @param array<string> $args + * @return void + */ + function data_only_marked(array $args) : void { // } - function data_user($args) { + /** + * @param array<string> $args + * @return void + */ + function data_user(array $args) : void { // } - function data_import(array $args) { + /** + * @param array<string> $args + * @return void + * @throws PDOException + */ + function data_import(array $args) : void { $user = $args["data_user"]; $input_file = $args["data_import"]; @@ -60,7 +73,7 @@ class Data_Migration extends Plugin { $batch = json_decode($zip->getFromIndex($i), true); if ($batch) { - if ($batch["version"] == $this->DATA_FORMAT_VERSION) { + if ($batch["version"] == self::DATA_FORMAT_VERSION) { if ($batch["schema-version"] == SCHEMA_VERSION) { $total_processed += count($batch["articles"]); @@ -75,7 +88,7 @@ class Data_Migration extends Plugin { } } else { Debug::log("batch has incorrect data format version (expected: " . - $this->DATA_FORMAT_VERSION . ", got: " . $batch["version"]); + self::DATA_FORMAT_VERSION . ", got: " . $batch["version"]); } @@ -94,7 +107,12 @@ class Data_Migration extends Plugin { } } - function data_export(array $args) { + /** + * @param array<string> $args + * @return void + * @throws PDOException + */ + function data_export(array $args) :void { $user = $args["data_user"]; $output_file = $args["data_export"]; $only_marked = isset($args["data_only_marked"]); @@ -139,7 +157,7 @@ class Data_Migration extends Plugin { $batch_filename = sprintf("%08d.json", $batch_seq); $batch = [ - "version" => $this->DATA_FORMAT_VERSION, + "version" => self::DATA_FORMAT_VERSION, "schema-version" => SCHEMA_VERSION, "articles" => $this->get_export_batch($owner_uid, $offset, $batch_size, $only_marked) ]; @@ -167,7 +185,15 @@ class Data_Migration extends Plugin { } } - private function get_export_batch(int $owner_uid, int $offset, int $batch_size, bool $only_marked) { + /** + * @param int $owner_uid + * @param int $offset + * @param int $batch_size + * @param bool $only_marked + * @return array<int, array<string, int|string>> + * @throws PDOException + */ + private function get_export_batch(int $owner_uid, int $offset, int $batch_size, bool $only_marked) : array { $rv = []; Debug::log("processing articles, offset: $offset"); @@ -221,7 +247,7 @@ class Data_Migration extends Plugin { return $rv; } - private function convert_guid(string $guid, int $owner_uid) { + private function convert_guid(string $guid, int $owner_uid) : string { if (strpos($guid, 'SHA1:') === 0) { return $guid; // legacy format } else { @@ -236,7 +262,13 @@ class Data_Migration extends Plugin { } } - private function import_article_batch(int $owner_uid, array $articles) { + /** + * @param int $owner_uid + * @param array<int, array<string, int|string>> $articles + * @return array<int, int> + * @throws PDOException + */ + private function import_article_batch(int $owner_uid, array $articles) : array { $total_imported = 0; $total_feeds_created = 0; |