[TOOLS] Fix errors found by PHPStan

This commit is contained in:
Hugo Sales 2021-12-21 12:17:51 +00:00
parent fa863d9e03
commit da8c41e094
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 19 additions and 6 deletions

View File

@ -87,9 +87,9 @@ class Actor extends ActorController
if ($form->isSubmitted() && $form->isValid()) {
Log::info(
_m(
'Actor id:{actor_id} nick:{actor_nick} created the group {nickname}',
['{actor_id}' => $actor->getId(), 'actor_nick' => $actor->getNickname(), 'nickname' => $nickname],
),
'Actor id:{actor_id} nick:{actor_nick} created the group {nickname}',
['{actor_id}' => $actor->getId(), 'actor_nick' => $actor->getNickname(), 'nickname' => $nickname],
),
);
$group = E\Actor::create([
@ -112,8 +112,8 @@ class Actor extends ActorController
'is_admin' => true,
]));
DB::flush();
Cache::delete(self::cacheKeys($actor->getId())['subscriber']);
Cache::delete(self::cacheKeys($actor->getId())['subscribed']);
Cache::delete(E\Actor::cacheKeys($actor->getId())['subscriber']);
Cache::delete(E\Actor::cacheKeys($actor->getId())['subscribed']);
throw new RedirectException;
}

View File

@ -33,6 +33,10 @@ declare(strict_types = 1);
namespace App\Core\Controller;
use App\Core\Controller;
use App\Core\DB\DB;
use function App\Core\I18n\_m;
use App\Util\Exception\ClientException;
use App\Util\Exception\RedirectException;
abstract class ActorController extends Controller
{
@ -43,7 +47,7 @@ abstract class ActorController extends Controller
{
$actor = DB::findOneBy('actor', ['id' => $id]);
if ($actor->getIsLocal()) {
return new RedirectResponse($actor->getUrl());
throw new RedirectException($actor->getUrl());
}
if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404);

View File

@ -29,6 +29,7 @@ use App\Core\Entity;
use App\Core\Event;
use App\Core\Router\Router;
use App\Core\UserRoles;
use App\Util\Exception\BugFoundException;
use App\Util\Exception\DuplicateFoundException;
use App\Util\Exception\NicknameException;
use App\Util\Exception\NotFoundException;
@ -501,6 +502,9 @@ class Actor extends Entity
break;
case self::GROUP:
$uri = Router::url('group_actor_view_id', ['id' => $this->getId()], $type);
// no break
default:
throw new BugFoundException('Actor type added but `Actor::getUri` was not updated');
}
Event::handle('EndGetActorUri', [$this, $type, &$uri]);
}
@ -521,6 +525,9 @@ class Actor extends Entity
break;
case self::GROUP:
$url = Router::url('group_actor_view_nickname', ['nickname' => $this->getNickname()], $type);
// no break
default:
throw new BugFoundException('Actor type added but `Actor::getUrl` was not updated');
}
} else {
return $this->getUri($type);
@ -540,6 +547,8 @@ class Actor extends Entity
return Router::url('actor_view_nickname', ['nickname' => $nickname], $uri_type);
case self::GROUP:
return Router::url('group_actor_view_nickname', ['nickname' => $nickname], $uri_type);
default:
throw new BugFoundException('Actor type added but `Actor::getPlaceholderUri` was not updated');
}
}