[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); DB::persist($activity);
if (!\is_null($target)) { if (!\is_null($target)) {
switch ($target[0]) { $target = \is_int($target) ? Actor::getById($target) : $target;
case '!': $mentions[] = [
$mentions[] = [ 'mentioned' => [$target],
'mentioned' => [LocalGroup::getActorByNickname(mb_substr($target, 1))], 'type' => match ($target->getType()) {
'type' => 'group', Actor::PERSON => 'mention',
'text' => mb_substr($target, 1), Actor::GROUP => 'group',
]; default => throw new ClientException(_m('Unknown target type give in \'In\' field: {target}', ['{target}' => $target?->getNickname() ?? '<null>'])),
break; },
default: 'text' => $target->getNickname(),
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()))); $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 App\Core\DB\DB;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Common;
use App\Util\Exception\BugFoundException; use App\Util\Exception\BugFoundException;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use Component\Collection\Util\Controller\CircleController; use Component\Collection\Util\Controller\CircleController;