From 1d898e350bfe91128ed364cbb7ef9e2f4b077d7e Mon Sep 17 00:00:00 2001 From: Jens True Date: Fri, 28 Jul 2023 12:12:47 +0000 Subject: [PATCH] 100% type coverage for psalm --- backup | 12 ++++++++---- composer.lock | 12 ++++++------ psalm.xml | 10 +++++++--- src/App.php | 2 +- src/Rclone/Rclone.php | 4 ++-- tests/Rclone/RcloneTest.php | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/backup b/backup index 8e2ebb5..bc30140 100755 --- a/backup +++ b/backup @@ -8,8 +8,12 @@ use Composer\InstalledVersions; $package = \Composer\InstalledVersions::getRootPackage(); $application = new Application('backup', $package['version']); +try { + $application->add(new App\CommandBackup()); + $application->add(new App\CommandShow()); -$application->add(new App\CommandBackup()); -$application->add(new App\CommandShow()); - -$application->run(); \ No newline at end of file + $application->run(); +} catch(Exception $e) +{ + echo("Critical error: ". $e->getMessage()); +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 1970115..c259ac7 100644 --- a/composer.lock +++ b/composer.lock @@ -3290,16 +3290,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.2", + "version": "10.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e" + "reference": "be1fe461fdc917de2a29a452ccf2657d325b443d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/db1497ec8dd382e82c962f7abbe0320e4882ee4e", - "reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/be1fe461fdc917de2a29a452ccf2657d325b443d", + "reference": "be1fe461fdc917de2a29a452ccf2657d325b443d", "shasum": "" }, "require": { @@ -3356,7 +3356,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.2" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.3" }, "funding": [ { @@ -3364,7 +3364,7 @@ "type": "github" } ], - "time": "2023-05-22T09:04:27+00:00" + "time": "2023-07-26T13:45:28+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/psalm.xml b/psalm.xml index 8330093..b65c414 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,12 +7,16 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedBaselineEntry="true" findUnusedCode="true" + strictBinaryOperands="true" + checkForThrowsInGlobalScope="true" + ignoreInternalFunctionFalseReturn="false" + ignoreInternalFunctionNullReturn ="false" + findUnusedVariablesAndParams="true" + findUnusedPsalmSuppress="true" + restrictReturnTypes="true" > - - - diff --git a/src/App.php b/src/App.php index 0d463e2..0b9fd51 100644 --- a/src/App.php +++ b/src/App.php @@ -81,7 +81,7 @@ class App */ public function getConfig(string $key): mixed { - /** @var mixed */ + /** @var string|array */ $ret = $this->config->get($key); $this->logger->debug("Fetching configuration key", [$key, $ret]); return $ret; diff --git a/src/Rclone/Rclone.php b/src/Rclone/Rclone.php index 6d96d74..ca0844a 100644 --- a/src/Rclone/Rclone.php +++ b/src/Rclone/Rclone.php @@ -14,7 +14,7 @@ use Exception; * * Installation of rclone is required. * Configuration of the mounts must be done before use. - * Tested using rclone v1.53.3-DEV + * Tested using rclone v1.62.2 */ class Rclone { @@ -97,7 +97,7 @@ class Rclone $options[] = $dest; foreach ($additionalOptions as $key => $value) { - $options[] = '--' . $key; + $options[] = '--' . (string)$key; $options[] = $value; } diff --git a/tests/Rclone/RcloneTest.php b/tests/Rclone/RcloneTest.php index b061f66..7b22882 100644 --- a/tests/Rclone/RcloneTest.php +++ b/tests/Rclone/RcloneTest.php @@ -48,7 +48,7 @@ final class RcloneTest extends TestCase $this->expectException(\Exception::class); $this->expectExceptionMessage("ERROR"); - $size = $rclone->getSize('temp/bogus-source'); + $rclone->getSize('temp/bogus-source'); $this->fail('Exception was not thrown'); }