diff --git a/appinfo/routes.php b/appinfo/routes.php index 558315734..cefc4eeb9 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -103,7 +103,6 @@ ], ////////// A T T A C H M E N T S ////////// - [ 'name' => 'notes#getAttachment', 'url' => '/notes/{noteid}/attachment', diff --git a/lib/Controller/ETagDoesNotMatchException.php b/lib/Controller/ETagDoesNotMatchException.php index 44e3c9aec..079cbe60f 100644 --- a/lib/Controller/ETagDoesNotMatchException.php +++ b/lib/Controller/ETagDoesNotMatchException.php @@ -13,9 +13,8 @@ use OCA\Notes\Service\Note; class ETagDoesNotMatchException extends Exception { - public Note $note; - - public function __construct(Note $note) { - $this->note = $note; + public function __construct( + public Note $note, + ) { } } diff --git a/lib/Controller/Helper.php b/lib/Controller/Helper.php index df5dfd9d5..97b3d10e2 100644 --- a/lib/Controller/Helper.php +++ b/lib/Controller/Helper.php @@ -23,21 +23,12 @@ use Psr\Log\LoggerInterface; class Helper { - private NotesService $notesService; - private MetaService $metaService; - public LoggerInterface $logger; - private IUserSession $userSession; - public function __construct( - NotesService $notesService, - MetaService $metaService, - IUserSession $userSession, - LoggerInterface $logger, + private NotesService $notesService, + private MetaService $metaService, + private IUserSession $userSession, + public LoggerInterface $logger, ) { - $this->notesService = $notesService; - $this->metaService = $metaService; - $this->userSession = $userSession; - $this->logger = $logger; } public function getUID() : string { diff --git a/lib/Controller/NotesApiController.php b/lib/Controller/NotesApiController.php index a9a201451..7b176e119 100644 --- a/lib/Controller/NotesApiController.php +++ b/lib/Controller/NotesApiController.php @@ -25,27 +25,16 @@ use OCP\IRequest; class NotesApiController extends ApiController { - private NotesService $service; - private MetaService $metaService; - private SettingsService $settingsService; - private Helper $helper; - private IMimeTypeDetector $mimeTypeDetector; - public function __construct( string $AppName, IRequest $request, - NotesService $service, - MetaService $metaService, - SettingsService $settingsService, - Helper $helper, - IMimeTypeDetector $mimeTypeDetector, + private NotesService $service, + private MetaService $metaService, + private SettingsService $settingsService, + private Helper $helper, + private IMimeTypeDetector $mimeTypeDetector, ) { parent::__construct($AppName, $request); - $this->service = $service; - $this->metaService = $metaService; - $this->settingsService = $settingsService; - $this->helper = $helper; - $this->mimeTypeDetector = $mimeTypeDetector; } /** @@ -316,5 +305,4 @@ public function uploadFile(int $noteid): JSONResponse { ); }); } - } diff --git a/lib/Controller/NotesController.php b/lib/Controller/NotesController.php index 9eb9761c2..aed5218fe 100644 --- a/lib/Controller/NotesController.php +++ b/lib/Controller/NotesController.php @@ -28,33 +28,18 @@ use OCP\IRequest; class NotesController extends Controller { - private NotesService $notesService; - private SettingsService $settingsService; - private ILockManager $lockManager; - private Helper $helper; - private IConfig $settings; - private IL10N $l10n; - private IMimeTypeDetector $mimeTypeDetector; - public function __construct( string $AppName, IRequest $request, - NotesService $notesService, - ILockManager $lockManager, - SettingsService $settingsService, - Helper $helper, - IConfig $settings, - IL10N $l10n, - IMimeTypeDetector $mimeTypeDetector, + private NotesService $notesService, + private ILockManager $lockManager, + private SettingsService $settingsService, + private Helper $helper, + private IConfig $settings, + private IL10N $l10n, + private IMimeTypeDetector $mimeTypeDetector, ) { parent::__construct($AppName, $request); - $this->notesService = $notesService; - $this->settingsService = $settingsService; - $this->lockManager = $lockManager; - $this->helper = $helper; - $this->settings = $settings; - $this->l10n = $l10n; - $this->mimeTypeDetector = $mimeTypeDetector; } /** diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index cdc3eba38..b4312bd3a 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -33,33 +33,18 @@ use Psr\Log\LoggerInterface; class PageController extends Controller { - private NotesService $notesService; - private IConfig $config; - private IUserSession $userSession; - private IURLGenerator $urlGenerator; - private IEventDispatcher $eventDispatcher; - private IInitialState $initialState; - private LoggerInterface $logger; - public function __construct( string $AppName, IRequest $request, - NotesService $notesService, - IConfig $config, - IUserSession $userSession, - IURLGenerator $urlGenerator, - IEventDispatcher $eventDispatcher, - IInitialState $initialState, - LoggerInterface $logger, + private NotesService $notesService, + private IConfig $config, + private IUserSession $userSession, + private IURLGenerator $urlGenerator, + private IEventDispatcher $eventDispatcher, + private IInitialState $initialState, + private LoggerInterface $logger, ) { parent::__construct($AppName, $request); - $this->notesService = $notesService; - $this->config = $config; - $this->userSession = $userSession; - $this->urlGenerator = $urlGenerator; - $this->eventDispatcher = $eventDispatcher; - $this->initialState = $initialState; - $this->logger = $logger; } /** diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 7fc083483..eff410228 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -17,18 +17,13 @@ use OCP\IUserSession; class SettingsController extends Controller { - private SettingsService $service; - private IUserSession $userSession; - public function __construct( string $appName, IRequest $request, - SettingsService $service, - IUserSession $userSession, + private SettingsService $service, + private IUserSession $userSession, ) { parent::__construct($appName, $request); - $this->service = $service; - $this->userSession = $userSession; } private function getUID(): string { diff --git a/lib/Migration/Cleanup.php b/lib/Migration/Cleanup.php index 028b8d553..892e2f5c4 100644 --- a/lib/Migration/Cleanup.php +++ b/lib/Migration/Cleanup.php @@ -14,10 +14,9 @@ use OCP\Migration\IRepairStep; class Cleanup implements IRepairStep { - private MetaMapper $metaMapper; - - public function __construct(MetaMapper $metaMapper) { - $this->metaMapper = $metaMapper; + public function __construct( + private MetaMapper $metaMapper, + ) { } /* diff --git a/lib/Migration/EditorHint.php b/lib/Migration/EditorHint.php index c1ef264c8..31ef04960 100644 --- a/lib/Migration/EditorHint.php +++ b/lib/Migration/EditorHint.php @@ -17,11 +17,10 @@ use OCP\Migration\IRepairStep; class EditorHint implements IRepairStep { - private IConfig $config; - private IUserManager $userManager; - public function __construct(IConfig $config, IUserManager $userManager) { - $this->config = $config; - $this->userManager = $userManager; + public function __construct( + private IConfig $config, + private IUserManager $userManager, + ) { } public function getName() { diff --git a/lib/Service/NotesService.php b/lib/Service/NotesService.php index ece3a69d2..644b61f0c 100644 --- a/lib/Service/NotesService.php +++ b/lib/Service/NotesService.php @@ -16,18 +16,11 @@ use OCP\Files\NotPermittedException; class NotesService { - private MetaService $metaService; - private SettingsService $settings; - private NoteUtil $noteUtil; - public function __construct( - MetaService $metaService, - SettingsService $settings, - NoteUtil $noteUtil, + private MetaService $metaService, + private SettingsService $settings, + private NoteUtil $noteUtil, ) { - $this->metaService = $metaService; - $this->settings = $settings; - $this->noteUtil = $noteUtil; } public function getAll(string $userId, bool $autoCreateNotesFolder = false) : array { @@ -94,6 +87,7 @@ function (Note $note) use ($terms) : bool { } )); } + private function searchTermsInNote(Note $note, array $terms) : bool { try { $d = $note->getData(); @@ -108,6 +102,7 @@ private function searchTermsInNote(Note $note, array $terms) : bool { return false; } } + private function searchTermInData(array $strings, string $term) : bool { foreach ($strings as $str) { if (stripos($str, $term) !== false) { diff --git a/lib/Service/Util.php b/lib/Service/Util.php index 2f025ab79..55dd7f305 100644 --- a/lib/Service/Util.php +++ b/lib/Service/Util.php @@ -13,15 +13,10 @@ use Psr\Log\LoggerInterface; class Util { - public IL10N $l10n; - public LoggerInterface $logger; - public function __construct( - IL10N $l10n, - LoggerInterface $logger, + public IL10N $l10n, + public LoggerInterface $logger, ) { - $this->l10n = $l10n; - $this->logger = $logger; } public static function retryIfLocked(callable $f, int $maxRetries = 5, int $sleep = 1) {