From: Matthias Schmidt Date: Sun, 2 Oct 2016 08:56:32 +0000 (+0200) Subject: Improve code for better code analysis by IDE X-Git-Tag: 3.0.0_Beta_2~33 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8e38b649e2d6b6ccca4dd94b8aa8e92b9a474f31;p=GitHub%2FWoltLab%2FWCF.git Improve code for better code analysis by IDE --- diff --git a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php index bebd4f90d6..a8257fcf83 100644 --- a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php +++ b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php @@ -16,6 +16,7 @@ use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\like\LikeHandler; use wcf\system\user\activity\event\UserActivityEventHandler; +use wcf\system\user\notification\object\type\ICommentUserNotificationObjectType; use wcf\system\user\notification\object\type\IMultiRecipientCommentUserNotificationObjectType; use wcf\system\user\notification\object\CommentResponseUserNotificationObject; use wcf\system\user\notification\object\CommentUserNotificationObject; @@ -273,6 +274,8 @@ class CommentAction extends AbstractDatabaseObjectAction { } } else { + /** @var ICommentUserNotificationObjectType $notificationObjectType */ + $userID = $notificationObjectType->getOwnerID($this->createdComment->commentID); if ($userID != WCF::getUser()->userID) { UserNotificationHandler::getInstance()->fireEvent( @@ -405,6 +408,8 @@ class CommentAction extends AbstractDatabaseObjectAction { } } else { + /** @var ICommentUserNotificationObjectType $notificationObjectType */ + $userID = $notificationObjectType->getOwnerID($this->comment->commentID); if ($this->comment->userID != WCF::getUser()->userID) { diff --git a/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php b/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php index e1e1cd515f..bf54e69b5f 100644 --- a/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php +++ b/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php @@ -23,6 +23,9 @@ class TemplateGroup extends DatabaseObject { */ protected static $databaseTableIndexName = 'templateGroupID'; + /** + * @var TemplateGroup[][] + */ protected static $templateGroupStructure = null; protected static $selectList = null; diff --git a/wcfsetup/install/files/lib/system/database/Redis.class.php b/wcfsetup/install/files/lib/system/database/Redis.class.php index 73fd8851e4..17026d4927 100644 --- a/wcfsetup/install/files/lib/system/database/Redis.class.php +++ b/wcfsetup/install/files/lib/system/database/Redis.class.php @@ -10,6 +10,18 @@ use wcf\util\StringUtil; * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Database + * + * @method integer del($key1, $key2 = null, $key3 = null) + * @method boolean expire($key, $ttl) + * @method string|bool get($key) + * @method integer hDel($key, $hashKey1, $hashKey2 = null, $hashKeyN = null) + * @method string hGet($key, $hashKey) + * @method integer hSet($key, $hashKey, $value) + * @method integer incr($key) + * @method string info($option = null) + * @method boolean setex($key, $ttl, $value) + * @method boolean setnx($key, $value) + * @method integer ttl($key) */ class Redis { /** diff --git a/wcfsetup/install/files/lib/system/email/mime/MultipartAlternativeMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/MultipartAlternativeMimePart.class.php index 5ee037bb57..e35535b9bc 100644 --- a/wcfsetup/install/files/lib/system/email/mime/MultipartAlternativeMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/MultipartAlternativeMimePart.class.php @@ -22,6 +22,8 @@ class MultipartAlternativeMimePart extends AbstractMultipartMimePart { * @inheritDoc */ protected function getConcatenatedParts($parts) { + /** @var \SplObjectStorage $parts */ + $sortedParts = new \SplPriorityQueue(); $parts->rewind(); diff --git a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php index f774ae4342..5903fcf6dd 100644 --- a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php @@ -186,7 +186,10 @@ class UserOptionHandler extends OptionHandler { * @inheritDoc */ protected function getFormElement($type, Option $option) { - if ($this->searchMode) return $this->getTypeObject($type)->getSearchFormElement($option, (isset($this->optionValues[$option->optionName]) ? $this->optionValues[$option->optionName] : null)); + if ($this->searchMode) { + /** @noinspection PhpUndefinedMethodInspection */ + return $this->getTypeObject($type)->getSearchFormElement($option, (isset($this->optionValues[$option->optionName]) ? $this->optionValues[$option->optionName] : null)); + } return parent::getFormElement($type, $option); } diff --git a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryLookupPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryLookupPageHandler.class.php index c21df7092a..72e4c5d16e 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryLookupPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryLookupPageHandler.class.php @@ -4,6 +4,7 @@ use wcf\data\category\AbstractDecoratedCategory; use wcf\data\object\type\ObjectTypeCache; use wcf\data\ILinkableObject; use wcf\system\database\util\PreparedStatementConditionBuilder; +use wcf\system\exception\ImplementationException; use wcf\system\exception\ParentClassException; use wcf\system\WCF; @@ -32,6 +33,9 @@ trait TDecoratedCategoryLookupPageHandler { */ public function getLink($objectID) { $className = $this->getDecoratedCategoryClass(); + + /** @var AbstractDecoratedCategory $category */ + /** @noinspection PhpUndefinedMethodInspection */ $category = $className::getCategory($objectID); if ($category instanceof ILinkableObject) { @@ -47,6 +51,7 @@ trait TDecoratedCategoryLookupPageHandler { public function isValid($objectID = null) { $className = $this->getDecoratedCategoryClass(); + /** @noinspection PhpUndefinedMethodInspection */ return $className::getCategory($objectID)->isAccessible(); } @@ -58,6 +63,9 @@ trait TDecoratedCategoryLookupPageHandler { if (!is_subclass_of($className, AbstractDecoratedCategory::class)) { throw new ParentClassException($className, AbstractDecoratedCategory::class); } + if (!is_subclass_of($className, ILinkableObject::class)) { + throw new ImplementationException($className, ILinkableObject::class); + } if (!defined($className.'::OBJECT_TYPE_NAME')) { throw new \LogicException("Class '{$className}' has no constant 'OBJECT_TYPE_NAME'."); } @@ -74,7 +82,8 @@ trait TDecoratedCategoryLookupPageHandler { $statement->execute($conditionBuilder->getParameters()); $results = []; while ($categoryID = $statement->fetchColumn()) { - /** @var AbstractDecoratedCategory $category */ + /** @var AbstractDecoratedCategory|ILinkableObject $category */ + /** @noinspection PhpUndefinedMethodInspection */ $category = $className::getCategory($categoryID); // build hierarchy diff --git a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php index 585d5b0fae..1e8042e4df 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php @@ -27,6 +27,7 @@ trait TDecoratedCategoryMenuPageHandler { $className = $this->getDecoratedCategoryClass(); /** @var AbstractDecoratedCategory $category */ + /** @noinspection PhpUndefinedMethodInspection */ $category = $className::getCategory($objectID); // check if category exists diff --git a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php index b85151dbbb..ed3f48ff28 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php @@ -40,6 +40,7 @@ trait TDecoratedCategoryOnlineLocationPageHandler { } /** @var AbstractDecoratedCategory $category */ + /** @noinspection PhpUndefinedMethodInspection */ $category = $className::getCategory($user->pageObjectID); if ($category === null) { return ''; diff --git a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php index ffe08c3368..aa20d7ec60 100644 --- a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php @@ -1,6 +1,7 @@ editorClassName($object))->update([ + /** @var DatabaseObjectEditor $editor */ + $editor = new $this->editorClassName($object); + $editor->update([ 'height' => $object->width, 'width' => $object->height, 'filesize' => filesize($object->getLocation()) @@ -189,11 +192,15 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { $this->objects[$uploadFile->getInternalFileID()] = $object; } catch (SystemException $e) { - (new $this->editorClassName($object))->delete(); + /** @var DatabaseObjectEditor $editor */ + $editor = new $this->editorClassName($object); + $editor->delete(); } } else { - (new $this->editorClassName($object))->delete(); + /** @var DatabaseObjectEditor $editor */ + $editor = new $this->editorClassName($object); + $editor->delete(); } if ($object->isImage && !empty($this->options['generateThumbnails']) && $object instanceof IThumbnailFile) { @@ -201,7 +208,9 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy { $this->generateThumbnails($object); } catch (SystemException $e) { - (new $this->editorClassName($object))->delete(); + /** @var DatabaseObjectEditor $editor */ + $editor = new $this->editorClassName($object); + $editor->delete(); } } }