[TOOLS] Run CS-Fixer on whole project

This commit is contained in:
Hugo Sales 2022-02-26 14:45:38 +00:00
parent 255c44bbf0
commit 45c7888676
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
24 changed files with 146 additions and 171 deletions

View File

@ -27,10 +27,7 @@ use App\Core\ActorLocalRoles;
use App\Core\Controller; use App\Core\Controller;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\RedirectResponse;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Common; use App\Util\Common;
@ -38,13 +35,15 @@ use App\Util\Exception\ClientException;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Form\FormFields; use App\Util\Form\FormFields;
use Component\Posting\Posting; use Component\Posting\Posting;
use InvalidArgumentException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException; use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Length;
class Post extends Controller class Post extends Controller
@ -74,23 +73,22 @@ class Post extends Controller
]; ];
Event::handle('PostingAvailableContentTypes', [&$available_content_types]); Event::handle('PostingAvailableContentTypes', [&$available_content_types]);
if (!is_int($this->int('in'))) { if (!\is_int($this->int('in'))) {
throw new \InvalidArgumentException('You must specify an In group/org.'); throw new InvalidArgumentException('You must specify an In group/org.');
} }
$context_actor = Actor::getById($this->int('in')); $context_actor = Actor::getById($this->int('in'));
if (!$context_actor->isGroup()) { if (!$context_actor->isGroup()) {
throw new \InvalidArgumentException('Only group blog posts are supported for now.'); throw new InvalidArgumentException('Only group blog posts are supported for now.');
} }
$in_targets = ["!{$context_actor->getNickname()}" => $context_actor->getId()]; $in_targets = ["!{$context_actor->getNickname()}" => $context_actor->getId()];
$form_params[] = ['in', ChoiceType::class, ['label' => _m('In:'), 'multiple' => false, 'expanded' => false, 'choices' => $in_targets]]; $form_params[] = ['in', ChoiceType::class, ['label' => _m('In:'), 'multiple' => false, 'expanded' => false, 'choices' => $in_targets]];
$visibility_options = [ $visibility_options = [
_m('Public') => VisibilityScope::EVERYWHERE->value, _m('Public') => VisibilityScope::EVERYWHERE->value,
_m('Local') => VisibilityScope::LOCAL->value, _m('Local') => VisibilityScope::LOCAL->value,
_m('Addressee') => VisibilityScope::ADDRESSEE->value, _m('Addressee') => VisibilityScope::ADDRESSEE->value,
]; ];
if (!\is_null($context_actor) && $context_actor->isGroup()) { if (!\is_null($context_actor) && $context_actor->isGroup()) { // @phpstan-ignore-line currently an open bug. See https://web.archive.org/web/20220226131651/https://github.com/phpstan/phpstan/issues/6234
if ($actor->canModerate($context_actor)) { if ($actor->canModerate($context_actor)) {
if ($context_actor->getRoles() & ActorLocalRoles::PRIVATE_GROUP) { if ($context_actor->getRoles() & ActorLocalRoles::PRIVATE_GROUP) {
$visibility_options = array_merge([_m('Group') => VisibilityScope::GROUP->value], $visibility_options); $visibility_options = array_merge([_m('Group') => VisibilityScope::GROUP->value], $visibility_options);

View File

@ -49,7 +49,7 @@ class ActorCircle extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $id; private int $id;
private ?int $tagger = null; // If null, is the special global self-tag circle private ?int $tagger = null;
private string $tag; private string $tag;
private ?string $description = null; private ?string $description = null;
private ?bool $private = false; private ?bool $private = false;
@ -202,7 +202,7 @@ class ActorCircle extends Entity
'description' => 'An actor can have lists of actors, to separate their feed or quickly mention his friend', 'description' => 'An actor can have lists of actors, to separate their feed or quickly mention his friend',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'], // An actor can be tagged by many actors 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'], // An actor can be tagged by many actors
'tagger' => ['type' => 'int', 'default' => null, 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_list_tagger_fkey', 'description' => 'user making the tag, null if self-tag'], 'tagger' => ['type' => 'int', 'default' => null, 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_list_tagger_fkey', 'description' => 'user making the tag, null if self-tag. If null, is the special global self-tag circle'],
'tag' => ['type' => 'varchar', 'length' => 64, 'foreign key' => true, 'target' => 'ActorTag.tag', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'actor tag'], // Join with ActorTag // // so, Doctrine doesn't like that the target is not unique, even though the pair is // Many Actor Circles can reference (and probably will) an Actor Tag 'tag' => ['type' => 'varchar', 'length' => 64, 'foreign key' => true, 'target' => 'ActorTag.tag', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'actor tag'], // Join with ActorTag // // so, Doctrine doesn't like that the target is not unique, even though the pair is // Many Actor Circles can reference (and probably will) an Actor Tag
'description' => ['type' => 'text', 'description' => 'description of the people tag'], 'description' => ['type' => 'text', 'description' => 'description of the people tag'],
'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'], 'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'],

View File

@ -28,7 +28,6 @@ use App\Core\Cache;
use App\Core\Controller; use App\Core\Controller;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Form; use App\Core\Form;
use App\Util\Nickname;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Entity as E; use App\Entity as E;
@ -45,6 +44,7 @@ use App\Util\Exception\NotFoundException;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use App\Util\Form\ActorForms; use App\Util\Form\ActorForms;
use App\Util\Nickname;
use Component\Group\Entity\GroupMember; use Component\Group\Entity\GroupMember;
use Component\Group\Entity\LocalGroup; use Component\Group\Entity\LocalGroup;
use Component\Subscription\Entity\ActorSubscription; use Component\Subscription\Entity\ActorSubscription;
@ -135,7 +135,7 @@ class Group extends Controller
nickname: $data['group_nickname'], nickname: $data['group_nickname'],
check_already_used: true, check_already_used: true,
which: Nickname::CHECK_LOCAL_GROUP, which: Nickname::CHECK_LOCAL_GROUP,
check_is_allowed: true check_is_allowed: true,
); );
$roles = ActorLocalRoles::VISITOR; // Can send direct messages to other actors $roles = ActorLocalRoles::VISITOR; // Can send direct messages to other actors

View File

@ -53,7 +53,7 @@ class LocalGroup extends Entity
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $actor_id; private int $actor_id;
private string $nickname; private string $nickname;
private string $type; private string $type = 'group';
private DateTimeInterface $created; private DateTimeInterface $created;
private DateTimeInterface $modified; private DateTimeInterface $modified;
@ -81,7 +81,7 @@ class LocalGroup extends Entity
public function setType(string $type): self public function setType(string $type): self
{ {
$this->type = $type; $this->type = mb_substr($type, 0, 64);
return $this; return $this;
} }

View File

@ -23,7 +23,6 @@ namespace Component\Notification;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Util\Exception\ServerException;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Modules\Component; use App\Core\Modules\Component;
@ -32,15 +31,14 @@ use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Exception\ServerException;
use Component\FreeNetwork\FreeNetwork; use Component\FreeNetwork\FreeNetwork;
use Component\Notification\Controller\Feed; use Component\Notification\Controller\Feed;
use Exception;
use Throwable;
class Notification extends Component class Notification extends Component
{ {
/**
* @param RouteLoader $m
* @return bool
*/
public function onAddRoute(RouteLoader $m): bool public function onAddRoute(RouteLoader $m): bool
{ {
$m->connect('feed_notifications', '/feed/notifications', [Feed::class, 'notifications']); $m->connect('feed_notifications', '/feed/notifications', [Feed::class, 'notifications']);
@ -48,10 +46,6 @@ class Notification extends Component
} }
/** /**
* @param int $actor_id
* @param LocalUser $user
* @param int $ordering
* @return bool
* @throws ServerException * @throws ServerException
*/ */
public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering): bool public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering): bool
@ -69,11 +63,6 @@ class Notification extends Component
/** /**
* Enqueues a notification for an Actor (such as person or group) which means * Enqueues a notification for an Actor (such as person or group) which means
* it shows up in their home feed and such. * it shows up in their home feed and such.
* @param Actor $sender
* @param Activity $activity
* @param array $ids_already_known
* @param string|null $reason
* @return bool
*/ */
public function onNewNotification(Actor $sender, Activity $activity, array $ids_already_known = [], ?string $reason = null): bool public function onNewNotification(Actor $sender, Activity $activity, array $ids_already_known = [], ?string $reason = null): bool
{ {
@ -87,11 +76,6 @@ class Notification extends Component
/** /**
* Bring given Activity to Targets's attention * Bring given Activity to Targets's attention
* @param Actor $sender
* @param Activity $activity
* @param array $targets
* @param string|null $reason
* @return bool
*/ */
public static function notify(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool public static function notify(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool
{ {
@ -125,11 +109,10 @@ class Notification extends Component
'target_id' => $target->getId(), 'target_id' => $target->getId(),
'reason' => $reason, 'reason' => $reason,
]))); ])));
} catch (\Exception|\Throwable $e) { } catch (Exception|Throwable $e) {
// We do our best not to record duplicated notifications, but it's not insane that can happen // We do our best not to record duplicated notifications, but it's not insane that can happen
Log::error('It was attempted to record an invalid notification!', [$e]); Log::error('It was attempted to record an invalid notification!', [$e]);
} }
} }
FreeNetwork::notify($sender, $activity, $remote_targets, $reason); FreeNetwork::notify($sender, $activity, $remote_targets, $reason);

