diff --git a/composer.json b/composer.json index c96a1e51..31617c05 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "autoload": { "psr-4": { - "OCA\\External\\\\": "lib/" + "OCA\\External\\": "lib/" } }, "autoload-dev": { diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php index aa88fe6f..6cabff33 100644 --- a/lib/Controller/APIController.php +++ b/lib/Controller/APIController.php @@ -59,10 +59,8 @@ public function __construct($appName, IRequest $request, SitesManager $sitesMana /** * @NoAdminRequired * @NoCSRFRequired - * - * @return DataResponse */ - public function get() { + public function get(): DataResponse { $data = $this->sitesManager->getSitesToDisplay(); $sites = []; @@ -90,10 +88,8 @@ public function get() { /** * @NoCSRFRequired - * - * @return DataResponse */ - public function getAdmin() { + public function getAdmin(): DataResponse { $icons = array_map(function ($icon) { return [ 'icon' => $icon, @@ -131,17 +127,9 @@ public function getAdmin() { } /** - * @param string $name - * @param string $url - * @param string $lang - * @param string $type - * @param string $device - * @param string $icon * @param string[] $groups - * @param int $redirect - * @return DataResponse */ - public function add($name, $url, $lang, $type, $device, $icon, array $groups, $redirect) { + public function add(string $name, string $url, string $lang, string $type, string $device, string $icon, array $groups, int $redirect): DataResponse { try { return new DataResponse($this->sitesManager->addSite($name, $url, $lang, $type, $device, $icon, $groups, (bool) $redirect)); } catch (InvalidNameException $e) { @@ -162,18 +150,9 @@ public function add($name, $url, $lang, $type, $device, $icon, array $groups, $r } /** - * @param int $id - * @param string $name - * @param string $url - * @param string $lang - * @param string $type - * @param string $device - * @param string $icon * @param string[] $groups - * @param int $redirect - * @return DataResponse */ - public function update($id, $name, $url, $lang, $type, $device, $icon, array $groups, $redirect) { + public function update(int $id, string $name, string $url, string $lang, string $type, string $device, string $icon, array $groups, int $redirect): DataResponse { try { return new DataResponse($this->sitesManager->updateSite($id, $name, $url, $lang, $type, $device, $icon, $groups, (bool) $redirect)); } catch (SiteNotFoundException $e) { @@ -195,11 +174,7 @@ public function update($id, $name, $url, $lang, $type, $device, $icon, array $gr } } - /** - * @param int $id - * @return DataResponse - */ - public function delete($id) { + public function delete(int $id): DataResponse { $this->sitesManager->deleteSite($id); return new DataResponse(); } diff --git a/lib/Controller/IconController.php b/lib/Controller/IconController.php index d0ecfbe6..dc3ff57a 100644 --- a/lib/Controller/IconController.php +++ b/lib/Controller/IconController.php @@ -65,10 +65,8 @@ public function __construct( /** * Upload an icon to the appdata folder - * - * @return DataResponse */ - public function uploadIcon() { + public function uploadIcon(): DataResponse { $icon = $this->request->getUploadedFile('uploadicon'); if (empty($icon)) { return new DataResponse([ @@ -125,11 +123,8 @@ public function uploadIcon() { /** * @NoAdminRequired * @NoCSRFRequired - * - * @param string $icon - * @return FileDisplayResponse */ - public function showIcon($icon) { + public function showIcon(string $icon): FileDisplayResponse { $folder = $this->appData->getFolder('icons'); try { $iconFile = $folder->getFile($icon); @@ -164,11 +159,7 @@ public function showIcon($icon) { return $response; } - /** - * @param string $icon - * @return DataResponse - */ - public function deleteIcon($icon) { + public function deleteIcon(string $icon): DataResponse { $folder = $this->appData->getFolder('icons'); try { @@ -188,12 +179,9 @@ public function deleteIcon($icon) { } /** - * @param ISimpleFolder $folder - * @param string $file - * @return ISimpleFile * @throws NotFoundException */ - protected function getDefaultIcon(ISimpleFolder $folder, $file) { + protected function getDefaultIcon(ISimpleFolder $folder, string $file): ISimpleFile { try { return $folder->getFile($file); } catch (NotFoundException $exception) { diff --git a/lib/Controller/SiteController.php b/lib/Controller/SiteController.php index 3a7a9231..c5f3c316 100644 --- a/lib/Controller/SiteController.php +++ b/lib/Controller/SiteController.php @@ -46,10 +46,8 @@ public function __construct(string $appName, /** * @NoAdminRequired * @NoCSRFRequired - * - * @return TemplateResponse|RedirectResponse */ - public function showPage(int $id, string $path) { + public function showPage(int $id, string $path): TemplateResponse|RedirectResponse { try { $site = $this->sitesManager->getSiteById($id); return $this->createResponse($id, $site, $path); @@ -63,10 +61,8 @@ public function showPage(int $id, string $path) { * @NoCSRFRequired * * This is used when the app is set as default app - * - * @return TemplateResponse|RedirectResponse */ - public function showDefaultPage() { + public function showDefaultPage(): TemplateResponse|RedirectResponse { // Show first available page when there is one $sites = $this->sitesManager->getSitesToDisplay(); if (!empty($sites)) { diff --git a/lib/SitesManager.php b/lib/SitesManager.php index 00c8c27b..67e5e6ca 100644 --- a/lib/SitesManager.php +++ b/lib/SitesManager.php @@ -84,11 +84,10 @@ public function __construct(IRequest $request, } /** - * @param int $id * @return array * @throws SiteNotFoundException */ - public function getSiteById($id) { + public function getSiteById(int $id) { $sites = $this->getSitesToDisplay(); if (isset($sites[$id])) { @@ -187,15 +186,7 @@ protected function fillSiteArray(array $site): array { } /** - * @param string $name - * @param string $url - * @param string $lang - * @param string $type - * @param string $device - * @param string $icon * @param string[] $groups - * @param bool $redirect - * @return array * @throws InvalidNameException * @throws InvalidURLException * @throws LanguageNotFoundException @@ -204,7 +195,7 @@ protected function fillSiteArray(array $site): array { * @throws GroupNotFoundException * @throws IconNotFoundException */ - public function addSite($name, $url, $lang, $type, $device, $icon, array $groups, $redirect) { + public function addSite(string $name, string $url, string $lang, string $type, string $device, string $icon, array $groups, bool $redirect): array { $id = 1 + $this->config->getValueInt('external', 'max_site'); if ($name === '') { @@ -277,16 +268,7 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups } /** - * @param int $id - * @param string $name - * @param string $url - * @param string $lang - * @param string $type - * @param string $device - * @param string $icon * @param string[] $groups - * @param bool $redirect - * @return array * @throws SiteNotFoundException * @throws InvalidNameException * @throws InvalidURLException @@ -296,7 +278,7 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups * @throws GroupNotFoundException * @throws IconNotFoundException */ - public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array $groups, $redirect) { + public function updateSite(int $id, string $name, string $url, string $lang, string $type, string $device, string $icon, array $groups, bool $redirect): array { $sites = $this->getSites(); if (!isset($sites[$id])) { throw new SiteNotFoundException();