From 6d30b35ed7f96cfdc593c31cae46ddf9e74bb015 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Mar 2017 10:11:49 +0100 Subject: [PATCH] Some more code fixes Signed-off-by: Joas Schilling --- lib/private/App/AppManager.php | 43 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 42777266249..7c861597c77 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -55,18 +55,21 @@ class AppManager implements IAppManager { 'prevent_group_restriction', ]; - /** @var \OCP\IUserSession */ + /** @var IUserSession */ private $userSession; - /** @var \OCP\IAppConfig */ + /** @var IAppConfig */ private $appConfig; - /** @var \OCP\IGroupManager */ + /** @var IGroupManager */ private $groupManager; - /** @var \OCP\ICacheFactory */ + /** @var ICacheFactory */ private $memCacheFactory; + /** @var EventDispatcherInterface */ + private $dispatcher; + /** @var string[] $appId => $enabled */ private $installedAppsCache; @@ -76,14 +79,12 @@ class AppManager implements IAppManager { /** @var string[] */ private $alwaysEnabled; - /** @var EventDispatcherInterface */ - private $dispatcher; - /** - * @param \OCP\IUserSession $userSession - * @param \OCP\IAppConfig $appConfig - * @param \OCP\IGroupManager $groupManager - * @param \OCP\ICacheFactory $memCacheFactory + * @param IUserSession $userSession + * @param IAppConfig $appConfig + * @param IGroupManager $groupManager + * @param ICacheFactory $memCacheFactory + * @param EventDispatcherInterface $dispatcher */ public function __construct(IUserSession $userSession, IAppConfig $appConfig, @@ -151,7 +152,7 @@ class AppManager implements IAppManager { if ($this->isAlwaysEnabled($appId)) { return true; } - if (is_null($user)) { + if ($user === null) { $user = $this->userSession->getUser(); } $installedApps = $this->getInstalledAppsValues(); @@ -170,7 +171,7 @@ class AppManager implements IAppManager { private function checkAppForUser($enabled, $user) { if ($enabled === 'yes') { return true; - } elseif (is_null($user)) { + } elseif ($user === null) { return false; } else { if(empty($enabled)){ @@ -187,7 +188,7 @@ class AppManager implements IAppManager { $userGroups = $this->groupManager->getUserGroupIds($user); foreach ($userGroups as $groupId) { - if (array_search($groupId, $groupIds) !== false) { + if (in_array($groupId, $groupIds, true)) { return true; } } @@ -311,12 +312,12 @@ class AppManager implements IAppManager { /** * Returns a list of apps that need upgrade * - * @param array $version ownCloud version as array of version components + * @param string $version Nextcloud version as array of version components * @return array list of app info from apps that need an upgrade * * @internal */ - public function getAppsNeedingUpgrade($ocVersion) { + public function getAppsNeedingUpgrade($version) { $appsToUpgrade = []; $apps = $this->getInstalledApps(); foreach ($apps as $appId) { @@ -325,7 +326,7 @@ class AppManager implements IAppManager { if ($appDbVersion && isset($appInfo['version']) && version_compare($appInfo['version'], $appDbVersion, '>') - && \OC_App::isAppCompatible($ocVersion, $appInfo) + && \OC_App::isAppCompatible($version, $appInfo) ) { $appsToUpgrade[] = $appInfo; } @@ -355,7 +356,7 @@ class AppManager implements IAppManager { /** * Returns a list of apps incompatible with the given version * - * @param array $version ownCloud version as array of version components + * @param string $version Nextcloud version as array of version components * * @return array list of app info from incompatible apps * @@ -378,16 +379,16 @@ class AppManager implements IAppManager { */ public function isShipped($appId) { $this->loadShippedJson(); - return in_array($appId, $this->shippedApps); + return in_array($appId, $this->shippedApps, true); } private function isAlwaysEnabled($appId) { $alwaysEnabled = $this->getAlwaysEnabledApps(); - return in_array($appId, $alwaysEnabled); + return in_array($appId, $alwaysEnabled, true); } private function loadShippedJson() { - if (is_null($this->shippedApps)) { + if ($this->shippedApps === null) { $shippedJson = \OC::$SERVERROOT . '/core/shipped.json'; if (!file_exists($shippedJson)) { throw new \Exception("File not found: $shippedJson"); -- 2.39.5