View File

@ -25,10 +25,10 @@ namespace Component\Search;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use App\Util\Exception\ClientException;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Formatting; use App\Util\Formatting;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;

View File

@ -50,13 +50,24 @@ class NoteTag extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $note_id;
private string $tag; private string $tag;
private string $canonical; private string $canonical;
private int $note_id;
private bool $use_canonical; private bool $use_canonical;
private ?int $language_id = null; private ?int $language_id = null;
private DateTimeInterface $created; private DateTimeInterface $created;
public function setNoteId(int $note_id): self
{
$this->note_id = $note_id;
return $this;
}
public function getNoteId(): int
{
return $this->note_id;
}
public function setTag(string $tag): self public function setTag(string $tag): self
{ {
$this->tag = mb_substr($tag, 0, 64); $this->tag = mb_substr($tag, 0, 64);
@ -79,17 +90,6 @@ class NoteTag extends Entity
return $this->canonical; return $this->canonical;
} }
public function setNoteId(int $note_id): self
{
$this->note_id = $note_id;
return $this;
}
public function getNoteId(): int
{
return $this->note_id;
}
public function setUseCanonical(bool $use_canonical): self public function setUseCanonical(bool $use_canonical): self
{ {
$this->use_canonical = $use_canonical; $this->use_canonical = $use_canonical;

View File

@ -32,15 +32,13 @@ declare(strict_types = 1);
namespace Plugin\ActivityPub\Controller; namespace Plugin\ActivityPub\Controller;
use App\Core\DB\DB;
use App\Entity\Actor;
use Component\Notification\Entity\Notification;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use Exception; use Component\Notification\Entity\Notification;
use Plugin\ActivityPub\Util\OrderedCollectionController; use Plugin\ActivityPub\Util\OrderedCollectionController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -58,7 +56,7 @@ class Outbox extends OrderedCollectionController
public function viewOutboxByActorId(Request $request, int $gsactor_id): array public function viewOutboxByActorId(Request $request, int $gsactor_id): array
{ {
$actor = Actor::getById($gsactor_id); $actor = Actor::getById($gsactor_id);
if (is_null($actor)) { if (\is_null($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} elseif (!$actor->getIsLocal()) { } elseif (!$actor->getIsLocal()) {
throw new ClientException(_m('We have no authority over a remote actor\'s outbox.'), 400); throw new ClientException(_m('We have no authority over a remote actor\'s outbox.'), 400);

View File

@ -48,15 +48,15 @@ class ActivityAnnounce extends Activity
// The only core Announce we recognise is for (transitive) activities coming from Group actors // The only core Announce we recognise is for (transitive) activities coming from Group actors
if ($actor->isGroup()) { if ($actor->isGroup()) {
if ($type_object instanceof AbstractObject) { if ($type_object instanceof AbstractObject) {
$actual_to = array_flip(is_string($type_object->get('to')) ? [$type_object->get('to')] : $type_object->get('to')); $actual_to = array_flip(\is_string($type_object->get('to')) ? [$type_object->get('to')] : $type_object->get('to'));
$actual_cc = array_flip(is_string($type_object->get('cc')) ? [$type_object->get('cc')] : $type_object->get('cc')); $actual_cc = array_flip(\is_string($type_object->get('cc')) ? [$type_object->get('cc')] : $type_object->get('cc'));
$actual_cc[$type_activity->get('actor')] = true; // Add group to targets $actual_cc[$type_activity->get('actor')] = true; // Add group to targets
foreach (is_string($type_activity->get('to')) ? [$type_activity->get('to')] : $type_activity->get('to') as $to) { foreach (\is_string($type_activity->get('to')) ? [$type_activity->get('to')] : $type_activity->get('to') as $to) {
if ($to !== 'https://www.w3.org/ns/activitystreams#Public') { if ($to !== 'https://www.w3.org/ns/activitystreams#Public') {
$actual_to[$to] = true; $actual_to[$to] = true;
} }
} }
foreach (is_string($type_activity->get('cc')) ? [$type_activity->get('cc')] : $type_activity->get('cc') as $cc) { foreach (\is_string($type_activity->get('cc')) ? [$type_activity->get('cc')] : $type_activity->get('cc') as $cc) {
if ($cc !== 'https://www.w3.org/ns/activitystreams#Public') { if ($cc !== 'https://www.w3.org/ns/activitystreams#Public') {
$actual_cc[$cc] = true; $actual_cc[$cc] = true;
} }

View File

@ -26,10 +26,10 @@ namespace Plugin\Favourite\Controller;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use App\Entity\Actor;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\Actor;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use App\Util\Exception\InvalidFormException; use App\Util\Exception\InvalidFormException;
@ -137,7 +137,6 @@ class Favourite extends FeedController
if (!\is_null($activity = \Plugin\Favourite\Favourite::unfavourNote(note_id: $id, actor_id: $actor_id))) { if (!\is_null($activity = \Plugin\Favourite\Favourite::unfavourNote(note_id: $id, actor_id: $actor_id))) {
DB::flush(); DB::flush();
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, [], _m('{nickname} unfavoured note {note_id}.', ['{nickname}' => $actor->getNickname(), '{note_id}' => $activity->getObjectId()])]); Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, [], _m('{nickname} unfavoured note {note_id}.', ['{nickname}' => $actor->getNickname(), '{note_id}' => $activity->getObjectId()])]);
} else { } else {
throw new ClientException(_m('Note already unfavoured!')); throw new ClientException(_m('Note already unfavoured!'));
} }

View File

@ -48,20 +48,15 @@ class AccessToken extends Token implements AccessTokenEntityInterface
private bool $revoked; private bool $revoked;
private DateTimeInterface $created; private DateTimeInterface $created;
public function getId(): string
{
return $this->id;
}
public function setId(string $id): self public function setId(string $id): self
{ {
$this->id = mb_substr($id, 0, 64); $this->id = mb_substr($id, 0, 64);
return $this; return $this;
} }
public function getExpiry(): DateTimeInterface public function getId(): string
{ {
return $this->expiry; return $this->id;
} }
public function setExpiry(DateTimeInterface $expiry): self public function setExpiry(DateTimeInterface $expiry): self
@ -70,9 +65,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface
return $this; return $this;
} }
public function getUserId(): ?int public function getExpiry(): DateTimeInterface
{ {
return $this->user_id; return $this->expiry;
} }
public function setUserId(?int $user_id): self public function setUserId(?int $user_id): self
@ -81,9 +76,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface
return $this; return $this;
} }
public function getClientId(): string public function getUserId(): ?int
{ {
return $this->client_id; return $this->user_id;
} }
public function setClientId(string $client_id): self public function setClientId(string $client_id): self
@ -92,9 +87,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface
return $this; return $this;
} }
public function getTokenScopes(): string public function getClientId(): string
{ {
return $this->token_scopes; return $this->client_id;
} }
public function setTokenScopes(string $token_scopes): self public function setTokenScopes(string $token_scopes): self
@ -103,9 +98,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface
return $this; return $this;
} }
public function getRevoked(): bool public function getTokenScopes(): string
{ {
return $this->revoked; return $this->token_scopes;
} }
public function setRevoked(bool $revoked): self public function setRevoked(bool $revoked): self
@ -114,9 +109,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface
return $this; return $this;
} }
public function getCreated(): DateTimeInterface public function getRevoked(): bool
{ {
return $this->created; return $this->revoked;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(DateTimeInterface $created): self
@ -125,6 +120,11 @@ class AccessToken extends Token implements AccessTokenEntityInterface
return $this; return $this;
} }
public function getCreated(): DateTimeInterface
{
return $this->created;
}
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} Autocode

