3535 * @copyright 2001-2025 WoltLab GmbH
3636 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
3737 *
38- * @property Conversation $formObject
38+ * @extends AbstractFormBuilderForm< Conversation>
3939 */
4040class ConversationAddForm extends AbstractFormBuilderForm
4141{
@@ -77,7 +77,8 @@ public function createForm()
7777
7878 $ groupParticipants = \array_filter (
7979 UserGroupCacheBuilder::getInstance ()->getData ([], 'groups ' ),
80- function (UserGroup $ group ) {
80+ static function (UserGroup $ group ) {
81+ // @phpstan-ignore property.notFound
8182 return $ group ->canBeAddedAsConversationParticipant ;
8283 }
8384 );
@@ -100,8 +101,8 @@ function (UserGroup $group) {
100101 ->label ('wcf.conversation.participants ' )
101102 ->description ('wcf.conversation.participants.description ' )
102103 ->maximumMultiples (WCF ::getSession ()->getPermission ('user.conversation.maxParticipants ' ))
103- ->addValidator (ConversationAddForm ::getParticipantsValidator ())
104- ->addValidator (ConversationAddForm ::getMaximumParticipantsValidator ()),
104+ ->addValidator (self ::getParticipantsValidator ())
105+ ->addValidator (self ::getMaximumParticipantsValidator ()),
105106 BooleanFormField::create ('addGroupParticipants ' )
106107 ->label ('wcf.conversation.addGroupParticipants ' )
107108 ->available (\count ($ groupParticipants ) > 0 ),
@@ -119,11 +120,11 @@ function (UserGroup $group) {
119120 ->description ('wcf.conversation.invisibleParticipants.description ' )
120121 ->available (WCF ::getSession ()->getPermission ('user.conversation.canAddInvisibleParticipants ' ))
121122 ->maximumMultiples (WCF ::getSession ()->getPermission ('user.conversation.maxParticipants ' ))
122- ->addValidator (ConversationAddForm ::getParticipantsValidator ())
123+ ->addValidator (self ::getParticipantsValidator ())
123124 ->addValidator (
124125 new FormFieldValidator (
125126 'duplicateParticipantsValidator ' ,
126- function (UserFormField $ formField ) {
127+ static function (UserFormField $ formField ) {
127128 /** @var UserFormField $participantsFormField */
128129 $ participantsFormField = $ formField ->getDocument ()->getNodeById ('participants ' );
129130
@@ -142,7 +143,7 @@ function (UserFormField $formField) {
142143 'intersects ' ,
143144 'wcf.conversation.participants.error.intersects ' ,
144145 [
145- 'username ' => $ user ->username
146+ 'username ' => $ user ->username ,
146147 ]
147148 )
148149 );
@@ -171,15 +172,15 @@ function (UserFormField $formField) {
171172 ),
172173 BooleanFormField::create ('participantCanInvite ' )
173174 ->label ('wcf.conversation.participantCanInvite ' )
174- ->available (WCF ::getSession ()->getPermission ('user.conversation.canSetCanInvite ' ))
175+ ->available (WCF ::getSession ()->getPermission ('user.conversation.canSetCanInvite ' )),
175176 ]),
176177 WysiwygFormContainer::create ('message ' )
177178 ->label ('wcf.conversation.message ' )
178179 ->messageObjectType ('com.woltlab.wcf.conversation.message ' )
179180 ->attachmentData ('com.woltlab.wcf.conversation.message ' )
180181 ->supportMentions ()
181182 ->supportQuotes ()
182- ->required ()
183+ ->required (),
183184 ]);
184185 }
185186
@@ -204,11 +205,11 @@ protected function finalizeForm()
204205 ->addProcessor (new VoidFormDataProcessor ('addGroupParticipants ' ))
205206 ->addProcessor (new VoidFormDataProcessor ('addInvisibleGroupParticipants ' ))
206207 ->addProcessor (
207- new CustomFormDataProcessor ('messageProcessor ' , function (IFormDocument $ document , array $ parameters ) {
208+ new CustomFormDataProcessor ('messageProcessor ' , static function (IFormDocument $ document , array $ parameters ) {
208209 unset($ parameters ['data ' ]['message ' ]);
209210
210211 return $ parameters ;
211- }, function (IFormDocument $ document , array $ data , IStorableObject $ object ) {
212+ }, static function (IFormDocument $ document , array $ data , IStorableObject $ object ) {
212213 \assert ($ object instanceof Conversation);
213214 $ data ['message ' ] = $ object ->getFirstMessage ()->message ;
214215
@@ -218,7 +219,7 @@ protected function finalizeForm()
218219 ->addProcessor (
219220 new CustomFormDataProcessor (
220221 'participantsProcessor ' ,
221- function (IFormDocument $ document , array $ parameters ) {
222+ static function (IFormDocument $ document , array $ parameters ) {
222223 $ participants = $ parameters ['participants ' ] ?? [];
223224 $ invisibleParticipants = $ parameters ['invisibleParticipants ' ] ?? [];
224225
@@ -255,7 +256,7 @@ function (IFormDocument $document, array $parameters) {
255256 ->addProcessor (
256257 new CustomFormDataProcessor (
257258 'draftDataProcessor ' ,
258- function (IFormDocument $ document , array $ parameters ) {
259+ static function (IFormDocument $ document , array $ parameters ) {
259260 if ($ parameters ['data ' ]['isDraft ' ]) {
260261 $ parameters ['data ' ]['draftData ' ] = \serialize ([
261262 'participants ' => $ parameters ['participants ' ] ?? [],
@@ -269,7 +270,7 @@ function (IFormDocument $document, array $parameters) {
269270
270271 return $ parameters ;
271272 },
272- function (IFormDocument $ document , array $ data , IStorableObject $ object ) {
273+ static function (IFormDocument $ document , array $ data , IStorableObject $ object ) {
273274 \assert ($ object instanceof Conversation);
274275
275276 $ draftData = @\unserialize ($ object ->draftData );
@@ -289,7 +290,7 @@ public function saved()
289290 parent ::saved ();
290291
291292 /** @var Conversation $conversation */
292- if ($ this ->formAction == 'create ' ) {
293+ if ($ this ->formAction === 'create ' ) {
293294 $ conversation = $ this ->objectAction ->getReturnValues ()['returnValues ' ];
294295 } else {
295296 $ conversation = new Conversation ($ this ->formObject ->conversationID );
@@ -313,7 +314,7 @@ public function saved()
313314 */
314315 public static function getParticipantsValidator (): FormFieldValidator
315316 {
316- return new FormFieldValidator ('participantsValidator ' , function (UserFormField $ formField ) {
317+ return new FormFieldValidator ('participantsValidator ' , static function (UserFormField $ formField ) {
317318 $ users = $ formField ->getUsers ();
318319 $ userIDs = \array_column ($ users , 'userID ' );
319320
@@ -332,7 +333,7 @@ public static function getParticipantsValidator(): FormFieldValidator
332333 $ e ->getType (),
333334 'wcf.conversation.participants.error. ' . $ e ->getType (),
334335 [
335- 'username ' => $ user ->username
336+ 'username ' => $ user ->username ,
336337 ]
337338 )
338339 );
@@ -353,7 +354,7 @@ public static function getMaximumParticipantsValidator(
353354 ): FormFieldValidator {
354355 return new FormFieldValidator (
355356 'participantsMaximumValidator ' ,
356- function (UserFormField $ formField ) use (
357+ static function (UserFormField $ formField ) use (
357358 $ invisibleParticipantsFieldId ,
358359 $ participantGroupsFieldId ,
359360 $ invisibleParticipantGroupsFieldId
@@ -370,7 +371,6 @@ function (UserFormField $formField) use (
370371 ->getNodeById ($ participantGroupsFieldId );
371372 $ invisibleParticipantGroupsFormField = $ formField ->getDocument ()
372373 ->getNodeById ($ invisibleParticipantGroupsFieldId );
373-
374374 $ groupIDs = \array_merge (
375375 $ participantGroupsFormField ?->getValue() ?: [],
376376 $ invisibleParticipantGroupsFormField ?->getValue() ?: [],
@@ -396,6 +396,8 @@ function (UserFormField $formField) use (
396396 /**
397397 * Returns the user IDs of the users that are in the given groups.
398398 *
399+ * @param int[] $groupIDs
400+ *
399401 * @return int[]
400402 */
401403 public static function getUserByGroups (array $ groupIDs ): array
0 commit comments