Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jan 9, 2024
1 parent ed6210a commit f534098
Show file tree
Hide file tree
Showing 29 changed files with 123 additions and 123 deletions.
2 changes: 1 addition & 1 deletion extensions/akismet/src/Akismet.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function sendRequest(string $type): ResponseInterface
$client = new Client();

return $client->request('POST', "$this->apiUrl/$type", [
'headers' => [
'headers' => [
'User-Agent' => "Flarum/$this->flarumVersion | Akismet/$this->extensionVersion",
],
'form_params' => $this->params,
Expand Down
1 change: 1 addition & 0 deletions extensions/flags/src/AddCanFlagAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected function checkFlagOwnPostSetting(User $actor, Post $post): bool
// If $actor is the post author, check to see if the setting is enabled
return (bool) $this->settings->get('flarum-flags.can_flag_own');
}

// $actor is not the post author
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/flags/src/Api/Serializer/FlagSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ protected function getDefaultAttributes(object|array $model): array
}

return [
'type' => $model->type,
'reason' => $model->reason,
'type' => $model->type,
'reason' => $model->reason,
'reasonDetail' => $model->reason_detail,
'createdAt' => $this->formatDate($model->created_at),
'createdAt' => $this->formatDate($model->created_at),
];
}

Expand Down
26 changes: 13 additions & 13 deletions extensions/tags/src/Api/Serializer/TagSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ protected function getDefaultAttributes(object|array $model): array
}

$attributes = [
'name' => $model->name,
'description' => $model->description,
'slug' => $this->slugManager->forResource(Tag::class)->toSlug($model),
'color' => $model->color,
'backgroundUrl' => $model->background_path,
'backgroundMode' => $model->background_mode,
'icon' => $model->icon,
'discussionCount' => (int) $model->discussion_count,
'position' => $model->position === null ? null : (int) $model->position,
'defaultSort' => $model->default_sort,
'isChild' => (bool) $model->parent_id,
'isHidden' => (bool) $model->is_hidden,
'lastPostedAt' => $this->formatDate($model->last_posted_at),
'name' => $model->name,
'description' => $model->description,
'slug' => $this->slugManager->forResource(Tag::class)->toSlug($model),
'color' => $model->color,
'backgroundUrl' => $model->background_path,
'backgroundMode' => $model->background_mode,
'icon' => $model->icon,
'discussionCount' => (int) $model->discussion_count,
'position' => $model->position === null ? null : (int) $model->position,
'defaultSort' => $model->default_sort,
'isChild' => (bool) $model->parent_id,
'isHidden' => (bool) $model->is_hidden,
'lastPostedAt' => $this->formatDate($model->last_posted_at),
'canStartDiscussion' => $this->actor->can('startDiscussion', $model),
'canAddToDiscussion' => $this->actor->can('addToDiscussion', $model)
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function tags()
['id' => 11, 'name' => 'Secondary Restricted', 'slug' => 'secondary-restricted', 'position' => null, 'parent_id' => null, 'is_restricted' => true],
['id' => 12, 'name' => 'Primary Restricted 2', 'slug' => 'primary-2-restricted', 'position' => 100, 'parent_id' => null, 'is_restricted' => true],
['id' => 13, 'name' => 'Primary Restricted 2 Child 1', 'slug' => 'primary-2-restricted-child-1', 'position' => 101, 'parent_id' => 12],
['id' => 14, 'name' => 'Primary Restricted 3', 'slug' => 'primary-3-restricted', 'position' => 102, 'parent_id' =>null, 'is_restricted' => true],
['id' => 14, 'name' => 'Primary Restricted 3', 'slug' => 'primary-3-restricted', 'position' => 102, 'parent_id' => null, 'is_restricted' => true],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function makeImage(UploadedFileInterface $file): EncodedImageInterface
}

$encodedImage = $this->imageManager->read($file->getStream()->getMetadata('uri'))
->scale(64, 64,)
->scale(64, 64)
->toPng();

$this->fileExtension = 'png';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function getDefaultAttributes(object|array $model): array

return [
'title' => $model->title,
'slug' => $this->slugManager->forResource(Discussion::class)->toSlug($model),
'slug' => $this->slugManager->forResource(Discussion::class)->toSlug($model),
];
}

Expand Down
4 changes: 2 additions & 2 deletions framework/core/src/Api/Serializer/BasicPostSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ protected function getDefaultAttributes(object|array $model): array
}

$attributes = [
'number' => (int) $model->number,
'createdAt' => $this->formatDate($model->created_at),
'number' => (int) $model->number,
'createdAt' => $this->formatDate($model->created_at),
'contentType' => $model->type
];

Expand Down
6 changes: 3 additions & 3 deletions framework/core/src/Api/Serializer/BasicUserSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ protected function getDefaultAttributes(object|array $model): array
}

return [
'username' => $model->username,
'username' => $model->username,
'displayName' => $model->display_name,
'avatarUrl' => $model->avatar_url,
'slug' => $this->slugManager->forResource(User::class)->toSlug($model)
'avatarUrl' => $model->avatar_url,
'slug' => $this->slugManager->forResource(User::class)->toSlug($model)
];
}