View File

@ -48,20 +48,15 @@ class AuthCode extends Token implements AuthCodeEntityInterface
private bool $revoked; private bool $revoked;
private DateTimeInterface $created; private DateTimeInterface $created;
public function getId(): string
{
return $this->id;
}
public function setId(string $id): self public function setId(string $id): self
{ {
$this->id = mb_substr($id, 0, 64); $this->id = mb_substr($id, 0, 64);
return $this; return $this;
} }
public function getExpiry(): DateTimeInterface public function getId(): string
{ {
return $this->expiry; return $this->id;
} }
public function setExpiry(DateTimeInterface $expiry): self public function setExpiry(DateTimeInterface $expiry): self
@ -70,9 +65,9 @@ class AuthCode extends Token implements AuthCodeEntityInterface
return $this; return $this;
} }
public function getUserId(): ?int public function getExpiry(): DateTimeInterface
{ {
return $this->user_id; return $this->expiry;
} }
public function setUserId(?int $user_id): self public function setUserId(?int $user_id): self
@ -81,9 +76,20 @@ class AuthCode extends Token implements AuthCodeEntityInterface
return $this; return $this;
} }
public function getTokenScopes(): string public function getUserId(): ?int
{ {
return $this->token_scopes; return $this->user_id;
}
public function setClientId(string $client_id): self
{
$this->client_id = mb_substr($client_id, 0, 64);
return $this;
}
public function getClientId(): string
{
return $this->client_id;
} }
public function setTokenScopes(string $token_scopes): self public function setTokenScopes(string $token_scopes): self
@ -92,9 +98,9 @@ class AuthCode extends Token implements AuthCodeEntityInterface
return $this; return $this;
} }
public function getRevoked(): bool public function getTokenScopes(): string
{ {
return $this->revoked; return $this->token_scopes;
} }
public function setRevoked(bool $revoked): self public function setRevoked(bool $revoked): self
@ -103,9 +109,9 @@ class AuthCode extends Token implements AuthCodeEntityInterface
return $this; return $this;
} }
public function getCreated(): DateTimeInterface public function getRevoked(): bool
{ {
return $this->created; return $this->revoked;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(DateTimeInterface $created): self
@ -114,20 +120,14 @@ class AuthCode extends Token implements AuthCodeEntityInterface
return $this; return $this;
} }
public function getCreated(): DateTimeInterface
{
return $this->created;
}
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} Autocode
public function getClientId(): string
{
return $this->client_id;
}
public function setClientId(string $client_id): self
{
$this->client_id = mb_substr($client_id, 0, 64);
return $this;
}
public function getRedirectUri(): ?string public function getRedirectUri(): ?string
{ {
/** @var Client $client */ /** @var Client $client */

View File

@ -52,20 +52,15 @@ class Client extends Entity implements ClientEntityInterface
private DateTimeInterface $created; private DateTimeInterface $created;
private DateTimeInterface $modified; private DateTimeInterface $modified;
public function getId(): string
{
return $this->id;
}
public function setId(string $id): self public function setId(string $id): self
{ {
$this->id = mb_substr($id, 0, 64); $this->id = mb_substr($id, 0, 64);
return $this; return $this;
} }
public function getSecret(): string public function getId(): string
{ {
return $this->secret; return $this->id;
} }
public function setSecret(string $secret): self public function setSecret(string $secret): self
@ -74,9 +69,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getActive(): bool public function getSecret(): string
{ {
return $this->active; return $this->secret;
} }
public function setActive(bool $active): self public function setActive(bool $active): self
@ -85,9 +80,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getPlainPcke(): bool public function getActive(): bool
{ {
return $this->plain_pcke; return $this->active;
} }
public function setPlainPcke(bool $plain_pcke): self public function setPlainPcke(bool $plain_pcke): self
@ -96,9 +91,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getIsConfidential(): bool public function getPlainPcke(): bool
{ {
return $this->is_confidential; return $this->plain_pcke;
} }
public function setIsConfidential(bool $is_confidential): self public function setIsConfidential(bool $is_confidential): self
@ -107,9 +102,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getRedirectUris(): string public function getIsConfidential(): bool
{ {
return $this->redirect_uris; return $this->is_confidential;
} }
public function setRedirectUris(string $redirect_uris): self public function setRedirectUris(string $redirect_uris): self
@ -118,9 +113,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getGrants(): string public function getRedirectUris(): string
{ {
return $this->grants; return $this->redirect_uris;
} }
public function setGrants(string $grants): self public function setGrants(string $grants): self
@ -129,9 +124,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getScopes(): string public function getGrants(): string
{ {
return $this->scopes; return $this->grants;
} }
public function setScopes(string $scopes): self public function setScopes(string $scopes): self
@ -140,6 +135,11 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getScopes(): string
{
return $this->scopes;
}
public function setClientName(string $client_name): self public function setClientName(string $client_name): self
{ {
$this->client_name = mb_substr($client_name, 0, 191); $this->client_name = mb_substr($client_name, 0, 191);
@ -151,20 +151,15 @@ class Client extends Entity implements ClientEntityInterface
return $this->client_name; return $this->client_name;
} }
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(?string $website): self public function setWebsite(?string $website): self
{ {
$this->website = $website; $this->website = $website;
return $this; return $this;
} }
public function getCreated(): DateTimeInterface public function getWebsite(): ?string
{ {
return $this->created; return $this->website;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(DateTimeInterface $created): self
@ -173,9 +168,9 @@ class Client extends Entity implements ClientEntityInterface
return $this; return $this;
} }
public function getModified(): DateTimeInterface public function getCreated(): DateTimeInterface
{ {
return $this->modified; return $this->created;
} }
public function setModified(DateTimeInterface $modified): self public function setModified(DateTimeInterface $modified): self
@ -183,6 +178,12 @@ class Client extends Entity implements ClientEntityInterface
$this->modified = $modified; $this->modified = $modified;
return $this; return $this;
} }
public function getModified(): DateTimeInterface
{
return $this->modified;
}
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} Autocode

