From 4c3e5138c53c0eb7593258b3cb10cb5501eb4c27 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 07:43:55 +0000 Subject: [PATCH 1/2] Chore(deps-dev): Bump psalm/phar from 5.26.1 to 6.16.1 Bumps [psalm/phar](https://github.com/psalm/phar) from 5.26.1 to 6.16.1. - [Release notes](https://github.com/psalm/phar/releases) - [Commits](https://github.com/psalm/phar/compare/5.26.1...6.16.1) --- updated-dependencies: - dependency-name: psalm/phar dependency-version: 6.16.1 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- composer.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 0996bb927..3e44af317 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "nextcloud/ocp": "dev-stable33", "phan/phan": "^6", "php-cs-fixer/shim": "3.95.3", - "psalm/phar": "^5.26", + "psalm/phar": "^6.16", "squizlabs/php_codesniffer": "^4", "staabm/annotate-pull-request-from-checkstyle": "^1.1.0" }, diff --git a/composer.lock b/composer.lock index 40014a25a..a5a3fc4ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c5d2b96ae5f4e7a626560239a3c11a14", + "content-hash": "a844cfa45cf4abaeba622c4061b17885", "packages": [], "packages-dev": [ { @@ -1323,20 +1323,20 @@ }, { "name": "psalm/phar", - "version": "5.26.1", + "version": "6.16.1", "source": { "type": "git", "url": "https://github.com/psalm/phar.git", - "reference": "8a38e7ad04499a0ccd2c506fd1da6fc01fff4547" + "reference": "11c6b55449667837fc07bb2a456c45a137c05ecd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/psalm/phar/zipball/8a38e7ad04499a0ccd2c506fd1da6fc01fff4547", - "reference": "8a38e7ad04499a0ccd2c506fd1da6fc01fff4547", + "url": "https://api.github.com/repos/psalm/phar/zipball/11c6b55449667837fc07bb2a456c45a137c05ecd", + "reference": "11c6b55449667837fc07bb2a456c45a137c05ecd", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.2" }, "conflict": { "vimeo/psalm": "*" @@ -1352,9 +1352,9 @@ "description": "Composer-based Psalm Phar", "support": { "issues": "https://github.com/psalm/phar/issues", - "source": "https://github.com/psalm/phar/tree/5.26.1" + "source": "https://github.com/psalm/phar/tree/6.16.1" }, - "time": "2024-09-09T16:22:43+00:00" + "time": "2026-03-19T11:11:23+00:00" }, { "name": "psr/clock", From 1399d3a766180063e6dbe413235f57e4afd611b4 Mon Sep 17 00:00:00 2001 From: "Enjeck C." Date: Mon, 22 Jun 2026 06:21:40 +0100 Subject: [PATCH 2/2] fix: run psalm fixes Signed-off-by: Enjeck C. --- lib/AppInfo/Application.php | 8 ++-- lib/AppInfo/BeforeShareCreatedListener.php | 16 ++----- .../BeforeTemplateRenderedListener.php | 3 +- lib/AppInfo/Capabilities.php | 10 ++-- lib/AppInfo/DashboardWidget.php | 21 ++++---- lib/AppInfo/SearchProvider.php | 16 ++----- lib/Controller/ChunkCursor.php | 2 +- lib/Controller/ETagDoesNotMatchException.php | 2 +- lib/Controller/Helper.php | 14 +----- lib/Controller/NotesApiController.php | 2 +- lib/Controller/NotesController.php | 5 +- lib/Controller/PageController.php | 2 +- lib/Controller/SettingsController.php | 2 +- lib/Db/Meta.php | 2 +- lib/Db/MetaMapper.php | 8 ++-- lib/Listener/NoteFileEventsListener.php | 8 ++-- lib/Migration/Cleanup.php | 4 +- lib/Migration/EditorHint.php | 7 ++- .../Version3005Date20200528204430.php | 9 +++- .../Version3005Date20200528204431.php | 9 +++- lib/Reference/NoteReferenceProvider.php | 22 ++++----- lib/Service/ImageNotWritableException.php | 2 +- lib/Service/InsufficientStorageException.php | 2 +- lib/Service/MetaNote.php | 2 +- lib/Service/MetaService.php | 7 +-- lib/Service/Note.php | 2 +- lib/Service/NoteDoesNotExistException.php | 2 +- lib/Service/NoteNotWritableException.php | 2 +- lib/Service/NoteUtil.php | 24 ++-------- lib/Service/NotesFolderException.php | 2 +- lib/Service/NotesService.php | 25 ++++------ lib/Service/SettingsService.php | 48 +------------------ lib/Service/TagService.php | 10 ++-- lib/Service/Util.php | 10 +--- 34 files changed, 102 insertions(+), 208 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index cafb4a21a..7079588ed 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightTfinal ext: 2020 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -28,10 +28,7 @@ class Application extends App implements IBootstrap { public const APP_ID = 'notes'; public static array $API_VERSIONS = [ '0.2', '1.3', '1.4' ]; - public function __construct(array $urlParams = []) { - parent::__construct(self::APP_ID, $urlParams); - } - + #[\Override] public function register(IRegistrationContext $context): void { $context->registerCapability(Capabilities::class); $context->registerSearchProvider(SearchProvider::class); @@ -45,6 +42,7 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(BeforeNodeRenamedEvent::class, NoteFileEventsListener::class); } + #[\Override] public function boot(IBootContext $context): void { // Intentionally empty } diff --git a/lib/AppInfo/BeforeShareCreatedListener.php b/lib/AppInfo/BeforeShareCreatedListener.php index f8d30195b..47796b6ce 100644 --- a/lib/AppInfo/BeforeShareCreatedListener.php +++ b/lib/AppInfo/BeforeShareCreatedListener.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2023 Nextcfinal loud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -25,17 +25,7 @@ class BeforeShareCreatedListener implements IEventListener { private NoteUtil $noteUtil; private LoggerInterface $logger; - public function __construct( - protected IUserManager $userManager, - SettingsService $settings, - NoteUtil $noteUtil, - LoggerInterface $logger, - ) { - $this->settings = $settings; - $this->noteUtil = $noteUtil; - $this->logger = $logger; - } - + #[\Override] public function handle(Event $event): void { if (!($event instanceof BeforeShareCreatedEvent)) { return; @@ -59,7 +49,7 @@ public function overwriteShareTarget(IShare $share): void { $ownerNotesPath = $ownerPath . '/' . $this->settings->get($uidOwner, 'notesPath'); $receiver = $share->getSharedWith(); - $receiverPath = $this->noteUtil->getRoot()->getUserFolder($receiver)->getPath(); + $this->noteUtil->getRoot()->getUserFolder($receiver)->getPath(); $receiverNotesInternalPath = $this->settings->get($receiver, 'notesPath'); $this->noteUtil->getOrCreateNotesFolder($receiver); diff --git a/lib/AppInfo/BeforeTemplateRenderedListener.php b/lib/AppInfo/BeforeTemplateRenderedListener.php index 2d51fadb7..8291c36ec 100644 --- a/lib/AppInfo/BeforeTemplateRenderedListener.php +++ b/lib/AppInfo/BeforeTemplateRenderedListener.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2020 Nextcloudfinal GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -15,6 +15,7 @@ /** @template-implements IEventListener */ class BeforeTemplateRenderedListener implements IEventListener { + #[\Override] public function handle(Event $event): void { if (!($event instanceof BeforeTemplateRenderedEvent)) { return; diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php index da81eeab6..948014e70 100644 --- a/lib/AppInfo/Capabilities.php +++ b/lib/AppInfo/Capabilities.php @@ -1,4 +1,4 @@ - [ diff --git a/lib/AppInfo/DashboardWidget.php b/lib/AppInfo/DashboardWidget.php index ddf7c6189..19ab04817 100644 --- a/lib/AppInfo/DashboardWidget.php +++ b/lib/AppInfo/DashboardWidget.php @@ -1,4 +1,4 @@ -url = $url; - $this->l10n = $l10n; - $this->notesService = $notesService; - } - /** * @inheritDoc */ + #[\Override] public function getId(): string { return 'notes'; } @@ -45,6 +36,7 @@ public function getId(): string { /** * @inheritDoc */ + #[\Override] public function getTitle(): string { return $this->l10n->t('Notes'); } @@ -52,6 +44,7 @@ public function getTitle(): string { /** * @inheritDoc */ + #[\Override] public function getOrder(): int { return 30; } @@ -59,6 +52,7 @@ public function getOrder(): int { /** * @inheritDoc */ + #[\Override] public function getIconClass(): string { return 'icon-notes'; } @@ -66,6 +60,7 @@ public function getIconClass(): string { /** * @inheritDoc */ + #[\Override] public function getUrl(): ?string { return $this->url->linkToRouteAbsolute('notes.page.index'); } @@ -73,10 +68,12 @@ public function getUrl(): ?string { /** * @inheritDoc */ + #[\Override] public function load(): void { \OCP\Util::addScript('notes', 'notes-dashboard'); } + #[\Override] public function getWidgetButtons(string $userId): array { $buttons = [ new WidgetButton( @@ -95,6 +92,7 @@ public function getWidgetButtons(string $userId): array { return $buttons; } + #[\Override] public function getItems(string $userId, ?string $since = null, int $limit = 7): array { $notes = $this->notesService->getTopNotes($userId); $notes = array_slice($notes, 0, $limit); @@ -112,6 +110,7 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7): }, $notes)); } + #[\Override] public function getIconUrl(): string { return $this->url->getAbsoluteURL($this->url->imagePath('notes', 'notes-dark.svg')); } diff --git a/lib/AppInfo/SearchProvider.php b/lib/AppInfo/SearchProvider.php index 562179df7..aeb77b0cb 100644 --- a/lib/AppInfo/SearchProvider.php +++ b/lib/AppInfo/SearchProvider.php @@ -1,4 +1,4 @@ -util = $util; - $this->notesService = $notesService; - $this->url = $url; - } - + #[\Override] public function getId(): string { return Application::APP_ID; } + #[\Override] public function getName(): string { return $this->util->l10n->t('Notes'); } + #[\Override] public function getOrder(string $route, array $routeParameters): int { if (strpos($route, 'files' . '.') === 0) { return 25; @@ -51,6 +44,7 @@ public function getOrder(string $route, array $routeParameters): int { return 4; } + #[\Override] public function search(IUser $user, ISearchQuery $query): SearchResult { $notes = $this->notesService->search($user->getUID(), $query->getTerm()); // sort by modified time diff --git a/lib/Controller/ChunkCursor.php b/lib/Controller/ChunkCursor.php index 9527a04f9..eda05b9f3 100644 --- a/lib/Controller/ChunkCursor.php +++ b/lib/Controller/ChunkCursor.php @@ -1,4 +1,4 @@ -notesService = $notesService; - $this->metaService = $metaService; - $this->userSession = $userSession; - $this->logger = $logger; - } - public function getUID() : string { return $this->userSession->getUser()->getUID(); } diff --git a/lib/Controller/NotesApiController.php b/lib/Controller/NotesApiController.php index a9a201451..78d481c9d 100644 --- a/lib/Controller/NotesApiController.php +++ b/lib/Controller/NotesApiController.php @@ -1,4 +1,4 @@ -notesService->get($this->helper->getUID(), $id); - $result = null; switch ($property) { case 'modified': if ($modified !== null) { @@ -385,7 +384,7 @@ public function uploadFile(int $noteid): JSONResponse { }); } - private function inLockScope(Note $note, callable $callback) { + private function inLockScope(Note $note, callable $callback): void { $isRichText = $this->settingsService->get($this->helper->getUID(), 'noteMode') === 'rich'; $lockContext = new LockContext( $note->getFile(), diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index cdc3eba38..e6352be81 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -1,4 +1,4 @@ -db->getQueryBuilder(); $qb->select('*') ->from($this->tableName) diff --git a/lib/Listener/NoteFileEventsListener.php b/lib/Listener/NoteFileEventsListener.php index 64c3af425..60e667458 100644 --- a/lib/Listener/NoteFileEventsListener.php +++ b/lib/Listener/NoteFileEventsListener.php @@ -4,7 +4,7 @@ /** * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later + * SPDX-License-Identifier: AGPfinal L-3.0-or-later */ namespace OCA\Notes\Listener; @@ -20,11 +20,9 @@ /** @template-implements IEventListener */ class NoteFileEventsListener implements IEventListener { - public function __construct( - private MetaService $metaService, - ) { - } + + #[\Override] public function handle(Event $event): void { if ($event instanceof BeforeNodeWrittenEvent) { $this->onFileModified($event->getNode()); diff --git a/lib/Migration/Cleanup.php b/lib/Migration/Cleanup.php index 028b8d553..7ede8f9f2 100644 --- a/lib/Migration/Cleanup.php +++ b/lib/Migration/Cleanup.php @@ -1,4 +1,4 @@ -metaMapper->deleteAll(); } diff --git a/lib/Migration/EditorHint.php b/lib/Migration/EditorHint.php index c1ef264c8..39a426d3a 100644 --- a/lib/Migration/EditorHint.php +++ b/lib/Migration/EditorHint.php @@ -1,4 +1,4 @@ -userManager = $userManager; } + #[\Override] public function getName() { return 'Show a hint about the new editor to existing users'; } + #[\Override] + /** + * @return void + */ public function run(IOutput $output) { $appVersion = $this->config->getAppValue('notes', 'installed_version'); diff --git a/lib/Migration/Version3005Date20200528204430.php b/lib/Migration/Version3005Date20200528204430.php index 78373bc25..73b39b618 100644 --- a/lib/Migration/Version3005Date20200528204430.php +++ b/lib/Migration/Version3005Date20200528204430.php @@ -1,4 +1,4 @@ -userId = $userSession->getUser()?->getUID(); - $this->l10n = $l10n->get('notes'); - $this->logger = $logger; - } - + #[\Override] public function matchReference(string $referenceText): bool { return $this->getNoteLinkId($referenceText) !== null; } @@ -54,6 +43,7 @@ private function getNoteLinkId(string $referenceText): ?int { return null; } + #[\Override] public function resolveReference(string $referenceText): ?IReference { $noteId = $this->getNoteLinkId($referenceText); $reference = new Reference($referenceText); @@ -75,26 +65,32 @@ public function resolveReference(string $referenceText): ?IReference { return null; } + #[\Override] public function getCachePrefix(string $referenceId): string { return $referenceId; } + #[\Override] public function getCacheKey(string $referenceId): string { return $this->userId ?? ''; } + #[\Override] public function getId(): string { return 'notes' ; } + #[\Override] public function getTitle(): string { return $this->l10n->t('Notes'); } + #[\Override] public function getOrder(): int { return 10; } + #[\Override] public function getIconUrl(): string { return $this->urlGenerator->imagePath('notes', 'notes.svg'); } diff --git a/lib/Service/ImageNotWritableException.php b/lib/Service/ImageNotWritableException.php index 0a85baa2e..41649636b 100644 --- a/lib/Service/ImageNotWritableException.php +++ b/lib/Service/ImageNotWritableException.php @@ -1,4 +1,4 @@ -metaMapper = $metaMapper; - $this->util = $util; - } - public function deleteByNote(int $id) : void { $this->metaMapper->deleteByNote($id); } diff --git a/lib/Service/Note.php b/lib/Service/Note.php index e50487f71..0fb7be846 100644 --- a/lib/Service/Note.php +++ b/lib/Service/Note.php @@ -1,4 +1,4 @@ -util = $util; - $this->root = $root; - $this->db = $db; - $this->tagService = $tagService; - $this->shareManager = $shareManager; - $this->userSession = $userSession; - $this->settingsService = $settingsService; - } - public function getRoot() : IRootFolder { return $this->root; } - public function getPathForUser(File $file) { + public function getPathForUser(File $file): string|null { $userFolder = $this->root->getUserFolder($this->userSession->getUser()->getUID()); return $userFolder->getRelativePath($file->getPath()); } @@ -161,7 +143,7 @@ private function sanitisePath(string $str) : string { return trim($str); } - public function stripMarkdown(string $str) : string { + public function stripMarkdown(string $str) : string|null { // prepare content: remove markdown characters and empty spaces $str = preg_replace("/^\s*[*+-]\s+/mu", '', $str); // list item $str = preg_replace("/^#+\s+(.*?)\s*#*$/mu", '$1', $str); // headline diff --git a/lib/Service/NotesFolderException.php b/lib/Service/NotesFolderException.php index e68155909..a9d20f679 100644 --- a/lib/Service/NotesFolderException.php +++ b/lib/Service/NotesFolderException.php @@ -1,4 +1,4 @@ -metaService = $metaService; - $this->settings = $settings; - $this->noteUtil = $noteUtil; - } - public function getAll(string $userId, bool $autoCreateNotesFolder = false) : array { $customExtension = $this->getCustomExtension($userId); try { @@ -141,7 +131,7 @@ public function create(string $userId, string $title, string $category) : Note { /** * @throws NoteDoesNotExistException if note does not exist */ - public function delete(string $userId, int $id) { + public function delete(string $userId, int $id): void { $customExtension = $this->getCustomExtension($userId); $notesFolder = $this->getNotesFolder($userId); $file = self::getFileById($customExtension, $notesFolder, $id); @@ -279,7 +269,7 @@ private static function isNote(FileInfo $file, string $customExtension) : bool { /** * Retrieve the value of user defined files extension */ - private function getCustomExtension(string $userId) { + private function getCustomExtension(string $userId): string { $suffix = $this->settings->get($userId, 'customSuffix'); return ltrim($suffix, '.'); } @@ -323,11 +313,16 @@ public function getAttachment(string $userId, int $noteid, string $path) : File * @param $userId * @param $noteid * @param $fileDataArray + * * @throws NotPermittedException * @throws ImageNotWritableException - * https://github.com/nextcloud/deck/blob/master/lib/Service/AttachmentService.php + * https://github.com/nextcloud/deck/blob/master/lib/Service/AttachmentService.php + * + * @return string[] + * + * @psalm-return array{filename: string} */ - public function createImage(string $userId, int $noteid, $fileDataArray) { + public function createImage(string $userId, int $noteid, array $fileDataArray): array { $note = $this->get($userId, $noteid); $notesFolder = $this->getNotesFolder($userId); $parent = $this->noteUtil->getCategoryFolder($notesFolder, $note->getCategory()); diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index b8f7d0a93..05685e77b 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -1,4 +1,4 @@ -config = $config; - $this->l10n = $l10n; - $this->root = $root; - $this->appManager = $appManager; - $this->attrs = [ - 'fileSuffix' => $this->getListAttrs('fileSuffix', [...$this->defaultSuffixes, 'custom']), - 'notesPath' => [ - 'default' => function (string $uid) { - return $this->getDefaultNotesNode($uid)['path']; - }, - 'validate' => function ($value) { - $value = str_replace([ '/', '\\' ], DIRECTORY_SEPARATOR, $value); - $parts = explode(DIRECTORY_SEPARATOR, $value); - $path = []; - foreach ($parts as $part) { - if ($part === '..') { - array_pop($path); - } elseif (strlen($part) && $part !== '.') { - array_push($path, $part); - } - } - return implode(DIRECTORY_SEPARATOR, $path); - }, - ], - 'noteMode' => $this->getListAttrs('noteMode', $this->getAvailableEditorModes()), - 'customSuffix' => [ - 'default' => $this->defaultSuffixes[0], - 'validate' => function ($value) { - $out = ltrim(preg_replace('/[^A-Za-z0-9.-]/', '', $value), '.'); - if (empty($out)) { - $out = substr($this->defaultSuffixes[0], 1); - } - return '.' . $out; - }, - ], - ]; - } - private function getListAttrs(string $attributeName, array $values) : array { $default = $this->config->getAppValue(Application::APP_ID, $attributeName, $values[0]); @@ -182,7 +138,7 @@ private function getSettingsFromDB(string $uid) : \stdClass { return $settings; } - public function getAll(string $uid, $saveInitial = false) : \stdClass { + public function getAll(string $uid, bool $saveInitial = false) : \stdClass { $settings = $this->getSettingsFromDB($uid); // use default for empty settings $toBeSaved = false; diff --git a/lib/Service/TagService.php b/lib/Service/TagService.php index 54d975221..817a4871c 100644 --- a/lib/Service/TagService.php +++ b/lib/Service/TagService.php @@ -1,4 +1,4 @@ -tagger = $tagManager->load('files'); - } - /** * @param list $fileIds * @return void @@ -28,7 +24,7 @@ public function loadTags(array $fileIds) : void { $this->cachedTags = $this->tagger->getTagsForObjects($fileIds); } - public function isFavorite($fileId) : bool { + public function isFavorite(int $fileId) : bool { $alltags = $this->cachedTags; if (!is_array($alltags)) { $alltags = $this->tagger->getTagsForObjects([$fileId]); @@ -36,7 +32,7 @@ public function isFavorite($fileId) : bool { return array_key_exists($fileId, $alltags) && in_array(ITags::TAG_FAVORITE, $alltags[$fileId]); } - public function setFavorite($fileId, $favorite) : void { + public function setFavorite(int $fileId, bool $favorite) : void { if ($favorite) { $this->tagger->addToFavorites($fileId); } else { diff --git a/lib/Service/Util.php b/lib/Service/Util.php index 2f025ab79..cb927c148 100644 --- a/lib/Service/Util.php +++ b/lib/Service/Util.php @@ -1,4 +1,4 @@ -l10n = $l10n; - $this->logger = $logger; - } - public static function retryIfLocked(callable $f, int $maxRetries = 5, int $sleep = 1) { for ($try = 1; $try <= $maxRetries; $try++) { try {