From 45c7888676a21a6ba19509520296dd1579cc0244 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 26 Feb 2022 14:45:38 +0000 Subject: [PATCH] [TOOLS] Run CS-Fixer on whole project --- components/Blog/Controller/Post.php | 20 +++---- components/Circle/Entity/ActorCircle.php | 4 +- components/Group/Controller/Group.php | 6 +- components/Group/Entity/GroupMember.php | 2 +- components/Group/Entity/LocalGroup.php | 4 +- components/Notification/Notification.php | 25 ++------ components/Search/Search.php | 2 +- components/Tag/Entity/NoteTag.php | 24 ++++---- plugins/ActivityPub/Controller/Inbox.php | 2 +- plugins/ActivityPub/Controller/Outbox.php | 8 +-- plugins/ActivityPub/Util/Explorer.php | 2 +- plugins/ActivityPub/Util/HTTPSignature.php | 2 +- .../Util/Model/ActivityAnnounce.php | 10 ++-- plugins/Favourite/Controller/Favourite.php | 3 +- plugins/OAuth2/Entity/AccessToken.php | 34 +++++------ plugins/OAuth2/Entity/AuthCode.php | 52 ++++++++--------- plugins/OAuth2/Entity/Client.php | 57 ++++++++++--------- plugins/OAuth2/Entity/RefreshToken.php | 26 ++++----- plugins/RepeatNote/Controller/Repeat.php | 3 +- plugins/RepeatNote/Entity/NoteRepeat.php | 3 +- src/Controller/ActorProfile.php | 2 +- src/Core/Form.php | 10 +--- src/Entity/Note.php | 14 ++--- src/Util/Form/ActorForms.php | 2 +- 24 files changed, 146 insertions(+), 171 deletions(-) diff --git a/components/Blog/Controller/Post.php b/components/Blog/Controller/Post.php index 6a27fcd326..067b9baeb9 100644 --- a/components/Blog/Controller/Post.php +++ b/components/Blog/Controller/Post.php @@ -27,10 +27,7 @@ use App\Core\ActorLocalRoles; use App\Core\Controller; use App\Core\Event; use App\Core\Form; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\HttpFoundation\RedirectResponse; use function App\Core\I18n\_m; -use App\Core\Router\Router; use App\Core\VisibilityScope; use App\Entity\Actor; use App\Util\Common; @@ -38,13 +35,15 @@ use App\Util\Exception\ClientException; use App\Util\Exception\RedirectException; use App\Util\Form\FormFields; use Component\Posting\Posting; +use InvalidArgumentException; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; 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\RedirectResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Validator\Constraints\Length; class Post extends Controller @@ -74,23 +73,22 @@ class Post extends Controller ]; Event::handle('PostingAvailableContentTypes', [&$available_content_types]); - if (!is_int($this->int('in'))) { - throw new \InvalidArgumentException('You must specify an In group/org.'); + if (!\is_int($this->int('in'))) { + throw new InvalidArgumentException('You must specify an In group/org.'); } $context_actor = Actor::getById($this->int('in')); 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]]; - $visibility_options = [ _m('Public') => VisibilityScope::EVERYWHERE->value, _m('Local') => VisibilityScope::LOCAL->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 ($context_actor->getRoles() & ActorLocalRoles::PRIVATE_GROUP) { $visibility_options = array_merge([_m('Group') => VisibilityScope::GROUP->value], $visibility_options); @@ -147,7 +145,7 @@ class Post extends Controller content_type: $content_type, locale: $data['language'], scope: VisibilityScope::from($data['visibility']), - targets: [(int)$data['in']], + targets: [(int) $data['in']], reply_to: $data['reply_to_id'], attachments: $data['attachments'], process_note_content_extra_args: $extra_args, diff --git a/components/Circle/Entity/ActorCircle.php b/components/Circle/Entity/ActorCircle.php index 30fd5a1b29..29a807141a 100644 --- a/components/Circle/Entity/ActorCircle.php +++ b/components/Circle/Entity/ActorCircle.php @@ -49,7 +49,7 @@ class ActorCircle extends Entity // {{{ Autocode // @codeCoverageIgnoreStart 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 $description = null; 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', 'fields' => [ '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 'description' => ['type' => 'text', 'description' => 'description of the people tag'], 'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'], diff --git a/components/Group/Controller/Group.php b/components/Group/Controller/Group.php index 6cd0999d57..1929b5313e 100644 --- a/components/Group/Controller/Group.php +++ b/components/Group/Controller/Group.php @@ -28,7 +28,6 @@ use App\Core\Cache; use App\Core\Controller; use App\Core\DB\DB; use App\Core\Form; -use App\Util\Nickname; use function App\Core\I18n\_m; use App\Core\Log; use App\Entity as E; @@ -45,6 +44,7 @@ use App\Util\Exception\NotFoundException; use App\Util\Exception\RedirectException; use App\Util\Exception\ServerException; use App\Util\Form\ActorForms; +use App\Util\Nickname; use Component\Group\Entity\GroupMember; use Component\Group\Entity\LocalGroup; use Component\Subscription\Entity\ActorSubscription; @@ -135,7 +135,7 @@ class Group extends Controller nickname: $data['group_nickname'], check_already_used: true, which: Nickname::CHECK_LOCAL_GROUP, - check_is_allowed: true + check_is_allowed: true, ); $roles = ActorLocalRoles::VISITOR; // Can send direct messages to other actors @@ -146,7 +146,7 @@ class Group extends Controller Log::info( _m( - 'Actor id:{actor_id} nick:{actor_nick} created the '.($roles & ActorLocalRoles::PRIVATE_GROUP ? 'private' : 'public').' group {nickname}', + 'Actor id:{actor_id} nick:{actor_nick} created the ' . ($roles & ActorLocalRoles::PRIVATE_GROUP ? 'private' : 'public') . ' group {nickname}', ['{actor_id}' => $actor->getId(), 'actor_nick' => $actor->getNickname(), 'nickname' => $nickname], ), ); diff --git a/components/Group/Entity/GroupMember.php b/components/Group/Entity/GroupMember.php index ae02bf76d7..d2512a2a39 100644 --- a/components/Group/Entity/GroupMember.php +++ b/components/Group/Entity/GroupMember.php @@ -45,7 +45,7 @@ class GroupMember extends Entity private int $group_id; private int $actor_id; private int $roles; - private ?string $uri = null; + private ?string $uri = null; private DateTimeInterface $created; private DateTimeInterface $modified; diff --git a/components/Group/Entity/LocalGroup.php b/components/Group/Entity/LocalGroup.php index 0620c453bd..710b4f7d7a 100644 --- a/components/Group/Entity/LocalGroup.php +++ b/components/Group/Entity/LocalGroup.php @@ -53,7 +53,7 @@ class LocalGroup extends Entity // @codeCoverageIgnoreStart private int $actor_id; private string $nickname; - private string $type; + private string $type = 'group'; private DateTimeInterface $created; private DateTimeInterface $modified; @@ -81,7 +81,7 @@ class LocalGroup extends Entity public function setType(string $type): self { - $this->type = $type; + $this->type = mb_substr($type, 0, 64); return $this; } diff --git a/components/Notification/Notification.php b/components/Notification/Notification.php index 94b40902b6..533d087945 100644 --- a/components/Notification/Notification.php +++ b/components/Notification/Notification.php @@ -23,7 +23,6 @@ namespace Component\Notification; use App\Core\DB\DB; use App\Core\Event; -use App\Util\Exception\ServerException; use function App\Core\I18n\_m; use App\Core\Log; use App\Core\Modules\Component; @@ -32,15 +31,14 @@ use App\Core\Router\Router; use App\Entity\Activity; use App\Entity\Actor; use App\Entity\LocalUser; +use App\Util\Exception\ServerException; use Component\FreeNetwork\FreeNetwork; use Component\Notification\Controller\Feed; +use Exception; +use Throwable; class Notification extends Component { - /** - * @param RouteLoader $m - * @return bool - */ public function onAddRoute(RouteLoader $m): bool { $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 */ 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 * 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 { @@ -87,11 +76,6 @@ class Notification extends Component /** * 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 { @@ -125,11 +109,10 @@ class Notification extends Component 'target_id' => $target->getId(), '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 Log::error('It was attempted to record an invalid notification!', [$e]); } - } FreeNetwork::notify($sender, $activity, $remote_targets, $reason); diff --git a/components/Search/Search.php b/components/Search/Search.php index fe14441fd1..bc8e38f9e6 100644 --- a/components/Search/Search.php +++ b/components/Search/Search.php @@ -25,10 +25,10 @@ namespace Component\Search; use App\Core\Event; use App\Core\Form; -use App\Util\Exception\ClientException; use function App\Core\I18n\_m; use App\Core\Modules\Component; use App\Util\Common; +use App\Util\Exception\ClientException; use App\Util\Exception\RedirectException; use App\Util\Formatting; use Symfony\Component\Form\Extension\Core\Type\SubmitType; diff --git a/components/Tag/Entity/NoteTag.php b/components/Tag/Entity/NoteTag.php index 01f4eb6ef9..20972c0a2d 100644 --- a/components/Tag/Entity/NoteTag.php +++ b/components/Tag/Entity/NoteTag.php @@ -50,13 +50,24 @@ class NoteTag extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart + private int $note_id; private string $tag; private string $canonical; - private int $note_id; private bool $use_canonical; private ?int $language_id = null; 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 { $this->tag = mb_substr($tag, 0, 64); @@ -79,17 +90,6 @@ class NoteTag extends Entity 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 { $this->use_canonical = $use_canonical; diff --git a/plugins/ActivityPub/Controller/Inbox.php b/plugins/ActivityPub/Controller/Inbox.php index 21f977d4b0..79b6a1846c 100644 --- a/plugins/ActivityPub/Controller/Inbox.php +++ b/plugins/ActivityPub/Controller/Inbox.php @@ -102,7 +102,7 @@ class Inbox extends Controller try { $resource_parts = parse_url($type->get('actor')); if ($resource_parts['host'] !== Common::config('site', 'server')) { - $actor = DB::wrapInTransaction(fn () => Explorer::getOneFromUri($type->get('actor'))); + $actor = DB::wrapInTransaction(fn () => Explorer::getOneFromUri($type->get('actor'))); $ap_actor = DB::findOneBy(ActivitypubActor::class, ['actor_id' => $actor->getId()]); } else { throw new Exception('Only remote actors can use this endpoint.'); diff --git a/plugins/ActivityPub/Controller/Outbox.php b/plugins/ActivityPub/Controller/Outbox.php index d70eee7ac1..618e1a4021 100644 --- a/plugins/ActivityPub/Controller/Outbox.php +++ b/plugins/ActivityPub/Controller/Outbox.php @@ -32,15 +32,13 @@ declare(strict_types = 1); 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 App\Core\Log; use App\Core\Router\Router; use App\Entity\Activity; +use App\Entity\Actor; use App\Util\Exception\ClientException; -use Exception; +use Component\Notification\Entity\Notification; use Plugin\ActivityPub\Util\OrderedCollectionController; use Symfony\Component\HttpFoundation\Request; @@ -58,7 +56,7 @@ class Outbox extends OrderedCollectionController public function viewOutboxByActorId(Request $request, int $gsactor_id): array { $actor = Actor::getById($gsactor_id); - if (is_null($actor)) { + if (\is_null($actor)) { throw new ClientException(_m('No such actor.'), 404); } elseif (!$actor->getIsLocal()) { throw new ClientException(_m('We have no authority over a remote actor\'s outbox.'), 400); diff --git a/plugins/ActivityPub/Util/Explorer.php b/plugins/ActivityPub/Util/Explorer.php index 6f26820e5a..410e43e8c8 100644 --- a/plugins/ActivityPub/Util/Explorer.php +++ b/plugins/ActivityPub/Util/Explorer.php @@ -231,7 +231,7 @@ class Explorer return true; } else { try { - $this->discovered_actors[] = DB::wrapInTransaction(fn() => Model\Actor::fromJson(json_encode($res)))->getActor(); + $this->discovered_actors[] = DB::wrapInTransaction(fn () => Model\Actor::fromJson(json_encode($res)))->getActor(); return true; } catch (Exception $e) { Log::debug( diff --git a/plugins/ActivityPub/Util/HTTPSignature.php b/plugins/ActivityPub/Util/HTTPSignature.php index 82caaad1cf..271c548458 100644 --- a/plugins/ActivityPub/Util/HTTPSignature.php +++ b/plugins/ActivityPub/Util/HTTPSignature.php @@ -143,7 +143,7 @@ class HTTPSignature { // We need this because the used Request headers fields specified by Signature are in lower case. $headersContent = array_change_key_case($inputHeaders, \CASE_LOWER); - $digest = 'SHA-256=' . base64_encode(hash('sha256', $body, true)); + $digest = 'SHA-256=' . base64_encode(hash('sha256', $body, true)); $headersToSign = []; foreach (explode(' ', $signatureData['headers']) as $h) { if ($h == '(request-target)') { diff --git a/plugins/ActivityPub/Util/Model/ActivityAnnounce.php b/plugins/ActivityPub/Util/Model/ActivityAnnounce.php index a3cfc87a6a..e634069f86 100644 --- a/plugins/ActivityPub/Util/Model/ActivityAnnounce.php +++ b/plugins/ActivityPub/Util/Model/ActivityAnnounce.php @@ -1,6 +1,6 @@ isGroup()) { if ($type_object instanceof AbstractObject) { - $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_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[$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') { $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') { $actual_cc[$cc] = true; } diff --git a/plugins/Favourite/Controller/Favourite.php b/plugins/Favourite/Controller/Favourite.php index 39d4305ff2..ed4f156cac 100644 --- a/plugins/Favourite/Controller/Favourite.php +++ b/plugins/Favourite/Controller/Favourite.php @@ -26,10 +26,10 @@ namespace Plugin\Favourite\Controller; use App\Core\DB\DB; use App\Core\Event; use App\Core\Form; -use App\Entity\Actor; use function App\Core\I18n\_m; use App\Core\Log; use App\Core\Router\Router; +use App\Entity\Actor; use App\Util\Common; use App\Util\Exception\ClientException; 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))) { DB::flush(); Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $activity, [], _m('{nickname} unfavoured note {note_id}.', ['{nickname}' => $actor->getNickname(), '{note_id}' => $activity->getObjectId()])]); - } else { throw new ClientException(_m('Note already unfavoured!')); } diff --git a/plugins/OAuth2/Entity/AccessToken.php b/plugins/OAuth2/Entity/AccessToken.php index fa34ab42d1..bb68c2eff5 100644 --- a/plugins/OAuth2/Entity/AccessToken.php +++ b/plugins/OAuth2/Entity/AccessToken.php @@ -48,20 +48,15 @@ class AccessToken extends Token implements AccessTokenEntityInterface private bool $revoked; private DateTimeInterface $created; - public function getId(): string - { - return $this->id; - } - public function setId(string $id): self { $this->id = mb_substr($id, 0, 64); return $this; } - public function getExpiry(): DateTimeInterface + public function getId(): string { - return $this->expiry; + return $this->id; } public function setExpiry(DateTimeInterface $expiry): self @@ -70,9 +65,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface return $this; } - public function getUserId(): ?int + public function getExpiry(): DateTimeInterface { - return $this->user_id; + return $this->expiry; } public function setUserId(?int $user_id): self @@ -81,9 +76,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface 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 @@ -92,9 +87,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface 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 @@ -103,9 +98,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface return $this; } - public function getRevoked(): bool + public function getTokenScopes(): string { - return $this->revoked; + return $this->token_scopes; } public function setRevoked(bool $revoked): self @@ -114,9 +109,9 @@ class AccessToken extends Token implements AccessTokenEntityInterface return $this; } - public function getCreated(): DateTimeInterface + public function getRevoked(): bool { - return $this->created; + return $this->revoked; } public function setCreated(DateTimeInterface $created): self @@ -125,6 +120,11 @@ class AccessToken extends Token implements AccessTokenEntityInterface return $this; } + public function getCreated(): DateTimeInterface + { + return $this->created; + } + // @codeCoverageIgnoreEnd // }}} Autocode diff --git a/plugins/OAuth2/Entity/AuthCode.php b/plugins/OAuth2/Entity/AuthCode.php index 03d4a400b6..0e9b8415b3 100644 --- a/plugins/OAuth2/Entity/AuthCode.php +++ b/plugins/OAuth2/Entity/AuthCode.php @@ -48,20 +48,15 @@ class AuthCode extends Token implements AuthCodeEntityInterface private bool $revoked; private DateTimeInterface $created; - public function getId(): string - { - return $this->id; - } - public function setId(string $id): self { $this->id = mb_substr($id, 0, 64); return $this; } - public function getExpiry(): DateTimeInterface + public function getId(): string { - return $this->expiry; + return $this->id; } public function setExpiry(DateTimeInterface $expiry): self @@ -70,9 +65,9 @@ class AuthCode extends Token implements AuthCodeEntityInterface return $this; } - public function getUserId(): ?int + public function getExpiry(): DateTimeInterface { - return $this->user_id; + return $this->expiry; } public function setUserId(?int $user_id): self @@ -81,9 +76,20 @@ class AuthCode extends Token implements AuthCodeEntityInterface 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 @@ -92,9 +98,9 @@ class AuthCode extends Token implements AuthCodeEntityInterface return $this; } - public function getRevoked(): bool + public function getTokenScopes(): string { - return $this->revoked; + return $this->token_scopes; } public function setRevoked(bool $revoked): self @@ -103,9 +109,9 @@ class AuthCode extends Token implements AuthCodeEntityInterface return $this; } - public function getCreated(): DateTimeInterface + public function getRevoked(): bool { - return $this->created; + return $this->revoked; } public function setCreated(DateTimeInterface $created): self @@ -114,20 +120,14 @@ class AuthCode extends Token implements AuthCodeEntityInterface return $this; } + public function getCreated(): DateTimeInterface + { + return $this->created; + } + // @codeCoverageIgnoreEnd // }}} 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 { /** @var Client $client */ diff --git a/plugins/OAuth2/Entity/Client.php b/plugins/OAuth2/Entity/Client.php index eee05fcfd5..27ef342a6e 100644 --- a/plugins/OAuth2/Entity/Client.php +++ b/plugins/OAuth2/Entity/Client.php @@ -52,20 +52,15 @@ class Client extends Entity implements ClientEntityInterface private DateTimeInterface $created; private DateTimeInterface $modified; - public function getId(): string - { - return $this->id; - } - public function setId(string $id): self { $this->id = mb_substr($id, 0, 64); return $this; } - public function getSecret(): string + public function getId(): string { - return $this->secret; + return $this->id; } public function setSecret(string $secret): self @@ -74,9 +69,9 @@ class Client extends Entity implements ClientEntityInterface return $this; } - public function getActive(): bool + public function getSecret(): string { - return $this->active; + return $this->secret; } public function setActive(bool $active): self @@ -85,9 +80,9 @@ class Client extends Entity implements ClientEntityInterface return $this; } - public function getPlainPcke(): bool + public function getActive(): bool { - return $this->plain_pcke; + return $this->active; } public function setPlainPcke(bool $plain_pcke): self @@ -96,9 +91,9 @@ class Client extends Entity implements ClientEntityInterface 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 @@ -107,9 +102,9 @@ class Client extends Entity implements ClientEntityInterface 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 @@ -118,9 +113,9 @@ class Client extends Entity implements ClientEntityInterface return $this; } - public function getGrants(): string + public function getRedirectUris(): string { - return $this->grants; + return $this->redirect_uris; } public function setGrants(string $grants): self @@ -129,9 +124,9 @@ class Client extends Entity implements ClientEntityInterface return $this; } - public function getScopes(): string + public function getGrants(): string { - return $this->scopes; + return $this->grants; } public function setScopes(string $scopes): self @@ -140,6 +135,11 @@ class Client extends Entity implements ClientEntityInterface return $this; } + public function getScopes(): string + { + return $this->scopes; + } + public function setClientName(string $client_name): self { $this->client_name = mb_substr($client_name, 0, 191); @@ -151,20 +151,15 @@ class Client extends Entity implements ClientEntityInterface return $this->client_name; } - public function getWebsite(): ?string - { - return $this->website; - } - public function setWebsite(?string $website): self { $this->website = $website; return $this; } - public function getCreated(): DateTimeInterface + public function getWebsite(): ?string { - return $this->created; + return $this->website; } public function setCreated(DateTimeInterface $created): self @@ -173,9 +168,9 @@ class Client extends Entity implements ClientEntityInterface return $this; } - public function getModified(): DateTimeInterface + public function getCreated(): DateTimeInterface { - return $this->modified; + return $this->created; } public function setModified(DateTimeInterface $modified): self @@ -183,6 +178,12 @@ class Client extends Entity implements ClientEntityInterface $this->modified = $modified; return $this; } + + public function getModified(): DateTimeInterface + { + return $this->modified; + } + // @codeCoverageIgnoreEnd // }}} Autocode diff --git a/plugins/OAuth2/Entity/RefreshToken.php b/plugins/OAuth2/Entity/RefreshToken.php index 1cefbca0b8..4f2dc7f3c8 100644 --- a/plugins/OAuth2/Entity/RefreshToken.php +++ b/plugins/OAuth2/Entity/RefreshToken.php @@ -48,20 +48,15 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface private bool $revoked; private DateTimeInterface $created; - public function getId(): string - { - return $this->id; - } - public function setId(string $id): self { $this->id = mb_substr($id, 0, 64); return $this; } - public function getExpiry(): DateTimeInterface + public function getId(): string { - return $this->expiry; + return $this->id; } public function setExpiry(DateTimeInterface $expiry): self @@ -70,9 +65,9 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface 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 @@ -81,9 +76,9 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface return $this; } - public function getRevoked(): bool + public function getAccessTokenId(): ?string { - return $this->revoked; + return $this->access_token_id; } public function setRevoked(bool $revoked): self @@ -92,9 +87,9 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface return $this; } - public function getCreated(): DateTimeInterface + public function getRevoked(): bool { - return $this->created; + return $this->revoked; } public function setCreated(DateTimeInterface $created): self @@ -103,6 +98,11 @@ class RefreshToken extends Entity implements RefreshTokenEntityInterface return $this; } + public function getCreated(): DateTimeInterface + { + return $this->created; + } + // @codeCoverageIgnoreEnd // }}} Autocode diff --git a/plugins/RepeatNote/Controller/Repeat.php b/plugins/RepeatNote/Controller/Repeat.php index c21d103b86..b447fb02aa 100644 --- a/plugins/RepeatNote/Controller/Repeat.php +++ b/plugins/RepeatNote/Controller/Repeat.php @@ -27,10 +27,10 @@ use App\Core\Controller; use App\Core\DB\DB; use App\Core\Event; use App\Core\Form; -use App\Entity\Actor; use function App\Core\I18n\_m; use App\Core\Log; use App\Core\Router\Router; +use App\Entity\Actor; use App\Entity\Note; use App\Util\Common; use App\Util\Exception\ClientException; @@ -77,7 +77,6 @@ class Repeat extends Controller 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()])]); - // Redirect user to where they came from // Prevent open redirect if (!\is_null($from = $this->string('from'))) { diff --git a/plugins/RepeatNote/Entity/NoteRepeat.php b/plugins/RepeatNote/Entity/NoteRepeat.php index 8e3b5fff56..c0f92d2bcf 100644 --- a/plugins/RepeatNote/Entity/NoteRepeat.php +++ b/plugins/RepeatNote/Entity/NoteRepeat.php @@ -65,7 +65,7 @@ class NoteRepeat extends Entity return $this; } - public function getActorId(): ?int + public function getActorId(): int { return $this->actor_id; } @@ -80,6 +80,7 @@ class NoteRepeat extends Entity { return $this->repeat_of; } + // @codeCoverageIgnoreEnd // }}} Autocode diff --git a/src/Controller/ActorProfile.php b/src/Controller/ActorProfile.php index 643f4f15ec..fc70ce13e8 100644 --- a/src/Controller/ActorProfile.php +++ b/src/Controller/ActorProfile.php @@ -33,7 +33,7 @@ class ActorProfile extends Controller { public function actorViewId(Request $request, int $id): array { - $actor = Actor::getById($id); + $actor = Actor::getById($id); $route_id = match ($actor->getType()) { Actor::PERSON => 'person_actor_view_id', Actor::GROUP => 'group_actor_view_id', diff --git a/src/Core/Form.php b/src/Core/Form.php index 1c9b835c5e..239d6e0159 100644 --- a/src/Core/Form.php +++ b/src/Core/Form.php @@ -137,18 +137,14 @@ abstract class Form /** * 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 callable|null $after_step - * @param array $create_args - * @param SymfForm|null $testing_only_form - * @return mixed + * * @throws RedirectException * @throws ServerException + * * @see * 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 { diff --git a/src/Entity/Note.php b/src/Entity/Note.php index bc35fc6278..4aa762146d 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -114,7 +114,7 @@ class Note extends Entity 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; } @@ -169,7 +169,7 @@ class Note extends Entity 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; } @@ -224,7 +224,7 @@ class Note extends Entity 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; } @@ -233,24 +233,24 @@ class Note extends Entity return $this->title; } - public function setCreated(DateTimeInterface $created): self + public function setCreated(\DateTimeInterface $created): self { $this->created = $created; return $this; } - public function getCreated(): DateTimeInterface + public function getCreated(): \DateTimeInterface { return $this->created; } - public function setModified(DateTimeInterface $modified): self + public function setModified(\DateTimeInterface $modified): self { $this->modified = $modified; return $this; } - public function getModified(): DateTimeInterface + public function getModified(): \DateTimeInterface { return $this->modified; } diff --git a/src/Util/Form/ActorForms.php b/src/Util/Form/ActorForms.php index 183bf99e16..3523237d60 100644 --- a/src/Util/Form/ActorForms.php +++ b/src/Util/Form/ActorForms.php @@ -108,7 +108,7 @@ class ActorForms // Validate 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) { throw new ClientException(_m('Full name cannot be more than 64 character long.')); }