From: Matthias Schmidt Date: Mon, 10 May 2021 14:07:35 +0000 (+0200) Subject: Add explicit `return null;` statements X-Git-Tag: 5.4.0_Alpha_2~14^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c0b28aa2c24deb4b2521e83e7ea14005e27f5fcf;p=GitHub%2FWoltLab%2FWCF.git Add explicit `return null;` statements --- diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php index c4b209aef0..80c86ab036 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php @@ -132,7 +132,7 @@ abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements I } catch (DatabaseQueryExecutionException $e) { // Error code 23000 = duplicate key if ($e->getCode() == '23000' && $e->getDriverCode() == '1062') { - return; + return null; } throw $e; diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php index e8359db1d8..4762ea07c6 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php @@ -410,7 +410,7 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject } if (empty($this->objects)) { - return; + return null; } return \reset($this->objects); diff --git a/wcfsetup/install/files/lib/data/article/content/ViewableArticleContent.class.php b/wcfsetup/install/files/lib/data/article/content/ViewableArticleContent.class.php index 076edbf7ea..2f2961ba33 100644 --- a/wcfsetup/install/files/lib/data/article/content/ViewableArticleContent.class.php +++ b/wcfsetup/install/files/lib/data/article/content/ViewableArticleContent.class.php @@ -81,7 +81,7 @@ class ViewableArticleContent extends DatabaseObjectDecorator } if ($this->image === null || !$this->image->isAccessible()) { - return; + return null; } return $this->image; @@ -113,7 +113,7 @@ class ViewableArticleContent extends DatabaseObjectDecorator } if ($this->teaserImage === null || !$this->teaserImage->isAccessible()) { - return; + return null; } return $this->teaserImage; diff --git a/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProvider.class.php b/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProvider.class.php index 7f376e4e3d..9023120319 100644 --- a/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProvider.class.php +++ b/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProvider.class.php @@ -136,12 +136,12 @@ class BBCodeMediaProvider extends DatabaseObject implements IRouteController /** * Returns media provider callback instance. * - * @return IBBCodeMediaProvider + * @return IBBCodeMediaProvider|null */ public function getCallback() { if (!$this->className) { - return; + return null; } if ($this->callback === null) { diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index 25877a1909..2e00f9522c 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -386,7 +386,7 @@ class Box extends DatabaseObject public function getImage() { if ($this->boxType === 'menu') { - return; + return null; } if ($this->image === null) { @@ -405,7 +405,7 @@ class Box extends DatabaseObject } if ($this->image === null || !$this->image->isAccessible()) { - return; + return null; } return $this->image; diff --git a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php index 4639dd1d50..249091c8f6 100644 --- a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php @@ -81,7 +81,7 @@ class StructuredCommentResponse extends DatabaseObjectDecorator { $response = new CommentResponse($responseID); if (!$response->responseID) { - return; + return null; } // prepare structured response diff --git a/wcfsetup/install/files/lib/data/devtools/missing/language/item/DevtoolsMissingLanguageItem.class.php b/wcfsetup/install/files/lib/data/devtools/missing/language/item/DevtoolsMissingLanguageItem.class.php index a9467a6f98..07f9da7cfc 100644 --- a/wcfsetup/install/files/lib/data/devtools/missing/language/item/DevtoolsMissingLanguageItem.class.php +++ b/wcfsetup/install/files/lib/data/devtools/missing/language/item/DevtoolsMissingLanguageItem.class.php @@ -34,7 +34,7 @@ class DevtoolsMissingLanguageItem extends DatabaseObject public function getLanguage() { if ($this->languageID === null) { - return; + return null; } return LanguageFactory::getInstance()->getLanguage($this->languageID); diff --git a/wcfsetup/install/files/lib/data/package/PackageCache.class.php b/wcfsetup/install/files/lib/data/package/PackageCache.class.php index b2652c877b..3ac224b65b 100644 --- a/wcfsetup/install/files/lib/data/package/PackageCache.class.php +++ b/wcfsetup/install/files/lib/data/package/PackageCache.class.php @@ -71,7 +71,7 @@ class PackageCache extends SingletonFactory { $packageID = $this->getPackageID($package); if ($packageID === null) { - return; + return null; } return $this->getPackage($packageID); diff --git a/wcfsetup/install/files/lib/data/smiley/category/SmileyCategory.class.php b/wcfsetup/install/files/lib/data/smiley/category/SmileyCategory.class.php index ec4e85dec5..9aa89c22c6 100644 --- a/wcfsetup/install/files/lib/data/smiley/category/SmileyCategory.class.php +++ b/wcfsetup/install/files/lib/data/smiley/category/SmileyCategory.class.php @@ -143,7 +143,7 @@ class SmileyCategory extends AbstractDecoratedCategory implements \Countable, IT return $this->current(); } catch (SystemException $e) { - return; + return null; } } diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index 3152984278..d890a73a75 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -321,7 +321,7 @@ final class User extends DatabaseObject implements IPopoverObject, IRouteControl * Returns the id of a user option. * * @param string $name - * @return int id + * @return int|null */ public static function getUserOptionID($name) { @@ -331,7 +331,7 @@ final class User extends DatabaseObject implements IPopoverObject, IRouteControl } if (!isset(self::$userOptions[$name])) { - return; + return null; } return self::$userOptions[$name]->optionID; diff --git a/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatch.class.php b/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatch.class.php index cb1815d9cb..2239ec8c2e 100644 --- a/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatch.class.php +++ b/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatch.class.php @@ -28,7 +28,7 @@ class UserObjectWatch extends DatabaseObject * @param int $objectTypeID * @param int $userID * @param int $objectID - * @return UserObjectWatch + * @return UserObjectWatch|null */ public static function getUserObjectWatch($objectTypeID, $userID, $objectID) { @@ -41,7 +41,7 @@ class UserObjectWatch extends DatabaseObject $statement->execute([$objectTypeID, $userID, $objectID]); $row = $statement->fetch(); if (!$row) { - return; + return null; } return new self(null, $row); diff --git a/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php b/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php index 8ddb434c24..877b6a8472 100644 --- a/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php +++ b/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php @@ -154,12 +154,12 @@ class UserOnline extends UserProfile /** * Returns the spider object * - * @return Spider + * @return Spider|null */ public function getSpider() { if (!$this->spiderID) { - return; + return null; } if ($this->spider === null) { diff --git a/wcfsetup/install/files/lib/data/user/option/category/UserOptionCategory.class.php b/wcfsetup/install/files/lib/data/user/option/category/UserOptionCategory.class.php index a5ca6c66dc..b559012ba5 100644 --- a/wcfsetup/install/files/lib/data/user/option/category/UserOptionCategory.class.php +++ b/wcfsetup/install/files/lib/data/user/option/category/UserOptionCategory.class.php @@ -46,7 +46,7 @@ class UserOptionCategory extends DatabaseObject implements ITitledObject * Returns an instance of UserOptionCategory by name. * * @param string $categoryName - * @return UserOptionCategory + * @return UserOptionCategory|null */ public static function getCategoryByName($categoryName) { @@ -57,7 +57,7 @@ class UserOptionCategory extends DatabaseObject implements ITitledObject $statement->execute([$categoryName]); $row = $statement->fetchArray(); if ($row === false) { - return; + return null; } return new self(null, $row); diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index c8bbf4a9c6..3e249e2f3a 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -1045,7 +1045,7 @@ class WCF public static function getActivePage() { if (self::getActiveRequest() === null) { - return; + return null; } if (self::getActiveRequest()->getClassName() === CmsPage::class) { @@ -1054,7 +1054,7 @@ class WCF return PageCache::getInstance()->getPage($metaData['cms']['pageID']); } - return; + return null; } return PageCache::getInstance()->getPageByController(self::getActiveRequest()->getClassName()); diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index d6485d62e8..f3f8e50852 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -340,7 +340,7 @@ class ClipboardHandler extends SingletonFactory // get objects $this->loadMarkedItems(); if (empty($this->markedItems)) { - return; + return null; } $this->pageClasses = $pages; diff --git a/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php b/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php index fb946929af..c7ac51af62 100644 --- a/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php +++ b/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php @@ -58,7 +58,7 @@ class DevtoolsSetup extends SingletonFactory public function getDatabaseConfig() { if (!isset($this->configuration['setup']) || !isset($this->configuration['setup']['database'])) { - return; + return null; } // dirname return a single backslash on Windows if there are no parent directories diff --git a/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php index d1ddc58c1c..02303db33c 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php @@ -215,7 +215,7 @@ class DateFormField extends AbstractFormField implements } if ($dateTime === false) { - return; + return null; } return $dateTime; diff --git a/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php b/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php index ae6aac8b2c..7ee4604d48 100644 --- a/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php +++ b/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php @@ -90,12 +90,12 @@ class ImportHandler extends SingletonFactory implements IAJAXInvokeAction * * @param string $type * @param mixed $oldID - * @return int $newID + * @return int|null */ public function getNewID($type, $oldID) { if (!$oldID) { - return; + return null; } $objectTypeID = $this->objectTypes[$type]->objectTypeID; diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index e9613aaabf..5f382bacdb 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -50,13 +50,13 @@ class LanguageFactory extends SingletonFactory * Returns a Language object for the language with the given id. * * @param int $languageID - * @return Language + * @return Language|null */ public function getLanguage($languageID) { if (!isset($this->languages[$languageID])) { if (!isset($this->cache['languages'][$languageID])) { - return; + return null; } $this->languages[$languageID] = $this->cache['languages'][$languageID]; diff --git a/wcfsetup/install/files/lib/system/menu/user/profile/UserProfileMenu.class.php b/wcfsetup/install/files/lib/system/menu/user/profile/UserProfileMenu.class.php index cef1acb074..b85086104c 100644 --- a/wcfsetup/install/files/lib/system/menu/user/profile/UserProfileMenu.class.php +++ b/wcfsetup/install/files/lib/system/menu/user/profile/UserProfileMenu.class.php @@ -112,12 +112,12 @@ class UserProfileMenu extends SingletonFactory * Returns the first visible menu item. * * @param int $userID - * @return UserProfileMenuItem + * @return UserProfileMenuItem|null */ public function getActiveMenuItem($userID = 0) { if (empty($this->menuItems)) { - return; + return null; } if ($this->activeMenuItem === null) { diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index edb123972f..ee98ad09be 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -896,7 +896,7 @@ class PackageInstallationDispatcher * Prompts for a text input for package directory (applies for applications only) * * @param string $applicationDirectory - * @return FormDocument + * @return FormDocument|null */ protected function promptPackageDir($applicationDirectory) { @@ -1031,7 +1031,7 @@ class PackageInstallationDispatcher FileUtil::makeWritable($packageDir); } - return; + return null; } } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index 833326405b..91a9f30633 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -813,7 +813,7 @@ class PackageInstallationNodeBuilder if ($row === false) { // PHP <7.4 _silently_ returns `null` when attempting to read an array index // when the source value equals `false`. - return; + return null; } return $row['queueID']; diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php index 1d53f96ebf..469aa24403 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php @@ -214,7 +214,7 @@ class PackageInstallationSQLParser extends SQLParser * * @param string $tableName * @param string $columnName - * @return int package id + * @return int|null package id */ protected function getColumnOwnerID($tableName, $columnName) { @@ -233,7 +233,7 @@ class PackageInstallationSQLParser extends SQLParser } elseif (isset($this->knownTables[$tableName])) { return $this->knownTables[$tableName]; } else { - return; + return null; } } diff --git a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php index 8c87c36cc3..d2284c1e88 100644 --- a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php +++ b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php @@ -265,7 +265,7 @@ class ControllerMap extends SingletonFactory $controller = $data[1]; if ($application === 'wcf' && empty($controller)) { - return; + return null; } elseif (\preg_match('~^__WCF_CMS__(?P\d+)$~', $controller, $matches)) { $cmsPageData = $this->lookupCmsPage($matches['pageID'], 0); if ($cmsPageData === null) { @@ -442,17 +442,17 @@ class ControllerMap extends SingletonFactory if ($pageType === 'action' && $application !== 'wcf') { $className = 'wcf\\' . ($isAcpRequest ? 'acp\\' : '') . $pageType . '\\' . $controller . \ucfirst($pageType); if (!\class_exists($className)) { - return; + return null; } } else { - return; + return null; } } // check for abstract classes $reflectionClass = new \ReflectionClass($className); if ($reflectionClass->isAbstract()) { - return; + return null; } return [ diff --git a/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php b/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php index 1c2d04d89e..e43de5a70c 100644 --- a/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php +++ b/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php @@ -257,7 +257,7 @@ class TagEngine extends SingletonFactory { $existingTags = $this->getObjectTags($objectType, $objectID); if (empty($existingTags)) { - return; + return null; } $languageIDs = []; diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index a910ef33e7..cbf84b0537 100755 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -801,12 +801,12 @@ class TemplateEngine extends SingletonFactory * * @param string $templateName * @param string $filename - * @return array + * @return array|null */ protected function getMetaData($templateName, $filename) { if (!\file_exists($filename) || !\is_readable($filename)) { - return; + return null; } // get file contents @@ -815,7 +815,7 @@ class TemplateEngine extends SingletonFactory // find first newline $position = \strpos($contents, "\n"); if ($position === false) { - return; + return null; } // cut contents @@ -824,7 +824,7 @@ class TemplateEngine extends SingletonFactory // read serializes data $data = @\unserialize($contents); if ($data === false || !\is_array($data)) { - return; + return null; } return $data; diff --git a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php index 4815467892..9213f606bb 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -596,12 +596,12 @@ class UserNotificationHandler extends SingletonFactory * * @param string $objectType * @param string $eventName - * @return IUserNotificationEvent + * @return IUserNotificationEvent|null */ public function getEvent($objectType, $eventName) { if (!isset($this->availableEvents[$objectType][$eventName])) { - return; + return null; } return $this->availableEvents[$objectType][$eventName]; diff --git a/wcfsetup/install/files/lib/util/DOMUtil.class.php b/wcfsetup/install/files/lib/util/DOMUtil.class.php index 13f2fa8804..5dd8dc31d2 100644 --- a/wcfsetup/install/files/lib/util/DOMUtil.class.php +++ b/wcfsetup/install/files/lib/util/DOMUtil.class.php @@ -139,7 +139,7 @@ final class DOMUtil public static function getParentBefore(\DOMNode $node, \DOMElement $ancestor) { if ($node->parentNode === $ancestor) { - return; + return null; } $parents = self::getParents($node);