View File

@ -48,20 +48,15 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface
private bool $revoked; private bool $revoked;
private DateTimeInterface $created; private DateTimeInterface $created;
public function getId(): string
{
return $this->id;
}
public function setId(string $id): self public function setId(string $id): self
{ {
$this->id = mb_substr($id, 0, 64); $this->id = mb_substr($id, 0, 64);
return $this; return $this;
} }
public function getExpiry(): DateTimeInterface public function getId(): string
{ {
return $this->expiry; return $this->id;
} }
public function setExpiry(DateTimeInterface $expiry): self public function setExpiry(DateTimeInterface $expiry): self
@ -70,9 +65,9 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface
return $this; return $this;
} }
public function getAccessTokenId(): ?string public function getExpiry(): DateTimeInterface
{ {
return $this->access_token_id; return $this->expiry;
} }
public function setAccessTokenId(?string $access_token_id): self public function setAccessTokenId(?string $access_token_id): self
@ -81,9 +76,9 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface
return $this; return $this;
} }
public function getRevoked(): bool public function getAccessTokenId(): ?string
{ {
return $this->revoked; return $this->access_token_id;
} }
public function setRevoked(bool $revoked): self public function setRevoked(bool $revoked): self
@ -92,9 +87,9 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface
return $this; return $this;
} }
public function getCreated(): DateTimeInterface public function getRevoked(): bool
{ {
return $this->created; return $this->revoked;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(DateTimeInterface $created): self
@ -103,6 +98,11 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface
return $this; return $this;
} }
public function getCreated(): DateTimeInterface
{
return $this->created;
}
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} Autocode

