Improve IDE recognition of variable types
authorMatthias Schmidt <gravatronics@live.com>
Mon, 26 Apr 2021 09:48:52 +0000 (11:48 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 26 Apr 2021 09:48:52 +0000 (11:48 +0200)
files/lib/data/conversation/label/ConversationLabelAction.class.php
files/lib/page/ConversationPage.class.php
files/lib/system/user/notification/event/ConversationMessageUserNotificationEvent.class.php
files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php

index 0795888447f8768a8772938412fa5e3265b576b9..577cb7ef364b7170b80f387f503675b3ee5503b5 100644 (file)
@@ -61,11 +61,7 @@ class ConversationLabelAction extends AbstractDatabaseObjectAction
     {
         parent::validateUpdate();
 
-        if (\count($this->objects) != 1) {
-            throw new UserInputException('objectID');
-        }
-
-        $label = \current($this->objects);
+        $label = $this->getSingleObject();
         if ($label->userID != WCF::getUser()->userID) {
             throw new PermissionDeniedException();
         }
@@ -78,11 +74,7 @@ class ConversationLabelAction extends AbstractDatabaseObjectAction
     {
         parent::validateDelete();
 
-        if (\count($this->objects) != 1) {
-            throw new UserInputException('objectID');
-        }
-
-        $label = \current($this->objects);
+        $label = $this->getSingleObject();
         if ($label->userID != WCF::getUser()->userID) {
             throw new PermissionDeniedException();
         }
index 3760c1941a2144cd023a76dfb6d589ae93906542..fc7875fcbb59aa922a996d70b367e911a2cd963f 100644 (file)
@@ -297,6 +297,7 @@ class ConversationPage extends MultipleLinkPage
         $invisibleParticipantIDs = [];
         if (WCF::getUser()->userID != $this->conversation->userID) {
             foreach ($this->participantList as $participant) {
+                /** @noinspection PhpUndefinedFieldInspection */
                 if ($participant->isInvisible) {
                     $invisibleParticipantIDs[] = $participant->userID;
                 }
index c753a8e7d65f99e9caf6a2ddb1c1726ea10ecc5f..16a4ce92d2768e9037c3fb0e9902cc737b376274 100644 (file)
@@ -85,7 +85,7 @@ class ConversationMessageUserNotificationEvent extends AbstractUserNotificationE
             'variables' => [
                 'author' => $this->author,
                 'message' => $this->userNotificationObject,
-                'conversation' => $this->userNotificationObject->getConversation(),
+                'conversation' => $this->getUserNotificationObject()->getConversation(),
             ],
         ];
     }
@@ -103,7 +103,7 @@ class ConversationMessageUserNotificationEvent extends AbstractUserNotificationE
         return $this->getLanguage()->getDynamicVariable('wcf.user.notification.conversation.message.mail.title', [
             'author' => $this->author,
             'message' => $this->userNotificationObject,
-            'conversation' => $this->userNotificationObject->getConversation(),
+            'conversation' => $this->getUserNotificationObject()->getConversation(),
         ]);
     }
 
index 5e044a144b77d2013c13a885d012c3631adb35d5..35ac6788c7f14e04a8e2c950bff23c61ddc4a592 100644 (file)
@@ -97,15 +97,14 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker
 
         // retrieve permissions
         $userIDs = [];
-        foreach ($this->objectList as $object) {
+        foreach ($this->getObjectList() as $object) {
             // passing `0` is actually valid, because it won't yield any results when querying the group membership
             $userIDs[] = ($object->userID ?: 0);
         }
         $userPermissions = $this->getBulkUserPermissions($userIDs, ['user.message.disallowedBBCodes']);
 
         $updateData = [];
-        /** @var ConversationMessage $message */
-        foreach ($this->objectList as $message) {
+        foreach ($this->getObjectList() as $message) {
             SearchIndexManager::getInstance()->set(
                 'com.woltlab.wcf.conversation.message',
                 $message->messageID,