[TOOLS] Fix errors found by PHPStan

This commit is contained in:
Hugo Sales 2022-01-02 21:44:45 +00:00 committed by Diogo Peralta Cordeiro
parent 8fa04bb47d
commit 9e0a2dd4a0
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 11 additions and 11 deletions

View File

@ -253,17 +253,16 @@ class Posting extends Component
DB::persist($activity);
if (!\is_null($target)) {
switch ($target[0]) {
case '!':
$target = \is_int($target) ? Actor::getById($target) : $target;
$mentions[] = [
'mentioned' => [LocalGroup::getActorByNickname(mb_substr($target, 1))],
'type' => 'group',
'text' => mb_substr($target, 1),
'mentioned' => [$target],
'type' => match ($target->getType()) {
Actor::PERSON => 'mention',
Actor::GROUP => 'group',
default => throw new ClientException(_m('Unknown target type give in \'In\' field: {target}', ['{target}' => $target?->getNickname() ?? '<null>'])),
},
'text' => $target->getNickname(),
];
break;
default:
throw new ClientException(_m('Unknown target type give in \'In\' field: ' . $target));
}
}
$mention_ids = F\unique(F\flat_map($mentions, fn (array $m) => F\map($m['mentioned'] ?? [], fn (Actor $a) => $a->getId())));

View File

@ -26,6 +26,7 @@ namespace Plugin\Directory\Controller;
use App\Core\DB\DB;
use function App\Core\I18n\_m;
use App\Entity\Actor;
use App\Util\Common;
use App\Util\Exception\BugFoundException;
use App\Util\Exception\ClientException;
use Component\Collection\Util\Controller\CircleController;