Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -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);
Expand All @@ -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
}
Expand Down
16 changes: 3 additions & 13 deletions lib/AppInfo/BeforeShareCreatedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -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;
Expand All @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion lib/AppInfo/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -15,6 +15,7 @@

/** @template-implements IEventListener<BeforeTemplateRenderedEvent|Event> */
class BeforeTemplateRenderedListener implements IEventListener {
#[\Override]
public function handle(Event $event): void {
if (!($event instanceof BeforeTemplateRenderedEvent)) {
return;
Expand Down
10 changes: 3 additions & 7 deletions lib/AppInfo/Capabilities.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand All @@ -14,13 +14,9 @@
use OCP\Capabilities\ICapability;

class Capabilities implements ICapability {
public function __construct(
private IAppManager $appManager,
private NoteUtil $noteUtil,
private ?string $userId,
) {
}


#[\Override]
public function getCapabilities(): array {
return [
Application::APP_ID => [
Expand Down
21 changes: 10 additions & 11 deletions lib/AppInfo/DashboardWidget.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand All @@ -25,58 +25,55 @@ class DashboardWidget implements IWidget, IButtonWidget, IAPIWidget, IIconWidget
private IL10N $l10n;
private NotesService $notesService;

public function __construct(
IURLGenerator $url,
IL10N $l10n,
NotesService $notesService,
) {
$this->url = $url;
$this->l10n = $l10n;
$this->notesService = $notesService;
}

/**
* @inheritDoc
*/
#[\Override]
public function getId(): string {
return 'notes';
}

/**
* @inheritDoc
*/
#[\Override]
public function getTitle(): string {
return $this->l10n->t('Notes');
}

/**
* @inheritDoc
*/
#[\Override]
public function getOrder(): int {
return 30;
}

/**
* @inheritDoc
*/
#[\Override]
public function getIconClass(): string {
return 'icon-notes';
}

/**
* @inheritDoc
*/
#[\Override]
public function getUrl(): ?string {
return $this->url->linkToRouteAbsolute('notes.page.index');
}

/**
* @inheritDoc
*/
#[\Override]
public function load(): void {
\OCP\Util::addScript('notes', 'notes-dashboard');
}

#[\Override]
public function getWidgetButtons(string $userId): array {
$buttons = [
new WidgetButton(
Expand All @@ -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);
Expand All @@ -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'));
}
Expand Down
16 changes: 5 additions & 11 deletions lib/AppInfo/SearchProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand All @@ -24,24 +24,17 @@ class SearchProvider implements IProvider {
private NotesService $notesService;
private IURLGenerator $url;

public function __construct(
Util $util,
NotesService $notesService,
IURLGenerator $url,
) {
$this->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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/ChunkCursor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/ETagDoesNotMatchException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down
14 changes: 1 addition & 13 deletions lib/Controller/Helper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down Expand Up @@ -28,18 +28,6 @@ class Helper {
public LoggerInterface $logger;
private IUserSession $userSession;

public function __construct(
NotesService $notesService,
MetaService $metaService,
IUserSession $userSession,
LoggerInterface $logger,
) {
$this->notesService = $notesService;
$this->metaService = $metaService;
$this->userSession = $userSession;
$this->logger = $logger;
}

public function getUID() : string {
return $this->userSession->getUser()->getUID();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/NotesApiController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down
5 changes: 2 additions & 3 deletions lib/Controller/NotesController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down Expand Up @@ -264,7 +264,6 @@ public function updateProperty(
$favorite
) {
$note = $this->notesService->get($this->helper->getUID(), $id);
$result = null;
switch ($property) {
case 'modified':
if ($modified !== null) {
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @method integer getLastUpdate()
* @method void setLastUpdate(integer $value)
* @method string getEtag()
* @method void setEtag(string $value)
* @final method void setEtag(string $value)
* @method string getContentEtag()
* @method void setContentEtag(string $value)
* @method string getFileEtag()
Expand Down
8 changes: 3 additions & 5 deletions lib/Db/MetaMapper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
final <?php

declare(strict_types=1);

Expand All @@ -14,11 +14,9 @@
use OCP\IDBConnection;

class MetaMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'notes_meta');
}

public function getAll($userId) : array {

public function getAll(string $userId) : array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
Expand Down
Loading
Loading