From 50ae396000b4c8c3b50c2205a37970e719430516 Mon Sep 17 00:00:00 2001 From: Jens True Date: Wed, 5 Jul 2023 15:00:31 +0000 Subject: [PATCH] 100% analysis in Psalm --- src/CommandBackup.php | 12 +++++++++--- src/Rclone/Rclone.php | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/CommandBackup.php b/src/CommandBackup.php index 95fcca5..abb0522 100644 --- a/src/CommandBackup.php +++ b/src/CommandBackup.php @@ -44,12 +44,18 @@ class CommandBackup extends Command $rclone->setLogger($app->getLogger()->withName('rclone')); $notification = new Notification(); - $notification->loadMany($app->getConfig('notification')); + /** @var array> */ + $notificationConfig = $app->getConfig('notification'); + $notification->loadMany($notificationConfig); - $render = new Twig($app->getConfig('templates')); + /** @var array */ + $templateConfig = $app->getConfig('templates'); + $render = new Twig($templateConfig); + /** @var array{title: string, source: string, destination: string}[] */ + $backupElements = $app->getConfig('backup'); /** @var array{title: string, source: string, destination: string} $conf */ - foreach ($sio->progressIterate($app->getConfig('backup')) as $conf) { + foreach ($sio->progressIterate($backupElements) as $conf) { $title = $conf['title']; try { $template = array(); diff --git a/src/Rclone/Rclone.php b/src/Rclone/Rclone.php index 704e664..3847482 100644 --- a/src/Rclone/Rclone.php +++ b/src/Rclone/Rclone.php @@ -79,7 +79,10 @@ class Rclone if (!$process->isSuccessful()) { throw new Exception($process->getErrorOutput()); } - return (int)json_decode($process->getOutput())->bytes; + + /** @var array{bytes: int} */ + $output = json_decode($process->getOutput(), true); + return $output['bytes']; } /**