View File

@ -27,10 +27,10 @@ use App\Core\Controller;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use App\Entity\Actor;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
@ -77,7 +77,6 @@ class Repeat extends Controller
DB::flush(); DB::flush();
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $repeat_activity, [], _m('{nickname} repeated note {note_id}.', ['{nickname}' => $actor->getNickname(), '{note_id}' => $repeat_activity->getObjectId()])]); Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $repeat_activity, [], _m('{nickname} repeated note {note_id}.', ['{nickname}' => $actor->getNickname(), '{note_id}' => $repeat_activity->getObjectId()])]);
// Redirect user to where they came from // Redirect user to where they came from
// Prevent open redirect // Prevent open redirect
if (!\is_null($from = $this->string('from'))) { if (!\is_null($from = $this->string('from'))) {

View File

@ -65,7 +65,7 @@ class NoteRepeat extends Entity
return $this; return $this;
} }
public function getActorId(): ?int public function getActorId(): int
{ {
return $this->actor_id; return $this->actor_id;
} }
@ -80,6 +80,7 @@ class NoteRepeat extends Entity
{ {
return $this->repeat_of; return $this->repeat_of;
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} Autocode

View File

@ -137,18 +137,14 @@ abstract class Form
/** /**
* Handle the full life cycle of a form. Creates it with @param array $form_definition * Handle the full life cycle of a form. Creates it with @param array $form_definition
* @param Request $request *
* @param object|null $target
* @param array $extra_args If specified, is used as $target->set($data[$key], $extra_args[$key]) * @param array $extra_args If specified, is used as $target->set($data[$key], $extra_args[$key])
* @param callable|null $after_step *
* @param array $create_args
* @param SymfForm|null $testing_only_form
* @return mixed
* @throws RedirectException * @throws RedirectException
* @throws ServerException * @throws ServerException
*
* @see * @see
* self::create and inserts the submitted values into the database * self::create and inserts the submitted values into the database
*
*/ */
public static function handle(array $form_definition, Request $request, ?object $target, array $extra_args = [], ?callable $before_step = null, ?callable $after_step = null, array $create_args = [], ?SymfForm $testing_only_form = null): mixed public static function handle(array $form_definition, Request $request, ?object $target, array $extra_args = [], ?callable $before_step = null, ?callable $after_step = null, array $create_args = [], ?SymfForm $testing_only_form = null): mixed
{ {

View File

@ -114,7 +114,7 @@ class Note extends Entity
public function setContentType(string $content_type): self public function setContentType(string $content_type): self
{ {
$this->content_type = mb_substr($content_type, 0, 129); $this->content_type = \mb_substr($content_type, 0, 129);
return $this; return $this;
} }
@ -169,7 +169,7 @@ class Note extends Entity
public function setSource(?string $source): self public function setSource(?string $source): self
{ {
$this->source = \is_null($source) ? null : mb_substr($source, 0, 32); $this->source = \is_null($source) ? null : \mb_substr($source, 0, 32);
return $this; return $this;
} }
@ -224,7 +224,7 @@ class Note extends Entity
public function setTitle(?string $title): self public function setTitle(?string $title): self
{ {
$this->title = \is_null($title) ? null : mb_substr($title, 0, 129); $this->title = \is_null($title) ? null : \mb_substr($title, 0, 129);
return $this; return $this;
} }
@ -233,24 +233,24 @@ class Note extends Entity
return $this->title; return $this->title;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(\DateTimeInterface $created): self
{ {
$this->created = $created; $this->created = $created;
return $this; return $this;
} }
public function getCreated(): DateTimeInterface public function getCreated(): \DateTimeInterface
{ {
return $this->created; return $this->created;
} }
public function setModified(DateTimeInterface $modified): self public function setModified(\DateTimeInterface $modified): self
{ {
$this->modified = $modified; $this->modified = $modified;
return $this; return $this;
} }
public function getModified(): DateTimeInterface public function getModified(): \DateTimeInterface
{ {
return $this->modified; return $this->modified;
} }

View File

@ -108,7 +108,7 @@ class ActorForms
// Validate full name // Validate full name
if ($target->getFullname() !== $data['full_name']) { if ($target->getFullname() !== $data['full_name']) {
if (!is_null($data['full_name'])) { if (!\is_null($data['full_name'])) {
if (mb_strlen($data['full_name']) > 64) { if (mb_strlen($data['full_name']) > 64) {
throw new ClientException(_m('Full name cannot be more than 64 character long.')); throw new ClientException(_m('Full name cannot be more than 64 character long.'));
} }