Expand Down
14 changes: 7 additions & 7 deletions framework/core/src/Api/Serializer/CurrentUserSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ protected function getDefaultAttributes(object|array $model): array
$attributes = parent::getDefaultAttributes($model);

$attributes += [
'isEmailConfirmed' => (bool) $model->is_email_confirmed,
'email' => $model->email,
'markedAllAsReadAt' => $this->formatDate($model->marked_all_as_read_at),
'unreadNotificationCount' => (int) $model->getUnreadNotificationCount(),
'newNotificationCount' => (int) $model->getNewNotificationCount(),
'preferences' => (array) $model->preferences,
'isAdmin' => $model->isAdmin(),
'isEmailConfirmed' => (bool) $model->is_email_confirmed,
'email' => $model->email,
'markedAllAsReadAt' => $this->formatDate($model->marked_all_as_read_at),
'unreadNotificationCount' => (int) $model->getUnreadNotificationCount(),
'newNotificationCount' => (int) $model->getNewNotificationCount(),
'preferences' => (array) $model->preferences,
'isAdmin' => $model->isAdmin(),
];

return $attributes;
Expand Down
18 changes: 9 additions & 9 deletions framework/core/src/Api/Serializer/DiscussionSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class DiscussionSerializer extends BasicDiscussionSerializer
protected function getDefaultAttributes(object|array $model): array
{
$attributes = parent::getDefaultAttributes($model) + [
'commentCount' => (int) $model->comment_count,
'participantCount' => (int) $model->participant_count,
'createdAt' => $this->formatDate($model->created_at),
'lastPostedAt' => $this->formatDate($model->last_posted_at),
'lastPostNumber' => (int) $model->last_post_number,
'canReply' => $this->actor->can('reply', $model),
'canRename' => $this->actor->can('rename', $model),
'canDelete' => $this->actor->can('delete', $model),
'canHide' => $this->actor->can('hide', $model)
'commentCount' => (int) $model->comment_count,
'participantCount' => (int) $model->participant_count,
'createdAt' => $this->formatDate($model->created_at),
'lastPostedAt' => $this->formatDate($model->last_posted_at),
'lastPostNumber' => (int) $model->last_post_number,
'canReply' => $this->actor->can('reply', $model),
'canRename' => $this->actor->can('rename', $model),
'canDelete' => $this->actor->can('delete', $model),
'canHide' => $this->actor->can('hide', $model)
];

if ($model->hidden_at) {
Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/Api/Serializer/ForumSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function getDefaultAttributes(object|array $model): array
'headerHtml' => $this->settings->get('custom_header'),
'footerHtml' => $this->settings->get('custom_footer'),
'allowSignUp' => (bool) $this->settings->get('allow_sign_up'),
'defaultRoute' => $this->settings->get('default_route'),
'defaultRoute' => $this->settings->get('default_route'),
'canViewForum' => $this->actor->can('viewForum'),
'canStartDiscussion' => $this->actor->can('startDiscussion'),
'canSearchUsers' => $this->actor->can('searchUsers'),
Expand Down
8 changes: 4 additions & 4 deletions framework/core/src/Api/Serializer/GroupSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ protected function getDefaultAttributes(object|array $model): array

return [
'nameSingular' => $this->translateGroupName($model->name_singular),
'namePlural' => $this->translateGroupName($model->name_plural),
'color' => $model->color,
'icon' => $model->icon,
'isHidden' => $model->is_hidden
'namePlural' => $this->translateGroupName($model->name_plural),
'color' => $model->color,
'icon' => $model->icon,
'isHidden' => $model->is_hidden
];
}

Expand Down
6 changes: 3 additions & 3 deletions framework/core/src/Api/Serializer/NotificationSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ protected function getDefaultAttributes(object|array $model): array

return [
'contentType' => $model->type,
'content' => $model->data,
'createdAt' => $this->formatDate($model->created_at),
'isRead' => (bool) $model->read_at
'content' => $model->data,
'createdAt' => $this->formatDate($model->created_at),
'isRead' => (bool) $model->read_at
];
}

Expand Down
4 changes: 2 additions & 2 deletions framework/core/src/Api/Serializer/PostSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ protected function getDefaultAttributes(object|array $model): array
}

$attributes += [
'canEdit' => $canEdit,
'canEdit' => $canEdit,
'canDelete' => $this->actor->can('delete', $model),
'canHide' => $this->actor->can('hide', $model)
'canHide' => $this->actor->can('hide', $model)
];

return $attributes;
Expand Down
14 changes: 7 additions & 7 deletions framework/core/src/Api/Serializer/UserSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ protected function getDefaultAttributes(object|array $model): array
$attributes = parent::getDefaultAttributes($model);

