From f992856476fe5ccbc63e7b1dfaed946e88c8fd29 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 18 Jun 2023 00:26:54 +0200 Subject: [PATCH] remove useless @var --- lib/Db/BookmarkMapper.php | 5 +++-- lib/Db/PreferenceMapper.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Db/BookmarkMapper.php b/lib/Db/BookmarkMapper.php index d7fea1e..4f76308 100644 --- a/lib/Db/BookmarkMapper.php +++ b/lib/Db/BookmarkMapper.php @@ -65,7 +65,6 @@ class BookmarkMapper extends ReaderMapper { * @return ReaderEntity the newly created or updated bookmark */ 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)) { @@ -88,12 +87,14 @@ class BookmarkMapper extends ReaderMapper { $bookmark->setContent($content ?? ''); $this->insert($bookmark); - } else { + } elseif ($result[0] instanceof Bookmark) { $bookmark = $result[0]; $bookmark->setValue($value); $bookmark->setContent($content ?? ''); $this->update($bookmark); + } else { + $bookmark = new Bookmark(); } return $bookmark; diff --git a/lib/Db/PreferenceMapper.php b/lib/Db/PreferenceMapper.php index d213397..07e8abe 100644 --- a/lib/Db/PreferenceMapper.php +++ b/lib/Db/PreferenceMapper.php @@ -57,7 +57,6 @@ class PreferenceMapper extends ReaderMapper { * @return ReaderEntity the newly created or updated preference */ public function set(string $scope, int $fileId, string $name, string $value): ReaderEntity { - /** @var Preference[] $result */ $result = $this->get($scope, $fileId, $name); if(empty($result)) { @@ -69,11 +68,13 @@ class PreferenceMapper extends ReaderMapper { $preference->setValue($value); $this->insert($preference); - } else { + } elseif ($result[0] instanceof Preference) { $preference = $result[0]; $preference->setValue($value); $this->update($preference); + } else { + $preference = new Preference(); } return $preference;