Improve code for better code analysis by IDE
authorMatthias Schmidt <gravatronics@live.com>
Sun, 2 Oct 2016 08:56:32 +0000 (10:56 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 2 Oct 2016 08:56:32 +0000 (10:56 +0200)
wcfsetup/install/files/lib/data/comment/CommentAction.class.php
wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php
wcfsetup/install/files/lib/system/database/Redis.class.php
wcfsetup/install/files/lib/system/email/mime/MultipartAlternativeMimePart.class.php
wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php
wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryLookupPageHandler.class.php
wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php
wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php
wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php

index bebd4f90d6736fae5fa7c25ad7bda55fdb2e2c77..a8257fcf8386596781d84085048d96b754aa9c28 100644 (file)
@@ -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) {
index e1e1cd515fe7f7ccdc4961f384fda1226db38b5a..bf54e69b5f806441d76b0852074b02e3c607653d 100644 (file)
@@ -23,6 +23,9 @@ class TemplateGroup extends DatabaseObject {
         */
        protected static $databaseTableIndexName = 'templateGroupID';
        
+       /**
+        * @var TemplateGroup[][]
+        */
        protected static $templateGroupStructure = null;
        protected static $selectList = null;
        
index 73fd8851e4f8bf040911e21483e6397505521a44..17026d492759d26c6161ab886cdc0ec7d29773b4 100644 (file)
@@ -10,6 +10,18 @@ use wcf\util\StringUtil;
  * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @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 {
        /**
index 5ee037bb57939b670466eeb8777169bb6c0ecbfd..e35535b9bcb05b4e175d484b20de0e7db1beb178 100644 (file)
@@ -22,6 +22,8 @@ class MultipartAlternativeMimePart extends AbstractMultipartMimePart {
         * @inheritDoc
         */
        protected function getConcatenatedParts($parts) {
+               /** @var \SplObjectStorage $parts */
+               
                $sortedParts = new \SplPriorityQueue();
                
                $parts->rewind();
index f774ae4342dc75e7462e4085112550754880fc8a..5903fcf6dd1256d50bdae8d7b66b2a49598fb551 100644 (file)
@@ -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);
        }
index c21df7092a55d95ff2403151893f356870bb552b..72e4c5d16ed05ee8b037caeb0e81571ca2c96bdc 100644 (file)
@@ -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
index 585d5b0faeec879b83bb219774e2894c2d462d76..1e8042e4dfefe1163a8d9e08a12a5a9b15591dfa 100644 (file)
@@ -27,6 +27,7 @@ trait TDecoratedCategoryMenuPageHandler {
                $className = $this->getDecoratedCategoryClass();
                
                /** @var AbstractDecoratedCategory $category */
+               /** @noinspection PhpUndefinedMethodInspection */
                $category = $className::getCategory($objectID);
                
                // check if category exists
index b85151dbbb7f789772fcffb1e44419f6f5210716..ed3f48ff28e41e183069a32ccce584f6dc912171 100644 (file)
@@ -40,6 +40,7 @@ trait TDecoratedCategoryOnlineLocationPageHandler {
                }
                
                /** @var AbstractDecoratedCategory $category */
+               /** @noinspection PhpUndefinedMethodInspection */
                $category = $className::getCategory($user->pageObjectID);
                if ($category === null) {
                        return '';
index ffe08c33684d379909ded21b5aa654b37f15a02f..aa20d7ec60b7fb35156cf9e1533193932a18c8bb 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\upload;
 use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\DatabaseObjectEditor;
 use wcf\data\IDatabaseObjectAction;
 use wcf\data\IFile;
 use wcf\data\IThumbnailFile;
@@ -174,7 +175,9 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy {
                                                                        
                                                                        // update width, height and filesize of the object
                                                                        if ($newImage !== null && ($orientation == ExifUtil::ORIENTATION_90_ROTATE || $orientation == ExifUtil::ORIENTATION_270_ROTATE)) {
-                                                                               (new $this->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();
                        }
                }
        }