$attributes += [
'joinTime' => $this->formatDate($model->joined_at),
'discussionCount' => (int) $model->discussion_count,
'commentCount' => (int) $model->comment_count,
'canEdit' => $this->actor->can('edit', $model),
'joinTime' => $this->formatDate($model->joined_at),
'discussionCount' => (int) $model->discussion_count,
'commentCount' => (int) $model->comment_count,
'canEdit' => $this->actor->can('edit', $model),
'canEditCredentials' => $this->actor->can('editCredentials', $model),
'canEditGroups' => $this->actor->can('editGroups', $model),
'canDelete' => $this->actor->can('delete', $model),
'canEditGroups' => $this->actor->can('editGroups', $model),
'canDelete' => $this->actor->can('delete', $model),
];

if ($model->getPreference('discloseOnline') || $this->actor->can('viewLastSeenAt', $model)) {
Expand All @@ -39,7 +39,7 @@ protected function getDefaultAttributes(object|array $model): array
if ($attributes['canEditCredentials'] || $this->actor->id === $model->id) {
$attributes += [
'isEmailConfirmed' => (bool) $model->is_email_confirmed,
'email' => $model->email
'email' => $model->email
];
}

Expand Down
16 changes: 8 additions & 8 deletions framework/core/src/Extension/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,15 @@ public function migrate(Migrator $migrator, string $direction = 'up'): ?int
public function toArray(): array
{
return (array) array_merge([
'id' => $this->getId(),
'version' => $this->getVersion(),
'path' => $this->getPath(),
'icon' => $this->getIcon(),
'hasAssets' => $this->hasAssets(),
'hasMigrations' => $this->hasMigrations(),
'id' => $this->getId(),
'version' => $this->getVersion(),
'path' => $this->getPath(),
'icon' => $this->getIcon(),
'hasAssets' => $this->hasAssets(),
'hasMigrations' => $this->hasMigrations(),
'extensionDependencyIds' => $this->getExtensionDependencyIds(),
'optionalDependencyIds' => $this->getOptionalDependencyIds(),
'links' => $this->getLinks(),
'optionalDependencyIds' => $this->getOptionalDependencyIds(),
'links' => $this->getLinks(),
], $this->composerJson);
}

Expand Down
8 changes: 4 additions & 4 deletions framework/core/src/Filesystem/FilesystemServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public function register(): void
return [
'flarum-assets' => function (Paths $paths, UrlGenerator $url) {
return [
'root' => "$paths->public/assets",
'url' => $url->to('forum')->path('assets'),
'root' => "$paths->public/assets",
'url' => $url->to('forum')->path('assets'),
'visibility' => Visibility::PUBLIC
];
},
'flarum-avatars' => function (Paths $paths, UrlGenerator $url) {
return [
'root' => "$paths->public/assets/avatars",
'url' => $url->to('forum')->path('assets/avatars')
'root' => "$paths->public/assets/avatars",
'url' => $url->to('forum')->path('assets/avatars')
];
},
];
Expand Down
32 changes: 16 additions & 16 deletions framework/core/src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,22 @@ protected function fireAppCallbacks(array $callbacks): void
public function registerCoreContainerAliases(): void
{
$aliases = [
'app' => [\Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class],
'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class],
'db' => [\Illuminate\Database\DatabaseManager::class],
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
'files' => [\Illuminate\Filesystem\Filesystem::class],
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Contracts\Hashing\Hasher::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class],
'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class],
'app' => [\Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class],
'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class],
'db' => [\Illuminate\Database\DatabaseManager::class],
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
'files' => [\Illuminate\Filesystem\Filesystem::class],
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Contracts\Hashing\Hasher::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class],
'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class],
];

foreach ($aliases as $key => $aliasGroup) {
Expand Down
6 changes: 3 additions & 3 deletions framework/core/src/Frontend/FrontendServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ function (Container $container) {

$this->container->singleton('flarum.less.config', function (Container $container) {
return [
'config-primary-color' => [
'config-primary-color' => [
'key' => 'theme_primary_color',
],
'config-secondary-color' => [
'key' => 'theme_secondary_color',
],
'config-dark-mode' => [
'config-dark-mode' => [
'key' => 'theme_dark_mode',
'callback' => function ($value) {
return $value ? 'true' : 'false';
},
],
'config-colored-header' => [
'config-colored-header' => [
'key' => 'theme_colored_header',
'callback' => function ($value) {
return $value ? 'true' : 'false';
Expand Down
6 changes: 3 additions & 3 deletions framework/core/src/Image/ImageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function register(): void
'imagick' => Drivers\Imagick\Driver::class
];
});

$this->container->singleton('image', function (Container $container): ImageManager {
$interventionDrivers = $container->make('image.drivers');

Expand All @@ -37,11 +37,11 @@ public function register(): void
$driver = $configDriver ?? 'gd';

// Check that the imagick library is actually available, else default back to gd.
if ($driver === 'imagick' && !extension_loaded('imagick')) {
if ($driver === 'imagick' && ! extension_loaded('imagick')) {
$driver = 'gd';
}

if (!Arr::has($interventionDrivers, $driver)) {
if (! Arr::has($interventionDrivers, $driver)) {
throw new RuntimeException("intervention/image: $driver is not valid");
}

Expand Down
Loading

0 comments on commit f534098

Please sign in to comment.