diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-02-17 15:37:57 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-02-17 16:05:23 +0100 |
commit | 9b68f80c4bf73ddc845fa64dba90cd858d663af6 (patch) | |
tree | 6d762ace846eecf243ddfbe6331714d161a6995d /lib/private/legacy/app.php | |
parent | 9fcf185c7de856c90d3399663546798bd502c93b (diff) | |
download | nextcloud-server-9b68f80c4bf73ddc845fa64dba90cd858d663af6.tar.gz nextcloud-server-9b68f80c4bf73ddc845fa64dba90cd858d663af6.zip |
Add remaining type hints, that were already okay
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/legacy/app.php')
-rw-r--r-- | lib/private/legacy/app.php | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 68869df5721..4e6ed99f5c3 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch> @@ -73,10 +74,10 @@ class OC_App { /** * clean the appId * - * @param string|boolean $app AppId that needs to be cleaned + * @param string $app AppId that needs to be cleaned * @return string */ - public static function cleanAppId($app) { + public static function cleanAppId(string $app): string { return str_replace(array('\0', '/', '\\', '..'), '', $app); } @@ -86,7 +87,7 @@ class OC_App { * @param string $app * @return bool */ - public static function isAppLoaded($app) { + public static function isAppLoaded(string $app): bool { return in_array($app, self::$loadedApps, true); } @@ -135,7 +136,7 @@ class OC_App { * @param string $app * @throws Exception */ - public static function loadApp($app) { + public static function loadApp(string $app) { self::$loadedApps[] = $app; $appPath = self::getAppPath($app); if($appPath === false) { @@ -227,7 +228,7 @@ class OC_App { * @param string $app * @param string $path */ - public static function registerAutoloading($app, $path) { + public static function registerAutoloading(string $app, string $path) { $key = $app . '-' . $path; if(isset(self::$alreadyRegistered[$key])) { return; @@ -259,7 +260,7 @@ class OC_App { * @param string $app app name * @throws Error */ - private static function requireAppFile($app) { + private static function requireAppFile(string $app) { // encapsulated here to avoid variable scope conflicts require_once $app . '/appinfo/app.php'; } @@ -287,7 +288,7 @@ class OC_App { * @param string $app * @return array */ - private static function getAppTypes($app) { + private static function getAppTypes(string $app): array { //load the cache if (count(self::$appTypes) == 0) { self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); @@ -341,7 +342,7 @@ class OC_App { * currently logged in one * @return string[] */ - public static function getEnabledApps($forceRefresh = false, $all = false) { + public static function getEnabledApps(bool $forceRefresh = false, bool $all = false): array { if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { return []; } @@ -376,7 +377,7 @@ class OC_App { * * This function checks whether or not an app is enabled. */ - public static function isEnabled($app) { + public static function isEnabled(string $app): bool { return \OC::$server->getAppManager()->isEnabledForUser($app); } @@ -426,7 +427,7 @@ class OC_App { * @param string $app app * @throws Exception */ - public static function disable($app) { + public static function disable(string $app) { // flush self::$enabledAppsCache = []; @@ -471,7 +472,7 @@ class OC_App { * @param string $appId * @return false|string */ - public static function findAppInDirectories($appId) { + public static function findAppInDirectories(string $appId) { $sanitizedAppId = self::cleanAppId($appId); if($sanitizedAppId !== $appId) { return false; @@ -519,7 +520,7 @@ class OC_App { * @param string $appId * @return string|false */ - public static function getAppPath($appId) { + public static function getAppPath(string $appId) { if ($appId === null || trim($appId) === '') { return false; } @@ -537,7 +538,7 @@ class OC_App { * @param string $appId * @return string|false */ - public static function getAppWebPath($appId) { + public static function getAppWebPath(string $appId) { if (($dir = self::findAppInDirectories($appId)) != false) { return OC::$WEBROOT . $dir['url'] . '/' . $appId; } @@ -552,7 +553,7 @@ class OC_App { * @return string * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion() */ - public static function getAppVersion($appId, $useCache = true) { + public static function getAppVersion(string $appId, bool $useCache = true): string { return \OC::$server->getAppManager()->getAppVersion($appId, $useCache); } @@ -562,7 +563,7 @@ class OC_App { * @param string $path * @return string */ - public static function getAppVersionByPath($path) { + public static function getAppVersionByPath(string $path): string { $infoFile = $path . '/appinfo/info.xml'; $appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true); return isset($appData['version']) ? $appData['version'] : ''; @@ -579,7 +580,7 @@ class OC_App { * @note all data is read from info.xml, not just pre-defined fields * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppInfo() */ - public static function getAppInfo($appId, $path = false, $lang = null) { + public static function getAppInfo(string $appId, bool $path = false, string $lang = null) { return \OC::$server->getAppManager()->getAppInfo($appId, $path, $lang); } @@ -594,7 +595,7 @@ class OC_App { * given for each app the following keys exist: * - active: boolean, signals if the user is on this navigation entry */ - public static function getNavigation() { + public static function getNavigation(): array { return OC::$server->getNavigationManager()->getAll(); } @@ -607,7 +608,7 @@ class OC_App { * This function returns an array containing all settings pages added. The * entries are sorted by the key 'order' ascending. */ - public static function getSettingsNavigation() { + public static function getSettingsNavigation(): array { return OC::$server->getNavigationManager()->getAll('settings'); } @@ -638,7 +639,7 @@ class OC_App { * @param string $type * @return array */ - public static function getForms($type) { + public static function getForms(string $type): array { $forms = []; switch ($type) { case 'admin': @@ -662,7 +663,7 @@ class OC_App { * @param string $app * @param string $page */ - public static function registerAdmin($app, $page) { + public static function registerAdmin(string $app, string $page) { self::$adminForms[] = $app . '/' . $page . '.php'; } @@ -671,7 +672,7 @@ class OC_App { * @param string $app * @param string $page */ - public static function registerPersonal($app, $page) { + public static function registerPersonal(string $app, string $page) { self::$personalForms[] = $app . '/' . $page . '.php'; } @@ -685,7 +686,7 @@ class OC_App { /** * @return array */ - public static function getAlternativeLogIns() { + public static function getAlternativeLogIns(): array { return self::$altLogin; } @@ -695,7 +696,7 @@ class OC_App { * @return array an array of app names (string IDs) * @todo: change the name of this method to getInstalledApps, which is more accurate */ - public static function getAllApps() { + public static function getAllApps(): array { $apps = []; @@ -727,7 +728,7 @@ class OC_App { * * @return array */ - public function listAllApps() { + public function listAllApps(): array { $installedApps = OC_App::getAllApps(); $appManager = \OC::$server->getAppManager(); @@ -808,7 +809,7 @@ class OC_App { return $appList; } - public static function shouldUpgrade($app) { + public static function shouldUpgrade(string $app): bool { $versions = self::getAppVersions(); $currentVersion = OC_App::getAppVersion($app); if ($currentVersion && isset($versions[$app])) { @@ -828,7 +829,7 @@ class OC_App { * @param string $version2 version to take the number of parts from * @return string shortened $version1 */ - private static function adjustVersionParts($version1, $version2) { + private static function adjustVersionParts(string $version1, string $version2): string { $version1 = explode('.', $version1); $version2 = explode('.', $version2); // reduce $version1 to match the number of parts in $version2 @@ -914,7 +915,7 @@ class OC_App { * @param string $appId * @return bool */ - public static function updateApp($appId) { + public static function updateApp(sstring $appId): bool { $appPath = self::getAppPath($appId); if($appPath === false) { return false; @@ -973,7 +974,7 @@ class OC_App { * @param string[] $steps * @throws \OC\NeedsUpdateException */ - public static function executeRepairSteps($appId, array $steps) { + public static function executeRepairSteps(string $appId, array $steps) { if (empty($steps)) { return; } @@ -1007,7 +1008,7 @@ class OC_App { * @param string $appId * @param string[] $steps */ - private static function setupLiveMigrations($appId, array $steps) { + private static function setupLiveMigrations(string $appId, array $steps) { $queue = \OC::$server->getJobList(); foreach ($steps as $step) { $queue->add('OC\Migration\BackgroundRepair', [ @@ -1020,7 +1021,7 @@ class OC_App { * @param string $appId * @return \OC\Files\View|false */ - public static function getStorage($appId) { + public static function getStorage(string $appId) { if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check if (\OC::$server->getUserSession()->isLoggedIn()) { $view = new \OC\Files\View('/' . OC_User::getUser()); @@ -1038,7 +1039,7 @@ class OC_App { } } - protected static function findBestL10NOption($options, $lang) { + protected static function findBestL10NOption(array $options, string $lang): string { $fallback = $similarLangFallback = $englishFallback = false; $lang = strtolower($lang); @@ -1090,7 +1091,7 @@ class OC_App { * @param string $lang * @return array improved app data */ - public static function parseAppInfo(array $data, $lang = null) { + public static function parseAppInfo(array $data, $lang = null): array { if ($lang && isset($data['name']) && is_array($data['name'])) { $data['name'] = self::findBestL10NOption($data['name'], $lang); @@ -1115,7 +1116,7 @@ class OC_App { * @param array $info * @throws \Exception */ - public static function checkAppDependencies($config, $l, $info) { + public static function checkAppDependencies(\OCP\IConfig $config, \OCP\IL10N $l, array $info) { $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); $missing = $dependencyAnalyzer->analyze($info); if (!empty($missing)) { |