From 94ea2b9fef444c9131976f142344e471f886548a Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 29 May 2016 14:48:17 +0200 Subject: [PATCH] Fix warnings about undefined fields in data classes (WIP) --- .../files/lib/data/ProcessibleDatabaseObject.class.php | 2 ++ .../files/lib/data/acp/menu/item/ACPMenuItem.class.php | 1 + .../files/lib/data/acp/session/log/ACPSessionLog.class.php | 1 + wcfsetup/install/files/lib/data/ad/Ad.class.php | 2 ++ .../install/files/lib/data/comment/LikeableComment.class.php | 4 ++-- .../files/lib/data/comment/LikeableCommentProvider.class.php | 2 ++ .../data/comment/response/LikeableCommentResponse.class.php | 2 +- .../response/LikeableCommentResponseProvider.class.php | 2 ++ .../install/files/lib/data/label/group/LabelGroup.class.php | 3 +++ wcfsetup/install/files/lib/data/language/Language.class.php | 1 + wcfsetup/install/files/lib/data/media/MediaAction.class.php | 2 ++ .../install/files/lib/data/media/ViewableMedia.class.php | 3 +++ wcfsetup/install/files/lib/data/poll/Poll.class.php | 4 +++- wcfsetup/install/files/lib/data/template/Template.class.php | 1 + .../install/files/lib/data/template/TemplateList.class.php | 5 +++++ .../user/activity/event/UserActivityEventAction.class.php | 1 + .../install/files/lib/data/user/online/UserOnline.class.php | 1 + 17 files changed, 33 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php b/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php index 5e5dfa2b6d..b55147132c 100644 --- a/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php @@ -13,6 +13,8 @@ use wcf\system\SingletonFactory; * @package com.woltlab.wcf * @subpackage data * @category Community Framework + * + * @property-read string|null $className */ class ProcessibleDatabaseObject extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php b/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php index c4c3db6164..55753024b8 100644 --- a/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php +++ b/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php @@ -68,6 +68,7 @@ class ACPMenuItem extends DatabaseObject implements ITreeMenuItem { // links of top option category menu items need the id of the option // category if ($this->parentMenuItem == 'wcf.acp.menu.link.option.category') { + /** @noinspection PhpUndefinedFieldInspection */ $linkParameters['id'] = $this->optionCategoryID; } diff --git a/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php b/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php index d1557c4a93..8fa88f91d4 100644 --- a/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php @@ -22,6 +22,7 @@ use wcf\util\UserUtil; * @property-read string $userAgent * @property-read integer $time * @property-read integer $lastActivityTime + * @property-read string|null $active */ class ACPSessionLog extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/data/ad/Ad.class.php b/wcfsetup/install/files/lib/data/ad/Ad.class.php index 9b906193e2..fb296dae08 100644 --- a/wcfsetup/install/files/lib/data/ad/Ad.class.php +++ b/wcfsetup/install/files/lib/data/ad/Ad.class.php @@ -53,7 +53,9 @@ class Ad extends DatabaseObject implements IRouteController { $objectType = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); $location = WCF::getLanguage()->get('wcf.acp.ad.location.'.$objectType->objectType); + /** @noinspection PhpUndefinedFieldInspection */ if ($objectType->categoryname != 'com.woltlab.wcf.global') { + /** @noinspection PhpUndefinedFieldInspection */ $location = WCF::getLanguage()->get('wcf.acp.ad.location.category.'.$objectType->categoryname).': '.$location; } diff --git a/wcfsetup/install/files/lib/data/comment/LikeableComment.class.php b/wcfsetup/install/files/lib/data/comment/LikeableComment.class.php index cea7adee01..b123d12777 100644 --- a/wcfsetup/install/files/lib/data/comment/LikeableComment.class.php +++ b/wcfsetup/install/files/lib/data/comment/LikeableComment.class.php @@ -63,12 +63,12 @@ class LikeableComment extends AbstractLikeObject { * @inheritDoc */ public function sendNotification(Like $like) { - $objectType = CommentHandler::getInstance()->getObjectType($this->object->objectTypeID); + $objectType = CommentHandler::getInstance()->getObjectType($this->getDecoratedObject()->objectTypeID); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.like.notification')) { if ($this->userID != WCF::getUser()->userID) { $notificationObject = new LikeUserNotificationObject($like); UserNotificationHandler::getInstance()->fireEvent('like', $objectType->objectType.'.like.notification', $notificationObject, [$this->userID], [ - 'objectID' => $this->object->objectID, + 'objectID' => $this->getDecoratedObject()->objectID, 'objectOwnerID' => $this->userID ]); } diff --git a/wcfsetup/install/files/lib/data/comment/LikeableCommentProvider.class.php b/wcfsetup/install/files/lib/data/comment/LikeableCommentProvider.class.php index 4c54e29e2a..912e050154 100644 --- a/wcfsetup/install/files/lib/data/comment/LikeableCommentProvider.class.php +++ b/wcfsetup/install/files/lib/data/comment/LikeableCommentProvider.class.php @@ -39,6 +39,8 @@ class LikeableCommentProvider extends AbstractObjectTypeProvider implements ILik * @inheritDoc */ public function checkPermissions(ILikeObject $comment) { + /** @var Comment $comment */ + if (!$comment->commentID) return false; $objectType = CommentHandler::getInstance()->getObjectType($comment->objectTypeID); diff --git a/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponse.class.php b/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponse.class.php index d14e8884a9..6d6c073d2e 100644 --- a/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponse.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponse.class.php @@ -64,7 +64,7 @@ class LikeableCommentResponse extends AbstractLikeObject { * @inheritDoc */ public function sendNotification(Like $like) { - $comment = new Comment($this->object->commentID); + $comment = new Comment($this->getDecoratedObject()->commentID); $objectType = CommentHandler::getInstance()->getObjectType($comment->objectTypeID); if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.like.notification')) { if ($this->userID != WCF::getUser()->userID) { diff --git a/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponseProvider.class.php b/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponseProvider.class.php index fd8e9b49c0..042b51ad0a 100644 --- a/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponseProvider.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponseProvider.class.php @@ -42,6 +42,8 @@ class LikeableCommentResponseProvider extends AbstractObjectTypeProvider impleme * @inheritDoc */ public function checkPermissions(ILikeObject $response) { + /** @var CommentResponse $response */ + if (!$response->responseID) return false; $comment = new Comment($response->commentID); if (!$comment->commentID) { diff --git a/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php b/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php index 4e20ab7288..737f01e0f1 100644 --- a/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php +++ b/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php @@ -55,10 +55,13 @@ class LabelGroup extends DatabaseObject implements IRouteController { * @return integer */ public static function sortLabelGroups(DatabaseObject $groupA, DatabaseObject $groupB) { + /** @noinspection PhpUndefinedFieldInspection */ if ($groupA->showOrder == $groupB->showOrder) { + /** @noinspection PhpUndefinedFieldInspection */ return ($groupA->groupID > $groupB->groupID) ? 1 : -1; } + /** @noinspection PhpUndefinedFieldInspection */ return ($groupA->showOrder > $groupB->showOrder) ? 1 : -1; } } diff --git a/wcfsetup/install/files/lib/data/language/Language.class.php b/wcfsetup/install/files/lib/data/language/Language.class.php index 51d32752f2..641137e694 100644 --- a/wcfsetup/install/files/lib/data/language/Language.class.php +++ b/wcfsetup/install/files/lib/data/language/Language.class.php @@ -20,6 +20,7 @@ use wcf\system\WCF; * @property-read string $countryCode * @property-read integer $isDefault * @property-read integer $hasContent + * @property-read integer $isDisabled */ class Language extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/data/media/MediaAction.class.php b/wcfsetup/install/files/lib/data/media/MediaAction.class.php index cbe6d5e317..32c2df9e00 100644 --- a/wcfsetup/install/files/lib/data/media/MediaAction.class.php +++ b/wcfsetup/install/files/lib/data/media/MediaAction.class.php @@ -60,6 +60,8 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction, /** @noinspection PhpUndefinedMethodInspection */ $this->parameters['__files']->saveFiles($saveStrategy); + + /** @var Media[] $mediaFiles */ $mediaFiles = $saveStrategy->getObjects(); $result = [ diff --git a/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php b/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php index 83a32b7b13..c1337634cd 100644 --- a/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php +++ b/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php @@ -18,6 +18,9 @@ use wcf\util\StringUtil; * * @method Media getDecoratedObject() * @mixin Media + * @property-read string|null $title + * @property-read string|null $description + * @property-read string|null $altText */ class ViewableMedia extends DatabaseObjectDecorator { /** diff --git a/wcfsetup/install/files/lib/data/poll/Poll.class.php b/wcfsetup/install/files/lib/data/poll/Poll.class.php index b372d9d901..5f2069f568 100644 --- a/wcfsetup/install/files/lib/data/poll/Poll.class.php +++ b/wcfsetup/install/files/lib/data/poll/Poll.class.php @@ -61,12 +61,13 @@ class Poll extends DatabaseObject { /** * Adds an option to current poll. * - * @param \wcf\data\poll\option\PollOption $option + * @param PollOption $option */ public function addOption(PollOption $option) { if ($option->pollID == $this->pollID) { $this->options[$option->optionID] = $option; + /** @noinspection PhpUndefinedFieldInspection */ if ($option->voted) { $this->isParticipant = true; } @@ -124,6 +125,7 @@ class Poll extends DatabaseObject { foreach ($optionList as $option) { $this->options[$option->optionID] = $option; + /** @noinspection PhpUndefinedFieldInspection */ if ($option->voted) { $this->isParticipant = true; } diff --git a/wcfsetup/install/files/lib/data/template/Template.class.php b/wcfsetup/install/files/lib/data/template/Template.class.php index 374faceeb9..fd87d12f25 100644 --- a/wcfsetup/install/files/lib/data/template/Template.class.php +++ b/wcfsetup/install/files/lib/data/template/Template.class.php @@ -80,6 +80,7 @@ class Template extends DatabaseObject { * @return string */ public function getPath() { + /** @noinspection PhpUndefinedFieldInspection */ $path = FileUtil::getRealPath(WCF_DIR . $this->packageDir) . 'templates/' . $this->templateGroupFolderName . $this->templateName . '.tpl'; return $path; } diff --git a/wcfsetup/install/files/lib/data/template/TemplateList.class.php b/wcfsetup/install/files/lib/data/template/TemplateList.class.php index 7ffcb30073..6927d89581 100644 --- a/wcfsetup/install/files/lib/data/template/TemplateList.class.php +++ b/wcfsetup/install/files/lib/data/template/TemplateList.class.php @@ -13,6 +13,11 @@ use wcf\system\application\ApplicationHandler; * @package com.woltlab.wcf * @subpackage data.template * @category Community Framework + * + * @method Template current() + * @method Template[] getObjects() + * @method Template|null search($objectID) + * @property Template[] $objects */ class TemplateList extends DatabaseObjectList { /** diff --git a/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php b/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php index 3fac100a28..603c4af071 100644 --- a/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php +++ b/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php @@ -96,6 +96,7 @@ class UserActivityEventAction extends AbstractDatabaseObjectAction { public function validateSwitchContext() { } public function switchContext() { + /** @noinspection PhpUndefinedFieldInspection */ $userAction = new UserAction([WCF::getUser()], 'update', [ 'options' => [ User::getUserOptionID('recentActivitiesFilterByFollowing') => (WCF::getUser()->recentActivitiesFilterByFollowing ? 0 : 1) 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 c4f30cb0f8..405341b6e4 100644 --- a/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php +++ b/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php @@ -22,6 +22,7 @@ use wcf\util\UserUtil; * @property-read integer|null $pageID * @property-read integer|null $pageObjectID * @property-read integer|null $parentPageObjectID + * @property-read string|null $userOnlineMarking */ class UserOnline extends UserProfile { /** -- 2.20.1