Browse Source

fix(psalm): Work around a psalm bug introduced with 5.18.0

Ref https://github.com/vimeo/psalm/issues/10534

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/11288/head
Joas Schilling 2 years ago
parent
commit
0e220a35b0
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 15
      lib/Service/RoomService.php

15
lib/Service/RoomService.php

@ -467,23 +467,24 @@ class RoomService {
/**
* @param Room $room
* @param int $newType Currently it is only allowed to change between `Room::TYPE_GROUP` and `Room::TYPE_PUBLIC`
* @param bool $allowSwitchingOneToOne
* @param bool $allowSwitchingOneToOne Allows additionally to change the type from `Room::TYPE_ONE_TO_ONE` to `Room::TYPE_ONE_TO_ONE_FORMER`
* @return bool True when the change was valid, false otherwise
*/
public function setType(Room $room, int $newType, bool $allowSwitchingOneToOne = false): bool {
if ($newType === $room->getType()) {
$oldType = $room->getType();
if ($oldType === $newType) {
return true;
}
if (!$allowSwitchingOneToOne && $room->getType() === Room::TYPE_ONE_TO_ONE) {
if (!$allowSwitchingOneToOne && $oldType === Room::TYPE_ONE_TO_ONE) {
return false;
}
if ($room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
if ($oldType === Room::TYPE_ONE_TO_ONE_FORMER) {
return false;
}
if ($room->getType() === Room::TYPE_NOTE_TO_SELF) {
if ($oldType === Room::TYPE_NOTE_TO_SELF) {
return false;
}
@ -491,7 +492,7 @@ class RoomService {
return false;
}
if ($newType === Room::TYPE_ONE_TO_ONE_FORMER && $room->getType() !== Room::TYPE_ONE_TO_ONE) {
if ($newType === Room::TYPE_ONE_TO_ONE_FORMER && $oldType !== Room::TYPE_ONE_TO_ONE) {
return false;
}
@ -503,8 +504,6 @@ class RoomService {
return false;
}
$oldType = $room->getType();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_TYPE, $newType, $oldType);
$this->dispatcher->dispatchTyped($event);

Loading…
Cancel
Save