From 2e2bd4a32d77f853cb7c90f2ee7a6ee6ed15be16 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 18 Jun 2023 00:08:38 +0200 Subject: [PATCH] fix little issues --- composer.json | 2 +- lib/AppInfo/Application.php | 9 +++++---- lib/Db/BookmarkMapper.php | 6 +++--- lib/Service/BookmarkService.php | 4 ++-- psalm.xml | 2 ++ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 67508bf..99a38c0 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l", "cs:check": "php-cs-fixer fix --dry-run --diff", "cs:fix": "php-cs-fixer fix", - "psalm:check": "psalm.phar --threads=1 --no-cache", + "psalm:check": "psalm.phar --threads=1 --no-cache --show-info=true", "psalm:fix": "psalm.phar --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType" }, "config": { diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index d257f31..8810fbd 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -27,10 +27,11 @@ class Application extends App { /** @psalm-suppress DeprecatedInterface */ $container = $this->getContainer(); - $hooks = new Hooks( - $container->get(IRootFolder::class), - $container->get(IDBConnection::class), - ); + /** @var IRootFolder $rootFolder */ + $rootFolder = $container->get(IRootFolder::class); + /** @var IDBConnection $dbConnection */ + $dbConnection = $container->get(IDBConnection::class); + $hooks = new Hooks($rootFolder, $dbConnection); $hooks->register(); /** @psalm-suppress DeprecatedMethod */ diff --git a/lib/Db/BookmarkMapper.php b/lib/Db/BookmarkMapper.php index 479c3a1..d7fea1e 100644 --- a/lib/Db/BookmarkMapper.php +++ b/lib/Db/BookmarkMapper.php @@ -57,20 +57,20 @@ class BookmarkMapper extends ReaderMapper { * @brief write bookmark to database * * @param int $fileId - * @param ?string $name + * @param string $name * @param string $value * @param ?string $type * @param ?string $content * * @return ReaderEntity the newly created or updated bookmark */ - public function set(int $fileId, ?string $name = null, string $value, ?string $type = null, ?string $content = null): ReaderEntity { + public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity { /** @var Bookmark[] $result */ $result = $this->get($fileId, $name); if(empty($result)) { // anonymous bookmarks are named after their contents - if (null === $name) { + if (empty($name)) { $name = $value; } diff --git a/lib/Service/BookmarkService.php b/lib/Service/BookmarkService.php index eacf74b..45d483d 100644 --- a/lib/Service/BookmarkService.php +++ b/lib/Service/BookmarkService.php @@ -54,12 +54,12 @@ class BookmarkService extends Service { * position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc * * @param int $fileId - * @param ?string $name + * @param string $name * @param string $value * @param ?string $type * @param ?string $content */ - public function set(int $fileId, ?string $name = null, string $value, ?string $type = null, ?string $content = null): ReaderEntity { + public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity { return $this->bookmarkMapper->set($fileId, $name, $value, $type, $content); } diff --git a/psalm.xml b/psalm.xml index 50fd490..8b21fed 100644 --- a/psalm.xml +++ b/psalm.xml @@ -2,6 +2,8 @@