Add explicit `return null;` statements
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / WCF.class.php
index ba5c2abd8d66d452e325c63423f917de65569c7c..3e249e2f3a55def6f7c5309c3ad8efba7b90ac2d 100644 (file)
@@ -366,6 +366,46 @@ class WCF
      * Loads the options file, automatically created if not exists.
      */
     protected function loadOptions()
+    {
+        $this->defineLegacyOptions();
+
+        $filename = WCF_DIR . 'options.inc.php';
+
+        // create options file if doesn't exist
+        if (!\file_exists($filename) || \filemtime($filename) <= 1) {
+            OptionEditor::rebuild();
+        }
+        require($filename);
+
+        // check if option file is complete and writable
+        if (PACKAGE_ID) {
+            if (!\is_writable($filename)) {
+                FileUtil::makeWritable($filename);
+
+                if (!\is_writable($filename)) {
+                    throw new SystemException("The option file '" . $filename . "' is not writable.");
+                }
+            }
+
+            // check if a previous write operation was incomplete and force rebuilding
+            if (!\defined('WCF_OPTION_INC_PHP_SUCCESS')) {
+                OptionEditor::rebuild();
+
+                require($filename);
+            }
+
+            if (ENABLE_DEBUG_MODE) {
+                self::$dbObj->enableDebugMode();
+            }
+        }
+    }
+
+    /**
+     * Defines constants for obsolete options, which were removed.
+     *
+     * @since   5.4
+     */
+    protected function defineLegacyOptions(): void
     {
         // The attachment module is always enabled since 5.2.
         // https://github.com/WoltLab/WCF/issues/2531
@@ -426,36 +466,6 @@ class WCF
         // Cover photos are always enabled since 5.4.
         // https://github.com/WoltLab/WCF/issues/3902
         \define('MODULE_USER_COVER_PHOTO', 1);
-
-        $filename = WCF_DIR . 'options.inc.php';
-
-        // create options file if doesn't exist
-        if (!\file_exists($filename) || \filemtime($filename) <= 1) {
-            OptionEditor::rebuild();
-        }
-        require($filename);
-
-        // check if option file is complete and writable
-        if (PACKAGE_ID) {
-            if (!\is_writable($filename)) {
-                FileUtil::makeWritable($filename);
-
-                if (!\is_writable($filename)) {
-                    throw new SystemException("The option file '" . $filename . "' is not writable.");
-                }
-            }
-
-            // check if a previous write operation was incomplete and force rebuilding
-            if (!\defined('WCF_OPTION_INC_PHP_SUCCESS')) {
-                OptionEditor::rebuild();
-
-                require($filename);
-            }
-
-            if (ENABLE_DEBUG_MODE) {
-                self::$dbObj->enableDebugMode();
-            }
-        }
     }
 
     /**
@@ -737,9 +747,7 @@ class WCF
      */
     public static function getApplicationObject(Application $application)
     {
-        if (isset(self::$applicationObjects[$application->packageID])) {
-            return self::$applicationObjects[$application->packageID];
-        }
+        return self::$applicationObjects[$application->packageID] ?? null;
     }
 
     /**
@@ -939,13 +947,11 @@ class WCF
      * Searches for cached core object definition.
      *
      * @param string $className
-     * @return  string
+     * @return  string|null
      */
     final protected static function getCoreObject($className)
     {
-        if (isset(self::$coreObjectCache[$className])) {
-            return self::$coreObjectCache[$className];
-        }
+        return self::$coreObjectCache[$className] ?? null;
     }
 
     /**
@@ -1039,7 +1045,7 @@ class WCF
     public static function getActivePage()
     {
         if (self::getActiveRequest() === null) {
-            return;
+            return null;
         }
 
         if (self::getActiveRequest()->getClassName() === CmsPage::class) {
@@ -1048,7 +1054,7 @@ class WCF
                 return PageCache::getInstance()->getPage($metaData['cms']['pageID']);
             }
 
-            return;
+            return null;
         }
 
         return PageCache::getInstance()->getPageByController(self::getActiveRequest()->getClassName());