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 Sep 26, 2024
1 parent 36df371 commit 10d0f60
Show file tree
Hide file tree
Showing 44 changed files with 155 additions and 140 deletions.
2 changes: 1 addition & 1 deletion extensions/akismet/src/Akismet.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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 @@ -40,6 +40,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 @@ -31,10 +31,10 @@ protected function getDefaultAttributes($flag)
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Carbon\Carbon;
use Flarum\Extend;
use Flarum\Formatter\Formatter;
use Flarum\Post\Post;
use Flarum\Post\CommentPost;
use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\DisplayName\DriverInterface;
Expand Down Expand Up @@ -574,7 +574,6 @@ public function rendering_post_mention_without_a_context_works()

$this->assertStringContainsString('TOBY$', $renderedHtml);
}

}

class CustomOtherDisplayNameDriver implements DriverInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

use Illuminate\Database\Schema\Builder;

return [
Expand Down
7 changes: 7 additions & 0 deletions extensions/package-manager/src/AllValidatorRules.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

namespace Flarum\ExtensionManager;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\CheckForUpdates;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\ExtensionManager\Composer\ComposerJson;
use Flarum\ExtensionManager\ConfigureAuthValidator;
use Flarum\ExtensionManager\ConfigureComposerValidator;
use Flarum\Foundation\Paths;
use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Composer\ComposerJson;
use Flarum\ExtensionManager\ConfigureComposerValidator;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\GlobalUpdate;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Api\Controller\AbstractListController;
use Flarum\Http\RequestUtil;
use Flarum\Http\UrlGenerator;
use Flarum\ExtensionManager\Api\Serializer\TaskSerializer;
use Flarum\ExtensionManager\Task\Task;
use Flarum\Http\RequestUtil;
use Flarum\Http\UrlGenerator;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\MajorUpdate;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\MinorUpdate;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\RemoveExtension;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\RequireExtension;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\UpdateExtension;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Flarum\ExtensionManager\Api\Controller;

use Flarum\Http\RequestUtil;
use Flarum\ExtensionManager\Command\WhyNot;
use Flarum\ExtensionManager\Job\Dispatcher;
use Flarum\Http\RequestUtil;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
namespace Flarum\ExtensionManager\Command;

use Flarum\Bus\Dispatcher as FlarumDispatcher;
use Flarum\Foundation\Config;
use Flarum\ExtensionManager\Composer\ComposerAdapter;
use Flarum\ExtensionManager\Event\FlarumUpdated;
use Flarum\ExtensionManager\Exception\ComposerUpdateFailedException;
use Flarum\Foundation\Config;
use Illuminate\Contracts\Events\Dispatcher;
use Symfony\Component\Console\Input\ArrayInput;

Expand Down
4 changes: 2 additions & 2 deletions extensions/package-manager/src/Composer/ComposerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

use Composer\Config;
use Composer\Console\Application;
use Flarum\Foundation\Paths;
use Flarum\ExtensionManager\OutputLogger;
use Flarum\ExtensionManager\Support\Util;
use Flarum\ExtensionManager\Task\Task;
use Flarum\Foundation\Paths;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
Expand Down Expand Up @@ -68,7 +68,7 @@ public function run(InputInterface $input, ?Task $task = null, bool $safeMode =
chdir($this->paths->base);

if ($safeMode) {
$temporaryVendorDir = $this->paths->base . DIRECTORY_SEPARATOR . 'temp-vendor';
$temporaryVendorDir = $this->paths->base.DIRECTORY_SEPARATOR.'temp-vendor';
if (! $this->filesystem->isDirectory($temporaryVendorDir)) {
$this->filesystem->makeDirectory($temporaryVendorDir);
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/package-manager/src/Composer/ComposerJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace Flarum\ExtensionManager\Composer;

use Flarum\Extension\ExtensionManager;
use Flarum\Foundation\Paths;
use Flarum\ExtensionManager\Support\Util;
use Flarum\Foundation\Paths;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
use Composer\Console\Application;
use Composer\Util\Platform;
use Flarum\Extension\ExtensionManager;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Foundation\Paths;
use Flarum\Frontend\RecompileFrontendAssets;
use Flarum\Locale\LocaleManager;
use Flarum\ExtensionManager\Composer\ComposerAdapter;
use Flarum\ExtensionManager\Event\FlarumUpdated;
use Flarum\ExtensionManager\Extension\Event\Updated;
use Flarum\ExtensionManager\Listener\ClearCacheAfterUpdate;
use Flarum\ExtensionManager\Listener\ReCheckForUpdates;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Foundation\Paths;
use Flarum\Frontend\RecompileFrontendAssets;
use Flarum\Locale\LocaleManager;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

use Composer\Command\ClearCacheCommand;
use Flarum\Database\Console\MigrateCommand;
use Flarum\Foundation\Console\AssetsPublishCommand;
use Flarum\ExtensionManager\Event\FlarumUpdated;
use Flarum\Foundation\Console\AssetsPublishCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

Expand Down
2 changes: 1 addition & 1 deletion extensions/package-manager/tests/integration/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace Flarum\ExtensionManager\Tests\integration;

use Flarum\Foundation\Paths;
use Flarum\ExtensionManager\Composer\ComposerAdapter;
use Flarum\ExtensionManager\Composer\ComposerJson;
use Flarum\ExtensionManager\Support\Util;
use Flarum\Foundation\Paths;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Illuminate\Support\Arr;
use Psr\Http\Message\ResponseInterface;
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 @@ -47,19 +47,19 @@ protected function getDefaultAttributes($tag)
}

$attributes = [
'name' => $tag->name,
'description' => $tag->description,
'slug' => $this->slugManager->forResource(Tag::class)->toSlug($tag),
'color' => $tag->color,
'backgroundUrl' => $tag->background_path,
'backgroundMode' => $tag->background_mode,
'icon' => $tag->icon,
'discussionCount' => (int) $tag->discussion_count,
'position' => $tag->position === null ? null : (int) $tag->position,
'defaultSort' => $tag->default_sort,
'isChild' => (bool) $tag->parent_id,
'isHidden' => (bool) $tag->is_hidden,
'lastPostedAt' => $this->formatDate($tag->last_posted_at),
'name' => $tag->name,
'description' => $tag->description,
'slug' => $this->slugManager->forResource(Tag::class)->toSlug($tag),
'color' => $tag->color,
'backgroundUrl' => $tag->background_path,
'backgroundMode' => $tag->background_mode,
'icon' => $tag->icon,
'discussionCount' => (int) $tag->discussion_count,
'position' => $tag->position === null ? null : (int) $tag->position,
'defaultSort' => $tag->default_sort,
'isChild' => (bool) $tag->parent_id,
'isHidden' => (bool) $tag->is_hidden,
'lastPostedAt' => $this->formatDate($tag->last_posted_at),
'canStartDiscussion' => $this->actor->can('startDiscussion', $tag),
'canAddToDiscussion' => $this->actor->can('addToDiscussion', $tag)
];
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 getDefaultAttributes($discussion)

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

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 @@ -53,8 +53,8 @@ protected function getDefaultAttributes($post)
}

$attributes = [
'number' => (int) $post->number,
'createdAt' => $this->formatDate($post->created_at),
'number' => (int) $post->number,
'createdAt' => $this->formatDate($post->created_at),
'contentType' => $post->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 @@ -45,10 +45,10 @@ protected function getDefaultAttributes($user)
}

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

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 @@ -20,13 +20,13 @@ protected function getDefaultAttributes($user)
$attributes = parent::getDefaultAttributes($user);

$attributes += [
'isEmailConfirmed' => (bool) $user->is_email_confirmed,
'email' => $user->email,
'markedAllAsReadAt' => $this->formatDate($user->marked_all_as_read_at),
'unreadNotificationCount' => (int) $user->getUnreadNotificationCount(),
'newNotificationCount' => (int) $user->getNewNotificationCount(),
'preferences' => (array) $user->preferences,
'isAdmin' => $user->isAdmin(),
'isEmailConfirmed' => (bool) $user->is_email_confirmed,
'email' => $user->email,
'markedAllAsReadAt' => $this->formatDate($user->marked_all_as_read_at),
'unreadNotificationCount' => (int) $user->getUnreadNotificationCount(),
'newNotificationCount' => (int) $user->getNewNotificationCount(),
'preferences' => (array) $user->preferences,
'isAdmin' => $user->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($discussion)
{
$attributes = parent::getDefaultAttributes($discussion) + [
'commentCount' => (int) $discussion->comment_count,
'participantCount' => (int) $discussion->participant_count,
'createdAt' => $this->formatDate($discussion->created_at),
'lastPostedAt' => $this->formatDate($discussion->last_posted_at),
'lastPostNumber' => (int) $discussion->last_post_number,
'canReply' => $this->actor->can('reply', $discussion),
'canRename' => $this->actor->can('rename', $discussion),
'canDelete' => $this->actor->can('delete', $discussion),
'canHide' => $this->actor->can('hide', $discussion)
'commentCount' => (int) $discussion->comment_count,
'participantCount' => (int) $discussion->participant_count,
'createdAt' => $this->formatDate($discussion->created_at),
'lastPostedAt' => $this->formatDate($discussion->last_posted_at),
'lastPostNumber' => (int) $discussion->last_post_number,
'canReply' => $this->actor->can('reply', $discussion),
'canRename' => $this->actor->can('rename', $discussion),
'canDelete' => $this->actor->can('delete', $discussion),
'canHide' => $this->actor->can('hide', $discussion)
];

if ($discussion->hidden_at) {
Expand Down
Loading

0 comments on commit 10d0f60

Please sign in to comment.