Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like OC_App often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use OC_App, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 58 | class OC_App { |
||
| 59 | static private $appVersion = []; |
||
| 60 | static private $adminForms = []; |
||
| 61 | static private $personalForms = []; |
||
| 62 | static private $appInfo = []; |
||
| 63 | static private $appTypes = []; |
||
| 64 | static private $loadedApps = []; |
||
| 65 | static private $loadedTypes = []; |
||
| 66 | static private $altLogin = []; |
||
| 67 | const officialApp = 200; |
||
| 68 | const approvedApp = 100; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * clean the appId |
||
| 72 | * |
||
| 73 | * @param string|boolean $app AppId that needs to be cleaned |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | public static function cleanAppId($app) { |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Check if an app is loaded |
||
| 82 | * |
||
| 83 | * @param string $app |
||
| 84 | * @return bool |
||
| 85 | */ |
||
| 86 | public static function isAppLoaded($app) { |
||
| 89 | |||
| 90 | /** |
||
| 91 | * loads all apps |
||
| 92 | * |
||
| 93 | * @param string[] | string | null $types |
||
| 94 | * @return bool |
||
| 95 | * |
||
| 96 | * This function walks through the ownCloud directory and loads all apps |
||
| 97 | * it can find. A directory contains an app if the file /appinfo/info.xml |
||
| 98 | * exists. |
||
| 99 | * |
||
| 100 | * if $types is set, only apps of those types will be loaded |
||
| 101 | */ |
||
| 102 | public static function loadApps($types = null) { |
||
| 103 | if (\is_array($types) && !\array_diff($types, self::$loadedTypes)) { |
||
| 104 | return true; |
||
| 105 | } |
||
| 106 | if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
||
| 107 | return false; |
||
| 108 | } |
||
| 109 | // Load the enabled apps here |
||
| 110 | $apps = self::getEnabledApps(); |
||
| 111 | |||
| 112 | // Add each apps' folder as allowed class path |
||
| 113 | foreach($apps as $app) { |
||
| 114 | if (self::isAppLoaded($app)) { |
||
| 115 | continue; |
||
| 116 | } |
||
| 117 | $path = self::getAppPath($app); |
||
| 118 | if($path !== false) { |
||
| 119 | self::registerAutoloading($app, $path); |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | // prevent app.php from printing output |
||
| 124 | \ob_start(); |
||
| 125 | foreach ($apps as $app) { |
||
| 126 | if ((\is_null($types) or self::isType($app, $types)) && !\in_array($app, self::$loadedApps)) { |
||
| 127 | self::loadApp($app); |
||
| 128 | } |
||
| 129 | } |
||
| 130 | \ob_end_clean(); |
||
| 131 | |||
| 132 | if (\is_array($types)) { |
||
| 133 | self::$loadedTypes = \array_merge(self::$loadedTypes, $types); |
||
| 134 | } |
||
| 135 | |||
| 136 | \OC_Hook::emit('OC_App', 'loadedApps'); |
||
| 137 | return true; |
||
| 138 | } |
||
| 139 | |||
| 140 | /** |
||
| 141 | * load a single app |
||
| 142 | * |
||
| 143 | * @param string $app |
||
| 144 | * @param bool $checkUpgrade whether an upgrade check should be done |
||
| 145 | * @throws \OC\NeedsUpdateException |
||
| 146 | */ |
||
| 147 | public static function loadApp($app, $checkUpgrade = true) { |
||
| 148 | self::$loadedApps[] = $app; |
||
| 149 | $appPath = self::getAppPath($app); |
||
| 150 | if($appPath === false) { |
||
| 151 | return; |
||
| 152 | } |
||
| 153 | |||
| 154 | // in case someone calls loadApp() directly |
||
| 155 | self::registerAutoloading($app, $appPath); |
||
| 156 | |||
| 157 | self::enableThemeIfApplicable($app); |
||
| 158 | |||
| 159 | if (\is_file($appPath . '/appinfo/app.php')) { |
||
| 160 | \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
||
| 161 | if ($checkUpgrade and self::shouldUpgrade($app)) { |
||
| 162 | throw new \OC\NeedsUpdateException(); |
||
| 163 | } |
||
| 164 | self::requireAppFile($app); |
||
| 165 | if (self::isType($app, ['authentication'])) { |
||
| 166 | // since authentication apps affect the "is app enabled for group" check, |
||
| 167 | // the enabled apps cache needs to be cleared to make sure that the |
||
| 168 | // next time getEnableApps() is called it will also include apps that were |
||
| 169 | // enabled for groups |
||
| 170 | self::$enabledAppsCache = []; |
||
| 171 | } |
||
| 172 | \OC::$server->getEventLogger()->end('load_app_' . $app); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Enables the app as a theme if it has the type "theme" |
||
| 178 | * @param string $app |
||
| 179 | */ |
||
| 180 | private static function enableThemeIfApplicable($app) { |
||
| 181 | if (self::isType($app, 'theme')) { |
||
| 182 | /** @var \OCP\Theme\IThemeService $themeService */ |
||
| 183 | $themeService = \OC::$server->query('ThemeService'); |
||
| 184 | $themeService->setAppTheme($app); |
||
| 185 | } |
||
| 186 | } |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @internal |
||
| 190 | * @param string $app |
||
| 191 | * @param string $path |
||
| 192 | */ |
||
| 193 | public static function registerAutoloading($app, $path) { |
||
| 194 | // Register on PSR-4 composer autoloader |
||
| 195 | $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
||
| 196 | \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
||
| 197 | if (\defined('PHPUNIT_RUN')) { |
||
| 198 | \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
||
| 199 | } |
||
| 200 | |||
| 201 | // Register on legacy autoloader |
||
| 202 | \OC::$loader->addValidRoot($path); |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Load app.php from the given app |
||
| 207 | * |
||
| 208 | * @param string $app app name |
||
| 209 | */ |
||
| 210 | private static function requireAppFile($app) { |
||
| 211 | try { |
||
| 212 | // encapsulated here to avoid variable scope conflicts |
||
| 213 | require_once $app . '/appinfo/app.php'; |
||
| 214 | } catch (Exception $ex) { |
||
| 215 | \OC::$server->getLogger()->logException($ex); |
||
| 216 | $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps(); |
||
| 217 | if (!\in_array($app, $blacklist)) { |
||
| 218 | if (!self::isType($app, ['authentication', 'filesystem'])) { |
||
| 219 | \OC::$server->getLogger()->warning('Could not load app "' . $app . '", it will be disabled', ['app' => 'core']); |
||
| 220 | self::disable($app); |
||
| 221 | } else { |
||
| 222 | \OC::$server->getLogger()->warning('Could not load app "' . $app . '", see exception above', ['app' => 'core']); |
||
| 223 | } |
||
| 224 | } |
||
| 225 | throw $ex; |
||
| 226 | } |
||
| 227 | } |
||
| 228 | |||
| 229 | /** |
||
| 230 | * check if an app is of a specific type |
||
| 231 | * |
||
| 232 | * @param string $app |
||
| 233 | * @param string|array $types |
||
| 234 | * @return bool |
||
| 235 | */ |
||
| 236 | public static function isType($app, $types) { |
||
| 237 | if (\is_string($types)) { |
||
| 238 | $types = [$types]; |
||
| 239 | } |
||
| 240 | $appTypes = self::getAppTypes($app); |
||
| 241 | foreach ($types as $type) { |
||
| 242 | if (\array_search($type, $appTypes) !== false) { |
||
| 243 | return true; |
||
| 244 | } |
||
| 245 | } |
||
| 246 | return false; |
||
| 247 | } |
||
| 248 | |||
| 249 | /** |
||
| 250 | * get the types of an app |
||
| 251 | * |
||
| 252 | * @param string $app |
||
| 253 | * @return array |
||
| 254 | */ |
||
| 255 | private static function getAppTypes($app) { |
||
| 256 | //load the cache |
||
| 257 | if (\count(self::$appTypes) == 0) { |
||
| 258 | self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); |
||
|
|
|||
| 259 | } |
||
| 260 | |||
| 261 | if (isset(self::$appTypes[$app])) { |
||
| 262 | return \explode(',', self::$appTypes[$app]); |
||
| 263 | } else { |
||
| 264 | return []; |
||
| 265 | } |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * read app types from info.xml and cache them in the database |
||
| 270 | */ |
||
| 271 | public static function setAppTypes($app) { |
||
| 272 | $appData = self::getAppInfo($app); |
||
| 273 | if(!\is_array($appData)) { |
||
| 274 | return; |
||
| 275 | } |
||
| 276 | |||
| 277 | if (isset($appData['types'])) { |
||
| 278 | $appTypes = \implode(',', $appData['types']); |
||
| 279 | } else { |
||
| 280 | $appTypes = ''; |
||
| 281 | } |
||
| 282 | |||
| 283 | \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes); |
||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * check if app is shipped |
||
| 288 | * |
||
| 289 | * @param string $appId the id of the app to check |
||
| 290 | * @return bool |
||
| 291 | * |
||
| 292 | * Check if an app that is installed is a shipped app or installed from the appstore. |
||
| 293 | */ |
||
| 294 | public static function isShipped($appId) { |
||
| 295 | return \OC::$server->getAppManager()->isShipped($appId); |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * get all enabled apps |
||
| 300 | */ |
||
| 301 | protected static $enabledAppsCache = []; |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Returns apps enabled for the current user. |
||
| 305 | * |
||
| 306 | * @param bool $forceRefresh whether to refresh the cache |
||
| 307 | * @param bool $all whether to return apps for all users, not only the |
||
| 308 | * currently logged in one |
||
| 309 | * @return string[] |
||
| 310 | */ |
||
| 311 | public static function getEnabledApps($forceRefresh = false, $all = false) { |
||
| 312 | if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { |
||
| 313 | return []; |
||
| 314 | } |
||
| 315 | // in incognito mode or when logged out, $user will be false, |
||
| 316 | // which is also the case during an upgrade |
||
| 317 | $appManager = \OC::$server->getAppManager(); |
||
| 318 | if ($all) { |
||
| 319 | $user = null; |
||
| 320 | } else { |
||
| 321 | $user = \OC::$server->getUserSession()->getUser(); |
||
| 322 | } |
||
| 323 | |||
| 324 | if (\is_null($user)) { |
||
| 325 | $apps = $appManager->getInstalledApps(); |
||
| 326 | } else { |
||
| 327 | $apps = $appManager->getEnabledAppsForUser($user); |
||
| 328 | } |
||
| 329 | $apps = \array_filter($apps, function ($app) { |
||
| 330 | return $app !== 'files';//we add this manually |
||
| 331 | }); |
||
| 332 | \sort($apps); |
||
| 333 | \array_unshift($apps, 'files'); |
||
| 334 | return $apps; |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * checks whether or not an app is enabled |
||
| 339 | * |
||
| 340 | * @param string $app app |
||
| 341 | * @return bool |
||
| 342 | * |
||
| 343 | * This function checks whether or not an app is enabled. |
||
| 344 | */ |
||
| 345 | public static function isEnabled($app) { |
||
| 346 | return \OC::$server->getAppManager()->isEnabledForUser($app); |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * enables an app |
||
| 351 | * |
||
| 352 | * @param mixed $app app |
||
| 353 | * @param array $groups (optional) when set, only these groups will have access to the app |
||
| 354 | * @throws \Exception |
||
| 355 | * @return void |
||
| 356 | * |
||
| 357 | * This function set an app as enabled in appconfig. |
||
| 358 | */ |
||
| 359 | public static function enable($app, $groups = null) { |
||
| 360 | self::$enabledAppsCache = []; // flush |
||
| 361 | |||
| 362 | // check for required dependencies |
||
| 363 | $config = \OC::$server->getConfig(); |
||
| 364 | $l = \OC::$server->getL10N('core'); |
||
| 365 | $info = self::getAppInfo($app); |
||
| 366 | if ($info === null) { |
||
| 367 | throw new \Exception("$app can't be enabled since it is not installed."); |
||
| 368 | } |
||
| 369 | |||
| 370 | self::checkAppDependencies($config, $l, $info); |
||
| 371 | |||
| 372 | if (!Installer::isInstalled($app)) { |
||
| 373 | Installer::installShippedApp($app); |
||
| 374 | } |
||
| 375 | |||
| 376 | $appManager = \OC::$server->getAppManager(); |
||
| 377 | if (!\is_null($groups)) { |
||
| 378 | $groupManager = \OC::$server->getGroupManager(); |
||
| 379 | $groupsList = []; |
||
| 380 | foreach ($groups as $group) { |
||
| 381 | $groupItem = $groupManager->get($group); |
||
| 382 | if ($groupItem instanceof \OCP\IGroup) { |
||
| 383 | $groupsList[] = $groupManager->get($group); |
||
| 384 | } |
||
| 385 | } |
||
| 386 | $appManager->enableAppForGroups($app, $groupsList); |
||
| 387 | } else { |
||
| 388 | $appManager->enableApp($app); |
||
| 389 | } |
||
| 390 | } |
||
| 391 | |||
| 392 | /** |
||
| 393 | * @param string $app |
||
| 394 | * @return bool |
||
| 395 | */ |
||
| 396 | public static function removeApp($app) { |
||
| 403 | |||
| 404 | /** |
||
| 405 | * This function set an app as disabled in appconfig. |
||
| 406 | * |
||
| 407 | * @param string $app app |
||
| 408 | * @throws Exception |
||
| 409 | */ |
||
| 410 | public static function disable($app) { |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Returns the Settings Navigation |
||
| 435 | * |
||
| 436 | * @return string[] |
||
| 437 | * |
||
| 438 | * This function returns an array containing all settings pages added. The |
||
| 439 | * entries are sorted by the key 'order' ascending. |
||
| 440 | */ |
||
| 441 | public static function getSettingsNavigation() { |
||
| 442 | $l = \OC::$server->getL10N('lib'); |
||
| 443 | $urlGenerator = \OC::$server->getURLGenerator(); |
||
| 444 | |||
| 475 | |||
| 476 | // This is private as well. It simply works, so don't ask for more details |
||
| 477 | private static function proceedNavigation($list) { |
||
| 502 | |||
| 503 | /** |
||
| 504 | * Get the path where to install apps |
||
| 505 | * |
||
| 506 | * @return string|null |
||
| 507 | */ |
||
| 508 | public static function getInstallPath() { |
||
| 518 | |||
| 519 | /** |
||
| 520 | * Get the directory for the given app. |
||
| 521 | * If the app exists in multiple directories, the most recent version is taken. |
||
| 522 | * (false if not found) |
||
| 523 | * |
||
| 524 | * @param string $appId |
||
| 525 | * @return string|false |
||
| 526 | */ |
||
| 527 | public static function getAppPath($appId) { |
||
| 530 | |||
| 531 | /** |
||
| 532 | * Get the web path for the given app. |
||
| 533 | * If the app exists in multiple directories, the most recent version is taken. |
||
| 534 | * (false if not found) |
||
| 535 | * |
||
| 536 | * @param string $appId |
||
| 537 | * @return string|false |
||
| 538 | */ |
||
| 539 | public static function getAppWebPath($appId) { |
||
| 542 | |||
| 543 | /** |
||
| 544 | * check if an app's directory is writable |
||
| 545 | * |
||
| 546 | * @param string $appId |
||
| 547 | * @return bool |
||
| 548 | */ |
||
| 549 | public static function isAppDirWritable($appId) { |
||
| 553 | |||
| 554 | /** |
||
| 555 | * get the last version of the app from appinfo/info.xml |
||
| 556 | * |
||
| 557 | * @param string $appId |
||
| 558 | * @return string |
||
| 559 | */ |
||
| 560 | public static function getAppVersion($appId) { |
||
| 567 | |||
| 568 | /** |
||
| 569 | * get app's version based on it's path |
||
| 570 | * |
||
| 571 | * @param string $path |
||
| 572 | * @return string |
||
| 573 | */ |
||
| 574 | public static function getAppVersionByPath($path) { |
||
| 579 | |||
| 580 | /** |
||
| 581 | * Read all app metadata from the info.xml file |
||
| 582 | * |
||
| 583 | * @param string $appId id of the app or the path of the info.xml file |
||
| 584 | * @param boolean $path (optional) |
||
| 585 | * @return array|null |
||
| 586 | * @note all data is read from info.xml, not just pre-defined fields |
||
| 587 | */ |
||
| 588 | public static function getAppInfo($appId, $path = false) { |
||
| 624 | |||
| 625 | /** |
||
| 626 | * Returns the navigation |
||
| 627 | * |
||
| 628 | * @return array |
||
| 629 | * |
||
| 630 | * This function returns an array containing all entries added. The |
||
| 631 | * entries are sorted by the key 'order' ascending. Additional to the keys |
||
| 632 | * given for each app the following keys exist: |
||
| 633 | * - active: boolean, signals if the user is on this navigation entry |
||
| 634 | */ |
||
| 635 | public static function getNavigation() { |
||
| 639 | |||
| 640 | /** |
||
| 641 | * get the id of loaded app |
||
| 642 | * |
||
| 643 | * @return string |
||
| 644 | */ |
||
| 645 | public static function getCurrentApp() { |
||
| 662 | |||
| 663 | /** |
||
| 664 | * @param string $type |
||
| 665 | * @return array |
||
| 666 | */ |
||
| 667 | public static function getForms($type) { |
||
| 688 | |||
| 689 | /** |
||
| 690 | * register an admin form to be shown |
||
| 691 | * |
||
| 692 | * @param string $app |
||
| 693 | * @param string $page |
||
| 694 | * @deprecated Register settings panels in info.xml |
||
| 695 | */ |
||
| 696 | public static function registerAdmin($app, $page) { |
||
| 702 | |||
| 703 | /** |
||
| 704 | * register a personal form to be shown |
||
| 705 | * @param string $app |
||
| 706 | * @param string $page |
||
| 707 | * @deprecated Register settings panels in info.xml |
||
| 708 | */ |
||
| 709 | public static function registerPersonal($app, $page) { |
||
| 715 | |||
| 716 | /** |
||
| 717 | * @param array $entry |
||
| 718 | */ |
||
| 719 | public static function registerLogIn(array $entry) { |
||
| 722 | |||
| 723 | /** |
||
| 724 | * @return array |
||
| 725 | */ |
||
| 726 | public static function getAlternativeLogIns() { |
||
| 729 | |||
| 730 | /** |
||
| 731 | * get a list of all apps in the apps folder |
||
| 732 | * |
||
| 733 | * @return array an array of app names (string IDs) |
||
| 734 | * @todo: change the name of this method to getInstalledApps, which is more accurate |
||
| 735 | */ |
||
| 736 | public static function getAllApps() { |
||
| 760 | |||
| 761 | /** |
||
| 762 | * List all apps, this is used in apps.php |
||
| 763 | * |
||
| 764 | * @param bool $onlyLocal |
||
| 765 | * @param bool $includeUpdateInfo Should we check whether there is an update |
||
| 766 | * in the app store? |
||
| 767 | * @return array |
||
| 768 | */ |
||
| 769 | public static function listAllApps() { |
||
| 857 | |||
| 858 | /** |
||
| 859 | * Returns the internal app ID or false |
||
| 860 | * @param string $ocsID |
||
| 861 | * @return string|false |
||
| 862 | */ |
||
| 863 | public static function getInternalAppIdByOcs($ocsID) { |
||
| 872 | |||
| 873 | public static function shouldUpgrade($app) { |
||
| 884 | |||
| 885 | /** |
||
| 886 | * Adjust the number of version parts of $version1 to match |
||
| 887 | * the number of version parts of $version2. |
||
| 888 | * |
||
| 889 | * @param string $version1 version to adjust |
||
| 890 | * @param string $version2 version to take the number of parts from |
||
| 891 | * @return string shortened $version1 |
||
| 892 | */ |
||
| 893 | private static function adjustVersionParts($version1, $version2) { |
||
| 906 | |||
| 907 | /** |
||
| 908 | * Check whether the current ownCloud version matches the given |
||
| 909 | * application's version requirements. |
||
| 910 | * |
||
| 911 | * The comparison is made based on the number of parts that the |
||
| 912 | * app info version has. For example for ownCloud 6.0.3 if the |
||
| 913 | * app info version is expecting version 6.0, the comparison is |
||
| 914 | * made on the first two parts of the ownCloud version. |
||
| 915 | * This means that it's possible to specify "requiremin" => 6 |
||
| 916 | * and "requiremax" => 6 and it will still match ownCloud 6.0.3. |
||
| 917 | * |
||
| 918 | * @param string|array $ocVersion ownCloud version to check against |
||
| 919 | * @param array $appInfo app info (from xml) |
||
| 920 | * |
||
| 921 | * @return boolean true if compatible, otherwise false |
||
| 922 | */ |
||
| 923 | public static function isAppCompatible($ocVersion, $appInfo) { |
||
| 959 | |||
| 960 | /** |
||
| 961 | * get the installed version of all apps |
||
| 962 | */ |
||
| 963 | public static function getAppVersions() { |
||
| 972 | |||
| 973 | /** |
||
| 974 | * update the database for the app and call the update script |
||
| 975 | * |
||
| 976 | * @param string $appId |
||
| 977 | * @return bool |
||
| 978 | */ |
||
| 979 | public static function updateApp($appId) { |
||
| 1024 | |||
| 1025 | /** |
||
| 1026 | * @param string $appId |
||
| 1027 | * @param string[] $steps |
||
| 1028 | * @throws \OC\NeedsUpdateException |
||
| 1029 | */ |
||
| 1030 | public static function executeRepairSteps($appId, array $steps) { |
||
| 1052 | |||
| 1053 | public static function setupBackgroundJobs(array $jobs) { |
||
| 1059 | |||
| 1060 | /** |
||
| 1061 | * @param string $appId |
||
| 1062 | * @param string[] $steps |
||
| 1063 | */ |
||
| 1064 | private static function setupLiveMigrations($appId, array $steps) { |
||
| 1072 | |||
| 1073 | /** |
||
| 1074 | * @param string $appId |
||
| 1075 | * @return \OC\Files\View|false |
||
| 1076 | */ |
||
| 1077 | public static function getStorage($appId) { |
||
| 1094 | |||
| 1095 | /** |
||
| 1096 | * parses the app data array and enhanced the 'description' value |
||
| 1097 | * |
||
| 1098 | * @param array $data the app data |
||
| 1099 | * @return array improved app data |
||
| 1100 | */ |
||
| 1101 | public static function parseAppInfo(array $data) { |
||
| 1131 | |||
| 1132 | /** |
||
| 1133 | * @param OCP\IConfig $config |
||
| 1134 | * @param OCP\IL10N $l |
||
| 1135 | * @param array $info |
||
| 1136 | * @throws Exception |
||
| 1137 | */ |
||
| 1138 | protected static function checkAppDependencies($config, $l, $info) { |
||
| 1150 | |||
| 1151 | /** |
||
| 1152 | * @param $appId |
||
| 1153 | */ |
||
| 1154 | public static function clearAppCache($appId) { |
||
| 1158 | } |
||
| 1159 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.