From a6cf10f8546c3b2b2d0e0e338800ee57b5b66adc Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 25 Feb 2016 22:09:39 -0500 Subject: [PATCH] Applied fixes from StyleCI --- ...05_042721_change_access_tokens_columns.php | 1 - ...7_change_settings_value_column_to_text.php | 1 - src/Admin/Controller/ClientController.php | 10 +++---- .../Middleware/RequireAdministrateAbility.php | 2 -- src/Admin/Server.php | 2 +- src/Api/Client.php | 2 +- src/Api/Controller/ListPostsController.php | 2 +- .../Controller/ShowDiscussionController.php | 6 ++--- src/Api/Controller/TokenController.php | 4 +-- src/Api/Serializer/AbstractSerializer.php | 5 +--- .../Serializer/DiscussionBasicSerializer.php | 2 +- src/Api/Serializer/GroupSerializer.php | 2 +- src/Api/Serializer/NotificationSerializer.php | 2 +- src/Api/Serializer/PostBasicSerializer.php | 2 +- src/Api/Serializer/UserBasicSerializer.php | 2 +- src/Asset/AssetManager.php | 6 ++--- src/Asset/JsCompiler.php | 2 +- src/Asset/RevisionCompiler.php | 4 +-- .../Command/GenerateExtensionCommand.php | 6 ++--- .../Command/GenerateMigrationCommand.php | 7 +++-- src/Core/Access/Gate.php | 9 +++++++ src/Core/Access/PostPolicy.php | 2 +- src/Core/Command/EditDiscussion.php | 4 +-- .../Command/ReadAllNotificationsHandler.php | 1 - src/Core/Command/ReadDiscussion.php | 8 +++--- src/Core/Command/RegisterUserHandler.php | 4 +-- .../Command/RequestPasswordResetHandler.php | 10 +++---- src/Core/Command/UploadAvatarHandler.php | 4 +-- src/Core/Discussion.php | 13 +++++----- src/Core/DiscussionState.php | 2 +- src/Core/Group.php | 8 +++--- .../Listener/DiscussionMetadataUpdater.php | 2 +- .../Listener/DiscussionRenamedNotifier.php | 4 +-- src/Core/Listener/UserMetadataUpdater.php | 8 +++--- .../NotificationServiceProvider.php | 1 - src/Core/Notification/NotificationSyncer.php | 4 +-- src/Core/Post.php | 5 +--- src/Core/Post/CommentPost.php | 8 +++--- src/Core/Post/DiscussionRenamedPost.php | 10 +++---- src/Core/Repository/DiscussionRepository.php | 4 +-- src/Core/Repository/PostRepository.php | 16 ++++++------ src/Core/Repository/UserRepository.php | 2 +- src/Core/Search/AbstractRegexGambit.php | 4 +-- .../Search/Discussion/DiscussionSearcher.php | 8 +++--- .../Search/Discussion/Gambit/AuthorGambit.php | 2 +- .../Discussion/Gambit/FulltextGambit.php | 2 +- .../Search/Discussion/Gambit/HiddenGambit.php | 2 +- .../Search/Discussion/Gambit/UnreadGambit.php | 2 +- src/Core/Search/GambitManager.php | 4 +-- src/Core/Search/User/Gambit/EmailGambit.php | 2 +- src/Core/Search/User/UserSearcher.php | 2 +- src/Core/Support/ScopeVisibilityTrait.php | 2 +- src/Core/User.php | 18 ++++++------- src/Database/AbstractModel.php | 4 +-- src/Database/DatabaseServiceProvider.php | 1 - src/Database/Migrator.php | 8 +++--- src/Event/ConfigureNotificationTypes.php | 4 +-- src/Event/PrepareUserGroups.php | 2 +- src/Event/ScopeHiddenDiscussionVisibility.php | 2 +- src/Event/ScopePostVisibility.php | 2 +- src/Extension/Extension.php | 21 +++++++-------- src/Extension/ExtensionManager.php | 26 +++++++++---------- src/Formatter/Formatter.php | 2 +- .../Controller/AbstractOAuth2Controller.php | 1 - .../Controller/AuthorizedClientController.php | 5 ++-- src/Forum/Controller/ClientController.php | 4 +-- src/Forum/Controller/DiscussionController.php | 4 +-- src/Forum/Controller/LogInController.php | 4 +-- src/Forum/Controller/RegisterController.php | 1 - .../Controller/ResetPasswordController.php | 6 ++--- .../Controller/SavePasswordController.php | 1 - src/Foundation/AbstractServer.php | 3 +-- src/Foundation/Application.php | 2 +- src/Http/AbstractUrlGenerator.php | 4 +-- .../Controller/AbstractClientController.php | 1 - .../Controller/AbstractHtmlController.php | 1 - src/Http/Controller/ClientView.php | 4 +-- src/Http/GenerateRouteHandlerTrait.php | 2 +- .../Middleware/AuthenticateWithHeader.php | 1 - src/Http/Middleware/DispatchRoute.php | 1 - src/Http/Middleware/HandleErrors.php | 2 +- src/Http/RouteCollection.php | 2 +- src/Install/Console/FileDataProvider.php | 6 ++--- src/Install/Console/InstallCommand.php | 16 +++++------- src/Install/Console/UserDataProvider.php | 6 ++--- src/Install/Controller/IndexController.php | 4 +-- src/Install/Controller/InstallController.php | 25 ++++++++---------- src/Locale/JsCompiler.php | 4 +-- src/Locale/Translator.php | 2 +- .../MemoryCacheSettingsRepository.php | 4 +-- src/Update/Console/MigrateCommand.php | 6 +---- src/Update/Controller/IndexController.php | 2 +- .../DatabaseSettingsRepositoryTest.php | 16 +++++++++--- .../MemoryCacheSettingsRepositoryTest.php | 14 ++++++++-- tests/Test/TestCase.php | 10 +++++++ views/install/app.php | 2 +- 96 files changed, 240 insertions(+), 245 deletions(-) diff --git a/migrations/2015_12_05_042721_change_access_tokens_columns.php b/migrations/2015_12_05_042721_change_access_tokens_columns.php index 3e3b2c96b..e41ba4746 100644 --- a/migrations/2015_12_05_042721_change_access_tokens_columns.php +++ b/migrations/2015_12_05_042721_change_access_tokens_columns.php @@ -8,7 +8,6 @@ * file that was distributed with this source code. */ - use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Builder; diff --git a/migrations/2015_12_17_194247_change_settings_value_column_to_text.php b/migrations/2015_12_17_194247_change_settings_value_column_to_text.php index 5e0edff4f..619b28b3c 100644 --- a/migrations/2015_12_17_194247_change_settings_value_column_to_text.php +++ b/migrations/2015_12_17_194247_change_settings_value_column_to_text.php @@ -8,7 +8,6 @@ * file that was distributed with this source code. */ - use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Builder; diff --git a/src/Admin/Controller/ClientController.php b/src/Admin/Controller/ClientController.php index b47e1679a..d91818ae5 100644 --- a/src/Admin/Controller/ClientController.php +++ b/src/Admin/Controller/ClientController.php @@ -10,17 +10,17 @@ namespace Flarum\Admin\Controller; +use Flarum\Api\Client; +use Flarum\Core\Permission; +use Flarum\Event\PrepareUnserializedSettings; +use Flarum\Extension\ExtensionManager; use Flarum\Foundation\Application; use Flarum\Http\Controller\AbstractClientController as BaseClientController; -use Flarum\Extension\ExtensionManager; use Flarum\Locale\LocaleManager; +use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; -use Flarum\Core\Permission; -use Flarum\Api\Client; -use Flarum\Settings\SettingsRepositoryInterface; -use Flarum\Event\PrepareUnserializedSettings; class ClientController extends BaseClientController { diff --git a/src/Admin/Middleware/RequireAdministrateAbility.php b/src/Admin/Middleware/RequireAdministrateAbility.php index ad6f2ea2c..8bf08abc0 100644 --- a/src/Admin/Middleware/RequireAdministrateAbility.php +++ b/src/Admin/Middleware/RequireAdministrateAbility.php @@ -13,12 +13,10 @@ namespace Flarum\Admin\Middleware; use Exception; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Forum\Controller\LogInController; -use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\View\Factory; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\HtmlResponse; -use Zend\Diactoros\Response\RedirectResponse; use Zend\Stratigility\MiddlewareInterface; class RequireAdministrateAbility implements MiddlewareInterface diff --git a/src/Admin/Server.php b/src/Admin/Server.php index 8d560ab5c..b1ea2d4f6 100644 --- a/src/Admin/Server.php +++ b/src/Admin/Server.php @@ -28,7 +28,7 @@ class Server extends AbstractServer if ($app->isInstalled()) { $path = parse_url($app->url('admin'), PHP_URL_PATH); - $errorDir = __DIR__ . '/../../error'; + $errorDir = __DIR__.'/../../error'; if ($app->isUpToDate()) { $pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody')); diff --git a/src/Api/Client.php b/src/Api/Client.php index e798526ce..c4ea6f965 100644 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -60,7 +60,7 @@ class Client if (! ($controller instanceof ControllerInterface)) { throw new InvalidArgumentException('Endpoint must be an instance of ' - . ControllerInterface::class); + .ControllerInterface::class); } try { diff --git a/src/Api/Controller/ListPostsController.php b/src/Api/Controller/ListPostsController.php index 4656cc480..c50175e5f 100644 --- a/src/Api/Controller/ListPostsController.php +++ b/src/Api/Controller/ListPostsController.php @@ -87,7 +87,7 @@ class ListPostsController extends AbstractCollectionController if (($near = array_get($queryParams, 'page.near')) > 1) { if (count($filter) > 1 || ! isset($filter['discussion']) || $sort) { throw new InvalidParameterException('You can only use page[near] with ' - . 'filter[discussion] and the default sort order'); + .'filter[discussion] and the default sort order'); } $offset = $this->posts->getIndexForNumber($filter['discussion'], $near, $actor); diff --git a/src/Api/Controller/ShowDiscussionController.php b/src/Api/Controller/ShowDiscussionController.php index e08321adf..cda6b4546 100644 --- a/src/Api/Controller/ShowDiscussionController.php +++ b/src/Api/Controller/ShowDiscussionController.php @@ -25,12 +25,12 @@ class ShowDiscussionController extends AbstractResourceController protected $discussions; /** - * @inheritdoc + * {@inheritdoc} */ public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer'; /** - * @inheritdoc + * {@inheritdoc} */ public $include = [ 'posts', @@ -42,7 +42,7 @@ class ShowDiscussionController extends AbstractResourceController ]; /** - * @inheritdoc + * {@inheritdoc} */ public $optionalInclude = [ 'startUser', diff --git a/src/Api/Controller/TokenController.php b/src/Api/Controller/TokenController.php index f6e4428e0..cb32c7bc2 100644 --- a/src/Api/Controller/TokenController.php +++ b/src/Api/Controller/TokenController.php @@ -68,9 +68,9 @@ class TokenController implements ControllerInterface $token = AccessToken::generate($user->id, $lifetime); $token->save(); - return (new JsonResponse([ + return new JsonResponse([ 'token' => $token->id, 'userId' => $user->id - ])); + ]); } } diff --git a/src/Api/Serializer/AbstractSerializer.php b/src/Api/Serializer/AbstractSerializer.php index c49c48a6f..6d72455bc 100644 --- a/src/Api/Serializer/AbstractSerializer.php +++ b/src/Api/Serializer/AbstractSerializer.php @@ -12,8 +12,6 @@ namespace Flarum\Api\Serializer; use Closure; use DateTime; -use Flarum\Api\Relationship\HasManyBuilder; -use Flarum\Api\Relationship\HasOneBuilder; use Flarum\Core\User; use Flarum\Event\GetApiRelationship; use Flarum\Event\PrepareApiAttributes; @@ -24,7 +22,6 @@ use LogicException; use Tobscure\JsonApi\AbstractSerializer as BaseAbstractSerializer; use Tobscure\JsonApi\Collection; use Tobscure\JsonApi\Relationship; -use Tobscure\JsonApi\Relationship\BuilderInterface; use Tobscure\JsonApi\Resource; use Tobscure\JsonApi\SerializerInterface; @@ -125,7 +122,7 @@ abstract class AbstractSerializer extends BaseAbstractSerializer if ($relationship && ! ($relationship instanceof Relationship)) { throw new LogicException('GetApiRelationship handler must return an instance of ' - . Relationship::class); + .Relationship::class); } return $relationship; diff --git a/src/Api/Serializer/DiscussionBasicSerializer.php b/src/Api/Serializer/DiscussionBasicSerializer.php index 3a3ed157e..b56044c4c 100644 --- a/src/Api/Serializer/DiscussionBasicSerializer.php +++ b/src/Api/Serializer/DiscussionBasicSerializer.php @@ -30,7 +30,7 @@ class DiscussionBasicSerializer extends AbstractSerializer { if (! ($discussion instanceof Discussion)) { throw new InvalidArgumentException(get_class($this) - . ' can only serialize instances of ' . Discussion::class); + .' can only serialize instances of '.Discussion::class); } return [ diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index 393a00758..81b514fb3 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -44,7 +44,7 @@ class GroupSerializer extends AbstractSerializer { if (! ($group instanceof Group)) { throw new InvalidArgumentException(get_class($this) - . ' can only serialize instances of ' . Group::class); + .' can only serialize instances of '.Group::class); } return [ diff --git a/src/Api/Serializer/NotificationSerializer.php b/src/Api/Serializer/NotificationSerializer.php index 30874aa33..45912300d 100644 --- a/src/Api/Serializer/NotificationSerializer.php +++ b/src/Api/Serializer/NotificationSerializer.php @@ -38,7 +38,7 @@ class NotificationSerializer extends AbstractSerializer { if (! ($notification instanceof Notification)) { throw new InvalidArgumentException(get_class($this) - . ' can only serialize instances of ' . Notification::class); + .' can only serialize instances of '.Notification::class); } return [ diff --git a/src/Api/Serializer/PostBasicSerializer.php b/src/Api/Serializer/PostBasicSerializer.php index d4ede57b3..54b9475f5 100644 --- a/src/Api/Serializer/PostBasicSerializer.php +++ b/src/Api/Serializer/PostBasicSerializer.php @@ -31,7 +31,7 @@ class PostBasicSerializer extends AbstractSerializer { if (! ($post instanceof Post)) { throw new InvalidArgumentException(get_class($this) - . ' can only serialize instances of ' . Post::class); + .' can only serialize instances of '.Post::class); } $attributes = [ diff --git a/src/Api/Serializer/UserBasicSerializer.php b/src/Api/Serializer/UserBasicSerializer.php index 74bde6b81..88d66f6a2 100644 --- a/src/Api/Serializer/UserBasicSerializer.php +++ b/src/Api/Serializer/UserBasicSerializer.php @@ -30,7 +30,7 @@ class UserBasicSerializer extends AbstractSerializer { if (! ($user instanceof User)) { throw new InvalidArgumentException(get_class($this) - . ' can only serialize instances of ' . User::class); + .' can only serialize instances of '.User::class); } return [ diff --git a/src/Asset/AssetManager.php b/src/Asset/AssetManager.php index fcde2655d..fad3af170 100644 --- a/src/Asset/AssetManager.php +++ b/src/Asset/AssetManager.php @@ -39,8 +39,8 @@ class AssetManager */ public function setFilename($filename) { - $this->js->setFilename($filename . '.js'); - $this->less->setFilename($filename . '.css'); + $this->js->setFilename($filename.'.js'); + $this->less->setFilename($filename.'.css'); } /** @@ -61,7 +61,7 @@ class AssetManager break; default: - throw new DomainException('Unsupported asset type: ' . $ext); + throw new DomainException('Unsupported asset type: '.$ext); } } diff --git a/src/Asset/JsCompiler.php b/src/Asset/JsCompiler.php index b063aaf0a..798ca74f2 100644 --- a/src/Asset/JsCompiler.php +++ b/src/Asset/JsCompiler.php @@ -53,7 +53,7 @@ class JsCompiler extends RevisionCompiler } /** - * @inheritDoc + * {@inheritdoc} */ protected function getCacheDifferentiator() { diff --git a/src/Asset/RevisionCompiler.php b/src/Asset/RevisionCompiler.php index 5b256af95..01a35ff73 100644 --- a/src/Asset/RevisionCompiler.php +++ b/src/Asset/RevisionCompiler.php @@ -104,7 +104,7 @@ class RevisionCompiler implements CompilerInterface */ protected function getCacheDifferentiator() { - return null; + return; } /** @@ -189,7 +189,7 @@ class RevisionCompiler implements CompilerInterface $ext = pathinfo($this->filename, PATHINFO_EXTENSION); - $file = $this->path . '/' . substr_replace($this->filename, '-' . $revision, -strlen($ext) - 1, 0); + $file = $this->path.'/'.substr_replace($this->filename, '-'.$revision, -strlen($ext) - 1, 0); if (file_exists($file)) { unlink($file); diff --git a/src/Console/Command/GenerateExtensionCommand.php b/src/Console/Command/GenerateExtensionCommand.php index 9aefaf983..eb70644ac 100644 --- a/src/Console/Command/GenerateExtensionCommand.php +++ b/src/Console/Command/GenerateExtensionCommand.php @@ -10,10 +10,8 @@ namespace Flarum\Console\Command; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Question\Question; use Flarum\Foundation\Application; +use Symfony\Component\Console\Question\Question; class GenerateExtensionCommand extends AbstractCommand { @@ -21,7 +19,7 @@ class GenerateExtensionCommand extends AbstractCommand { $this ->setName('generate:extension') - ->setDescription("Generate a Flarum extension skeleton."); + ->setDescription('Generate a Flarum extension skeleton.'); } /** diff --git a/src/Console/Command/GenerateMigrationCommand.php b/src/Console/Command/GenerateMigrationCommand.php index 51aaf1498..ca5d3c7fc 100644 --- a/src/Console/Command/GenerateMigrationCommand.php +++ b/src/Console/Command/GenerateMigrationCommand.php @@ -10,10 +10,9 @@ namespace Flarum\Console\Command; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Question\Question; use Flarum\Database\MigrationCreator; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; class GenerateMigrationCommand extends AbstractCommand { @@ -39,7 +38,7 @@ class GenerateMigrationCommand extends AbstractCommand { $this ->setName('generate:migration') - ->setDescription("Generate a migration.") + ->setDescription('Generate a migration.') ->addArgument( 'name', InputArgument::REQUIRED, diff --git a/src/Core/Access/Gate.php b/src/Core/Access/Gate.php index 43ac8adab..f6eba5078 100644 --- a/src/Core/Access/Gate.php +++ b/src/Core/Access/Gate.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Flarum\Core\Access; use Illuminate\Contracts\Auth\Access\Gate as GateContract; diff --git a/src/Core/Access/PostPolicy.php b/src/Core/Access/PostPolicy.php index 26709745b..146c9e618 100644 --- a/src/Core/Access/PostPolicy.php +++ b/src/Core/Access/PostPolicy.php @@ -45,7 +45,7 @@ class PostPolicy extends AbstractPolicy } /** - * @inheritDoc + * {@inheritdoc} */ public function subscribe(Dispatcher $events) { diff --git a/src/Core/Command/EditDiscussion.php b/src/Core/Command/EditDiscussion.php index 2c2909e07..dc6b1e3e2 100644 --- a/src/Core/Command/EditDiscussion.php +++ b/src/Core/Command/EditDiscussion.php @@ -17,7 +17,7 @@ class EditDiscussion /** * The ID of the discussion to edit. * - * @var integer + * @var int */ public $discussionId; @@ -36,7 +36,7 @@ class EditDiscussion public $data; /** - * @param integer $discussionId The ID of the discussion to edit. + * @param int $discussionId The ID of the discussion to edit. * @param \Flarum\Core\User $actor The user performing the action. * @param array $data The attributes to update on the discussion. */ diff --git a/src/Core/Command/ReadAllNotificationsHandler.php b/src/Core/Command/ReadAllNotificationsHandler.php index e783c8cf3..3fc8bf29f 100644 --- a/src/Core/Command/ReadAllNotificationsHandler.php +++ b/src/Core/Command/ReadAllNotificationsHandler.php @@ -11,7 +11,6 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Notification; use Flarum\Core\Repository\NotificationRepository; class ReadAllNotificationsHandler diff --git a/src/Core/Command/ReadDiscussion.php b/src/Core/Command/ReadDiscussion.php index a5cbb1547..32d655c68 100644 --- a/src/Core/Command/ReadDiscussion.php +++ b/src/Core/Command/ReadDiscussion.php @@ -17,7 +17,7 @@ class ReadDiscussion /** * The ID of the discussion to mark as read. * - * @var integer + * @var int */ public $discussionId; @@ -31,14 +31,14 @@ class ReadDiscussion /** * The number of the post to mark as read. * - * @var integer + * @var int */ public $readNumber; /** - * @param integer $discussionId The ID of the discussion to mark as read. + * @param int $discussionId The ID of the discussion to mark as read. * @param User $actor The user to mark the discussion as read for. - * @param integer $readNumber The number of the post to mark as read. + * @param int $readNumber The number of the post to mark as read. */ public function __construct($discussionId, User $actor, $readNumber) { diff --git a/src/Core/Command/RegisterUserHandler.php b/src/Core/Command/RegisterUserHandler.php index 2a46e77b7..0629e4681 100644 --- a/src/Core/Command/RegisterUserHandler.php +++ b/src/Core/Command/RegisterUserHandler.php @@ -170,10 +170,10 @@ class RegisterUserHandler 'target' => $this->uploadDir, ]); - $uploadName = Str::lower(Str::quickRandom()) . '.jpg'; + $uploadName = Str::lower(Str::quickRandom()).'.jpg'; $user->changeAvatarPath($uploadName); - $mount->move("source://".pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName"); + $mount->move('source://'.pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName"); } } diff --git a/src/Core/Command/RequestPasswordResetHandler.php b/src/Core/Command/RequestPasswordResetHandler.php index a75c9dcf5..3fafe078e 100644 --- a/src/Core/Command/RequestPasswordResetHandler.php +++ b/src/Core/Command/RequestPasswordResetHandler.php @@ -10,14 +10,14 @@ namespace Flarum\Core\Command; -use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\Core; use Flarum\Core\PasswordToken; use Flarum\Core\Repository\UserRepository; -use Illuminate\Contracts\Mail\Mailer; -use Illuminate\Mail\Message; -use Illuminate\Database\Eloquent\ModelNotFoundException; -use Flarum\Core; use Flarum\Forum\UrlGenerator; +use Flarum\Settings\SettingsRepositoryInterface; +use Illuminate\Contracts\Mail\Mailer; +use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Mail\Message; use Symfony\Component\Translation\TranslatorInterface; class RequestPasswordResetHandler diff --git a/src/Core/Command/UploadAvatarHandler.php b/src/Core/Command/UploadAvatarHandler.php index a22e74a15..fda27fc3a 100644 --- a/src/Core/Command/UploadAvatarHandler.php +++ b/src/Core/Command/UploadAvatarHandler.php @@ -111,11 +111,11 @@ class UploadAvatarHandler $mount->delete($file); } - $uploadName = Str::lower(Str::quickRandom()) . '.jpg'; + $uploadName = Str::lower(Str::quickRandom()).'.jpg'; $user->changeAvatarPath($uploadName); - $mount->move("source://".pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName"); + $mount->move('source://'.pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName"); $user->save(); diff --git a/src/Core/Discussion.php b/src/Core/Discussion.php index 8b6942719..075ba60b4 100644 --- a/src/Core/Discussion.php +++ b/src/Core/Discussion.php @@ -10,7 +10,6 @@ namespace Flarum\Core; -use Flarum\Core\Post; use Flarum\Core\Post\MergeableInterface; use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Core\Support\ScopeVisibilityTrait; @@ -119,8 +118,8 @@ class Discussion extends AbstractModel { $discussion = new static; - $discussion->title = $title; - $discussion->start_time = time(); + $discussion->title = $title; + $discussion->start_time = time(); $discussion->start_user_id = $user->id; $discussion->setRelation('startUser', $user); @@ -191,7 +190,7 @@ class Discussion extends AbstractModel */ public function setStartPost(Post $post) { - $this->start_time = $post->time; + $this->start_time = $post->time; $this->start_user_id = $post->user_id; $this->start_post_id = $post->id; @@ -206,9 +205,9 @@ class Discussion extends AbstractModel */ public function setLastPost(Post $post) { - $this->last_time = $post->time; - $this->last_user_id = $post->user_id; - $this->last_post_id = $post->id; + $this->last_time = $post->time; + $this->last_user_id = $post->user_id; + $this->last_post_id = $post->id; $this->last_post_number = $post->number; return $this; diff --git a/src/Core/DiscussionState.php b/src/Core/DiscussionState.php index fede5016a..25c630159 100644 --- a/src/Core/DiscussionState.php +++ b/src/Core/DiscussionState.php @@ -54,7 +54,7 @@ class DiscussionState extends AbstractModel { if ($number > $this->read_number) { $this->read_number = $number; - $this->read_time = time(); + $this->read_time = time(); $this->raise(new DiscussionWasRead($this)); } diff --git a/src/Core/Group.php b/src/Core/Group.php index f49cb6efb..8dfc51edf 100755 --- a/src/Core/Group.php +++ b/src/Core/Group.php @@ -81,9 +81,9 @@ class Group extends AbstractModel $group = new static; $group->name_singular = $nameSingular; - $group->name_plural = $namePlural; - $group->color = $color; - $group->icon = $icon; + $group->name_plural = $namePlural; + $group->color = $color; + $group->icon = $icon; $group->raise(new GroupWasCreated($group)); @@ -100,7 +100,7 @@ class Group extends AbstractModel public function rename($nameSingular, $namePlural) { $this->name_singular = $nameSingular; - $this->name_plural = $namePlural; + $this->name_plural = $namePlural; $this->raise(new GroupWasRenamed($this)); diff --git a/src/Core/Listener/DiscussionMetadataUpdater.php b/src/Core/Listener/DiscussionMetadataUpdater.php index 6591a126a..0b392fa0d 100755 --- a/src/Core/Listener/DiscussionMetadataUpdater.php +++ b/src/Core/Listener/DiscussionMetadataUpdater.php @@ -11,9 +11,9 @@ namespace Flarum\Core\Listener; use Flarum\Core\Post; -use Flarum\Event\PostWasPosted; use Flarum\Event\PostWasDeleted; use Flarum\Event\PostWasHidden; +use Flarum\Event\PostWasPosted; use Flarum\Event\PostWasRestored; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Core/Listener/DiscussionRenamedNotifier.php b/src/Core/Listener/DiscussionRenamedNotifier.php index 0c4b469a9..1cd0e3775 100755 --- a/src/Core/Listener/DiscussionRenamedNotifier.php +++ b/src/Core/Listener/DiscussionRenamedNotifier.php @@ -10,10 +10,10 @@ namespace Flarum\Core\Listener; -use Flarum\Event\DiscussionWasRenamed; -use Flarum\Core\Post\DiscussionRenamedPost; use Flarum\Core\Notification\DiscussionRenamedBlueprint; use Flarum\Core\Notification\NotificationSyncer; +use Flarum\Core\Post\DiscussionRenamedPost; +use Flarum\Event\DiscussionWasRenamed; use Illuminate\Contracts\Events\Dispatcher; class DiscussionRenamedNotifier diff --git a/src/Core/Listener/UserMetadataUpdater.php b/src/Core/Listener/UserMetadataUpdater.php index dc6d55e0f..06207e066 100755 --- a/src/Core/Listener/UserMetadataUpdater.php +++ b/src/Core/Listener/UserMetadataUpdater.php @@ -10,14 +10,14 @@ namespace Flarum\Core\Listener; -use Flarum\Core\Post; use Flarum\Core\Discussion; -use Flarum\Event\PostWasPosted; +use Flarum\Core\Post; +use Flarum\Event\DiscussionWasDeleted; +use Flarum\Event\DiscussionWasStarted; use Flarum\Event\PostWasDeleted; use Flarum\Event\PostWasHidden; +use Flarum\Event\PostWasPosted; use Flarum\Event\PostWasRestored; -use Flarum\Event\DiscussionWasStarted; -use Flarum\Event\DiscussionWasDeleted; use Illuminate\Contracts\Events\Dispatcher; class UserMetadataUpdater diff --git a/src/Core/Notification/NotificationServiceProvider.php b/src/Core/Notification/NotificationServiceProvider.php index 48976b0d4..644ff99ec 100644 --- a/src/Core/Notification/NotificationServiceProvider.php +++ b/src/Core/Notification/NotificationServiceProvider.php @@ -14,7 +14,6 @@ use Flarum\Core\Notification; use Flarum\Core\User; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Extend; use ReflectionClass; class NotificationServiceProvider extends AbstractServiceProvider diff --git a/src/Core/Notification/NotificationSyncer.php b/src/Core/Notification/NotificationSyncer.php index cb3551d86..8287b42ab 100644 --- a/src/Core/Notification/NotificationSyncer.php +++ b/src/Core/Notification/NotificationSyncer.php @@ -10,11 +10,11 @@ namespace Flarum\Core\Notification; +use Carbon\Carbon; use Flarum\Core\Notification; use Flarum\Core\Repository\NotificationRepository; -use Flarum\Event\NotificationWillBeSent; use Flarum\Core\User; -use Carbon\Carbon; +use Flarum\Event\NotificationWillBeSent; /** * The Notification Syncer commits notification blueprints to the database, and diff --git a/src/Core/Post.php b/src/Core/Post.php index ed2f53f1d..3a9af0665 100755 --- a/src/Core/Post.php +++ b/src/Core/Post.php @@ -10,12 +10,9 @@ namespace Flarum\Core; -use DomainException; use Flarum\Core\Post\RegisteredTypesScope; use Flarum\Core\Support\EventGeneratorTrait; -use Flarum\Core\Support\Locked; use Flarum\Core\Support\ScopeVisibilityTrait; -use Flarum\Core\Support\ValidateBeforeSaveTrait; use Flarum\Database\AbstractModel; use Flarum\Event\PostWasDeleted; use Illuminate\Database\Eloquent\Builder; @@ -99,7 +96,7 @@ class Post extends AbstractModel * Determine whether or not this post is visible to the given user. * * @param User $user - * @return boolean + * @return bool */ public function isVisibleTo(User $user) { diff --git a/src/Core/Post/CommentPost.php b/src/Core/Post/CommentPost.php index f6950af3c..8eb1c76e1 100755 --- a/src/Core/Post/CommentPost.php +++ b/src/Core/Post/CommentPost.php @@ -51,11 +51,11 @@ class CommentPost extends Post { $post = new static; - $post->time = time(); + $post->time = time(); $post->discussion_id = $discussionId; - $post->user_id = $userId; - $post->type = static::$type; - $post->ip_address = $ipAddress; + $post->user_id = $userId; + $post->type = static::$type; + $post->ip_address = $ipAddress; // Set content last, as the parsing may rely on other post attributes. $post->content = $content; diff --git a/src/Core/Post/DiscussionRenamedPost.php b/src/Core/Post/DiscussionRenamedPost.php index 765251b14..29cec3264 100755 --- a/src/Core/Post/DiscussionRenamedPost.php +++ b/src/Core/Post/DiscussionRenamedPost.php @@ -21,12 +21,12 @@ use Flarum\Core\Post; class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterface { /** - * @inheritdoc + * {@inheritdoc} */ public static $type = 'discussionRenamed'; /** - * @inheritdoc + * {@inheritdoc} */ public function saveAfter(Post $previous) { @@ -64,10 +64,10 @@ class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterf { $post = new static; - $post->content = static::buildContent($oldTitle, $newTitle); - $post->time = time(); + $post->content = static::buildContent($oldTitle, $newTitle); + $post->time = time(); $post->discussion_id = $discussionId; - $post->user_id = $userId; + $post->user_id = $userId; return $post; } diff --git a/src/Core/Repository/DiscussionRepository.php b/src/Core/Repository/DiscussionRepository.php index ee8b83c39..5e288dbf7 100644 --- a/src/Core/Repository/DiscussionRepository.php +++ b/src/Core/Repository/DiscussionRepository.php @@ -11,8 +11,8 @@ namespace Flarum\Core\Repository; use Flarum\Core\Discussion; -use Illuminate\Database\Eloquent\Builder; use Flarum\Core\User; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Query\Expression; class DiscussionRepository @@ -31,7 +31,7 @@ class DiscussionRepository * Find a discussion by ID, optionally making sure it is visible to a * certain user, or throw an exception. * - * @param integer $id + * @param int $id * @param User $user * @return \Flarum\Core\Discussion */ diff --git a/src/Core/Repository/PostRepository.php b/src/Core/Repository/PostRepository.php index 41e1a227c..ea106c477 100644 --- a/src/Core/Repository/PostRepository.php +++ b/src/Core/Repository/PostRepository.php @@ -10,11 +10,11 @@ namespace Flarum\Core\Repository; +use Flarum\Core\Discussion; use Flarum\Core\Post; +use Flarum\Core\User; use Flarum\Event\ScopePostVisibility; use Illuminate\Database\Eloquent\ModelNotFoundException; -use Flarum\Core\User; -use Flarum\Core\Discussion; class PostRepository { @@ -32,7 +32,7 @@ class PostRepository * Find a post by ID, optionally making sure it is visible to a certain * user, or throw an exception. * - * @param integer $id + * @param int $id * @param \Flarum\Core\User $actor * @return \Flarum\Core\Post * @@ -56,8 +56,8 @@ class PostRepository * @param array $where * @param \Flarum\Core\User|null $actor * @param array $sort - * @param integer $count - * @param integer $start + * @param int $count + * @param int $start * @return \Illuminate\Database\Eloquent\Collection */ public function findWhere(array $where = [], User $actor = null, $sort = [], $count = null, $start = 0) @@ -118,10 +118,10 @@ class PostRepository * is. If the post with that number does not exist, the index of the * closest post to it will be returned. * - * @param integer $discussionId - * @param integer $number + * @param int $discussionId + * @param int $number * @param \Flarum\Core\User|null $actor - * @return integer + * @return int */ public function getIndexForNumber($discussionId, $number, User $actor = null) { diff --git a/src/Core/Repository/UserRepository.php b/src/Core/Repository/UserRepository.php index afda68b52..9463b4baa 100644 --- a/src/Core/Repository/UserRepository.php +++ b/src/Core/Repository/UserRepository.php @@ -71,7 +71,7 @@ class UserRepository * * @param string $username * @param User|null $actor - * @return integer|null + * @return int|null */ public function getIdForUsername($username, User $actor = null) { diff --git a/src/Core/Search/AbstractRegexGambit.php b/src/Core/Search/AbstractRegexGambit.php index 57ea7870b..6d699c5af 100644 --- a/src/Core/Search/AbstractRegexGambit.php +++ b/src/Core/Search/AbstractRegexGambit.php @@ -27,10 +27,10 @@ abstract class AbstractRegexGambit implements GambitInterface if ($matches = $this->match($bit)) { list($negate) = array_splice($matches, 1, 1); - $this->conditions($search, $matches, !! $negate); + $this->conditions($search, $matches, (bool) $negate); } - return !! $matches; + return (bool) $matches; } /** diff --git a/src/Core/Search/Discussion/DiscussionSearcher.php b/src/Core/Search/Discussion/DiscussionSearcher.php index 65aedd103..cbb5b6585 100644 --- a/src/Core/Search/Discussion/DiscussionSearcher.php +++ b/src/Core/Search/Discussion/DiscussionSearcher.php @@ -11,13 +11,13 @@ namespace Flarum\Core\Search\Discussion; use Flarum\Core\Discussion; -use Flarum\Core\Search\ApplySearchParametersTrait; -use Flarum\Core\Search\SearchCriteria; -use Flarum\Core\Search\GambitManager; use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Repository\PostRepository; -use Flarum\Event\ConfigureDiscussionSearch; +use Flarum\Core\Search\ApplySearchParametersTrait; +use Flarum\Core\Search\GambitManager; +use Flarum\Core\Search\SearchCriteria; use Flarum\Core\Search\SearchResults; +use Flarum\Event\ConfigureDiscussionSearch; use Illuminate\Database\Eloquent\Collection; /** diff --git a/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/src/Core/Search/Discussion/Gambit/AuthorGambit.php index 830f033c1..e324af25a 100644 --- a/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/src/Core/Search/Discussion/Gambit/AuthorGambit.php @@ -10,10 +10,10 @@ namespace Flarum\Core\Search\Discussion\Gambit; -use Flarum\Core\Search\Discussion\DiscussionSearch; use Flarum\Core\Repository\UserRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; +use Flarum\Core\Search\Discussion\DiscussionSearch; use LogicException; class AuthorGambit extends AbstractRegexGambit diff --git a/src/Core/Search/Discussion/Gambit/FulltextGambit.php b/src/Core/Search/Discussion/Gambit/FulltextGambit.php index e28a03cd9..07b65d39c 100644 --- a/src/Core/Search/Discussion/Gambit/FulltextGambit.php +++ b/src/Core/Search/Discussion/Gambit/FulltextGambit.php @@ -10,9 +10,9 @@ namespace Flarum\Core\Search\Discussion\Gambit; +use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\Discussion\DiscussionSearch; use Flarum\Core\Search\Discussion\Fulltext\DriverInterface; -use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\GambitInterface; use LogicException; diff --git a/src/Core/Search/Discussion/Gambit/HiddenGambit.php b/src/Core/Search/Discussion/Gambit/HiddenGambit.php index 0078c6472..5624bc928 100644 --- a/src/Core/Search/Discussion/Gambit/HiddenGambit.php +++ b/src/Core/Search/Discussion/Gambit/HiddenGambit.php @@ -10,9 +10,9 @@ namespace Flarum\Core\Search\Discussion\Gambit; -use Flarum\Core\Search\Discussion\DiscussionSearch; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; +use Flarum\Core\Search\Discussion\DiscussionSearch; use LogicException; class HiddenGambit extends AbstractRegexGambit diff --git a/src/Core/Search/Discussion/Gambit/UnreadGambit.php b/src/Core/Search/Discussion/Gambit/UnreadGambit.php index 80fb51422..06050c14c 100644 --- a/src/Core/Search/Discussion/Gambit/UnreadGambit.php +++ b/src/Core/Search/Discussion/Gambit/UnreadGambit.php @@ -11,9 +11,9 @@ namespace Flarum\Core\Search\Discussion\Gambit; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Search\Discussion\DiscussionSearch; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; +use Flarum\Core\Search\Discussion\DiscussionSearch; use LogicException; class UnreadGambit extends AbstractRegexGambit diff --git a/src/Core/Search/GambitManager.php b/src/Core/Search/GambitManager.php index 357653f43..5ee89841a 100644 --- a/src/Core/Search/GambitManager.php +++ b/src/Core/Search/GambitManager.php @@ -105,8 +105,8 @@ class GambitManager foreach ($bits as $k => $bit) { foreach ($gambits as $gambit) { if (! $gambit instanceof GambitInterface) { - throw new LogicException('GambitInterface ' . get_class($gambit) - . ' does not implement ' . GambitInterface::class); + throw new LogicException('GambitInterface '.get_class($gambit) + .' does not implement '.GambitInterface::class); } if ($gambit->apply($search, $bit)) { diff --git a/src/Core/Search/User/Gambit/EmailGambit.php b/src/Core/Search/User/Gambit/EmailGambit.php index c6c406c05..8ef33ad53 100644 --- a/src/Core/Search/User/Gambit/EmailGambit.php +++ b/src/Core/Search/User/Gambit/EmailGambit.php @@ -10,10 +10,10 @@ namespace Flarum\Core\Search\User\Gambit; -use Flarum\Core\Search\User\UserSearch; use Flarum\Core\Repository\UserRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; +use Flarum\Core\Search\User\UserSearch; use LogicException; class EmailGambit extends AbstractRegexGambit diff --git a/src/Core/Search/User/UserSearcher.php b/src/Core/Search/User/UserSearcher.php index 307446265..513621813 100644 --- a/src/Core/Search/User/UserSearcher.php +++ b/src/Core/Search/User/UserSearcher.php @@ -10,11 +10,11 @@ namespace Flarum\Core\Search\User; +use Flarum\Core\Repository\UserRepository; use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\GambitManager; use Flarum\Core\Search\SearchCriteria; use Flarum\Core\Search\SearchResults; -use Flarum\Core\Repository\UserRepository; use Flarum\Event\ConfigureUserSearch; /** diff --git a/src/Core/Support/ScopeVisibilityTrait.php b/src/Core/Support/ScopeVisibilityTrait.php index 6b7659b3d..469c54efb 100644 --- a/src/Core/Support/ScopeVisibilityTrait.php +++ b/src/Core/Support/ScopeVisibilityTrait.php @@ -10,9 +10,9 @@ namespace Flarum\Core\Support; +use Flarum\Core\User; use Flarum\Event\ScopeModelVisibility; use Illuminate\Database\Eloquent\Builder; -use Flarum\Core\User; trait ScopeVisibilityTrait { diff --git a/src/Core/User.php b/src/Core/User.php index 2586f10c8..53f5e8013 100755 --- a/src/Core/User.php +++ b/src/Core/User.php @@ -11,9 +11,7 @@ namespace Flarum\Core; use DomainException; -use Flarum\Core; use Flarum\Core\Access\Gate; -use Flarum\Core\Notification; use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Core\Support\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; @@ -79,7 +77,7 @@ class User extends AbstractModel /** * An array of registered user preferences. Each preference is defined with - * a key, and its value is an array containing the following keys: + * a key, and its value is an array containing the following keys:. * * - transformer: a callback that confines the value of the preference * - default: a default value if the preference isn't set @@ -155,9 +153,9 @@ class User extends AbstractModel { $user = new static; - $user->username = $username; - $user->email = $email; - $user->password = $password; + $user->username = $username; + $user->email = $email; + $user->password = $password; $user->join_time = time(); $user->raise(new UserWasRegistered($user)); @@ -338,7 +336,7 @@ class User extends AbstractModel * Check if a given password matches the user's password. * * @param string $password - * @return boolean + * @return bool */ public function checkPassword($password) { @@ -365,7 +363,7 @@ class User extends AbstractModel * Check whether the user has a certain permission based on their groups. * * @param string $permission - * @return boolean + * @return bool */ public function hasPermission($permission) { @@ -385,7 +383,7 @@ class User extends AbstractModel * based on their groups. * * @param string $match - * @return boolean + * @return bool */ public function hasPermissionLike($match) { @@ -430,7 +428,7 @@ class User extends AbstractModel } /** - * Get all notifications that have not been read yet + * Get all notifications that have not been read yet. * * @return \Illuminate\Database\Eloquent\Collection */ diff --git a/src/Database/AbstractModel.php b/src/Database/AbstractModel.php index d38784490..1dc702500 100755 --- a/src/Database/AbstractModel.php +++ b/src/Database/AbstractModel.php @@ -28,7 +28,7 @@ abstract class AbstractModel extends Eloquent /** * Indicates if the model should be timestamped. Turn off by default. * - * @var boolean + * @var bool */ public $timestamps = false; @@ -107,7 +107,7 @@ abstract class AbstractModel extends Eloquent if (! $this->relationLoaded($key) && ($relation = $this->getCustomRelation($key))) { if (! $relation instanceof Relation) { throw new LogicException('Relationship method must return an object of type ' - . 'Illuminate\Database\Eloquent\Relations\Relation'); + .'Illuminate\Database\Eloquent\Relations\Relation'); } return $this->relations[$key] = $relation->getResults(); diff --git a/src/Database/DatabaseServiceProvider.php b/src/Database/DatabaseServiceProvider.php index 743012dd6..31d3238f8 100644 --- a/src/Database/DatabaseServiceProvider.php +++ b/src/Database/DatabaseServiceProvider.php @@ -10,7 +10,6 @@ namespace Flarum\Database; -use Flarum\Core; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Foundation\Application; use Illuminate\Database\ConnectionResolver; diff --git a/src/Database/Migrator.php b/src/Database/Migrator.php index 0377874e5..15477df4c 100755 --- a/src/Database/Migrator.php +++ b/src/Database/Migrator.php @@ -65,8 +65,8 @@ class Migrator Resolver $resolver, Filesystem $files ) { - $this->files = $files; - $this->resolver = $resolver; + $this->files = $files; + $this->resolver = $resolver; $this->repository = $repository; } @@ -213,7 +213,7 @@ class Migrator */ public function getMigrationFiles($path) { - $files = $this->files->glob($path . '/*_*.php'); + $files = $this->files->glob($path.'/*_*.php'); if ($files === false) { return []; @@ -287,7 +287,7 @@ class Migrator */ public function setConnection($name) { - if (!is_null($name)) { + if (! is_null($name)) { $this->resolver->setDefaultConnection($name); } diff --git a/src/Event/ConfigureNotificationTypes.php b/src/Event/ConfigureNotificationTypes.php index c33a354ad..d186721ac 100644 --- a/src/Event/ConfigureNotificationTypes.php +++ b/src/Event/ConfigureNotificationTypes.php @@ -44,8 +44,8 @@ class ConfigureNotificationTypes public function add($blueprint, $serializer, $enabledByDefault = []) { if (! (new ReflectionClass($blueprint))->implementsInterface(BlueprintInterface::class)) { - throw new InvalidArgumentException('Notification blueprint ' . $blueprint - . ' must implement '.BlueprintInterface::class); + throw new InvalidArgumentException('Notification blueprint '.$blueprint + .' must implement '.BlueprintInterface::class); } $this->blueprints[$blueprint] = $enabledByDefault; diff --git a/src/Event/PrepareUserGroups.php b/src/Event/PrepareUserGroups.php index 207f7a2c5..308171bf4 100644 --- a/src/Event/PrepareUserGroups.php +++ b/src/Event/PrepareUserGroups.php @@ -13,7 +13,7 @@ namespace Flarum\Event; use Flarum\Core\User; /** - * The `PrepareUserGroups` event + * The `PrepareUserGroups` event. */ class PrepareUserGroups { diff --git a/src/Event/ScopeHiddenDiscussionVisibility.php b/src/Event/ScopeHiddenDiscussionVisibility.php index 4a3c44ed0..0475bb08e 100644 --- a/src/Event/ScopeHiddenDiscussionVisibility.php +++ b/src/Event/ScopeHiddenDiscussionVisibility.php @@ -14,7 +14,7 @@ use Flarum\Core\User; use Illuminate\Database\Eloquent\Builder; /** - * The `ScopeHiddenDiscussionVisibility` event + * The `ScopeHiddenDiscussionVisibility` event. */ class ScopeHiddenDiscussionVisibility { diff --git a/src/Event/ScopePostVisibility.php b/src/Event/ScopePostVisibility.php index 2be853957..b59b24e1d 100644 --- a/src/Event/ScopePostVisibility.php +++ b/src/Event/ScopePostVisibility.php @@ -15,7 +15,7 @@ use Flarum\Core\User; use Illuminate\Database\Eloquent\Builder; /** - * The `ScopePostVisibility` event + * The `ScopePostVisibility` event. */ class ScopePostVisibility { diff --git a/src/Extension/Extension.php b/src/Extension/Extension.php index 0aac948a2..9f7f08ad4 100644 --- a/src/Extension/Extension.php +++ b/src/Extension/Extension.php @@ -86,7 +86,7 @@ class Extension implements Arrayable */ public function __construct($path, $composerJson) { - $this->path = $path; + $this->path = $path; $this->composerJson = $composerJson; $this->assignId(); } @@ -116,7 +116,6 @@ class Extension implements Arrayable return isset($this->{$name}) || $this->composerJsonAttribute(Str::snake($name, '-')); } - /** * Dot notation getter for composer.json attributes. * @@ -131,7 +130,7 @@ class Extension implements Arrayable } /** - * @param boolean $installed + * @param bool $installed * @return Extension */ public function setInstalled($installed) @@ -142,7 +141,7 @@ class Extension implements Arrayable } /** - * @return boolean + * @return bool */ public function isInstalled() { @@ -177,15 +176,15 @@ class Extension implements Arrayable { if (($icon = $this->composerJsonAttribute('extra.flarum-extension.icon'))) { if ($file = Arr::get($icon, 'image')) { - $file = $this->path . '/' . $file; + $file = $this->path.'/'.$file; if (file_exists($file)) { $mimetype = pathinfo($file, PATHINFO_EXTENSION) === 'svg' ? 'image/svg+xml' : finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file); - $data = file_get_contents($file); + $data = file_get_contents($file); - $icon['backgroundImage'] = 'url(\'data:' . $mimetype . ';base64,' . base64_encode($data) . '\')'; + $icon['backgroundImage'] = 'url(\'data:'.$mimetype.';base64,'.base64_encode($data).'\')'; } } @@ -194,7 +193,7 @@ class Extension implements Arrayable } /** - * @param boolean $enabled + * @param bool $enabled * @return Extension */ public function setEnabled($enabled) @@ -205,7 +204,7 @@ class Extension implements Arrayable } /** - * @return boolean + * @return bool */ public function isEnabled() { @@ -237,7 +236,7 @@ class Extension implements Arrayable */ public function hasAssets() { - return realpath($this->path . '/assets/') !== false; + return realpath($this->path.'/assets/') !== false; } /** @@ -247,7 +246,7 @@ class Extension implements Arrayable */ public function hasMigrations() { - return realpath($this->path . '/migrations/') !== false; + return realpath($this->path.'/migrations/') !== false; } /** diff --git a/src/Extension/ExtensionManager.php b/src/Extension/ExtensionManager.php index 33f20ff74..35b160c9a 100644 --- a/src/Extension/ExtensionManager.php +++ b/src/Extension/ExtensionManager.php @@ -10,7 +10,6 @@ namespace Flarum\Extension; -use Flarum\Core; use Flarum\Database\Migrator; use Flarum\Event\ExtensionWasDisabled; use Flarum\Event\ExtensionWasEnabled; @@ -19,7 +18,6 @@ use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Filesystem\Filesystem; -use Illuminate\Support\Arr; use Illuminate\Support\Collection; class ExtensionManager @@ -47,9 +45,9 @@ class ExtensionManager Dispatcher $dispatcher, Filesystem $filesystem ) { - $this->config = $config; - $this->app = $app; - $this->migrator = $migrator; + $this->config = $config; + $this->app = $app; + $this->migrator = $migrator; $this->dispatcher = $dispatcher; $this->filesystem = $filesystem; } @@ -61,15 +59,15 @@ class ExtensionManager { $extensionsDir = $this->getExtensionsDir(); - $dirs = array_diff(scandir($extensionsDir), ['.', '..']); + $dirs = array_diff(scandir($extensionsDir), ['.', '..']); $extensions = new Collection(); $installed = json_decode(file_get_contents(public_path('vendor/composer/installed.json')), true); foreach ($dirs as $dir) { - if (file_exists($manifest = $extensionsDir . '/' . $dir . '/composer.json')) { + if (file_exists($manifest = $extensionsDir.'/'.$dir.'/composer.json')) { $extension = new Extension( - $extensionsDir . '/' . $dir, + $extensionsDir.'/'.$dir, json_decode(file_get_contents($manifest), true) ); @@ -112,7 +110,7 @@ class ExtensionManager */ public function enable($name) { - if (!$this->isEnabled($name)) { + if (! $this->isEnabled($name)) { $extension = $this->getExtension($name); $enabled = $this->getEnabled(); @@ -182,8 +180,8 @@ class ExtensionManager { if ($extension->hasAssets()) { $this->filesystem->copyDirectory( - $extension->getPath() . '/assets', - $this->app->basePath() . '/assets/extensions/' . $extension->getId() + $extension->getPath().'/assets', + $this->app->basePath().'/assets/extensions/'.$extension->getId() ); } } @@ -195,7 +193,7 @@ class ExtensionManager */ protected function unpublishAssets(Extension $extension) { - $this->filesystem->deleteDirectory($this->app->basePath() . '/assets/extensions/' . $extension); + $this->filesystem->deleteDirectory($this->app->basePath().'/assets/extensions/'.$extension); } /** @@ -207,7 +205,7 @@ class ExtensionManager */ public function getAsset(Extension $extension, $path) { - return $this->app->basePath() . '/assets/extensions/' . $extension->getId() . $path; + return $this->app->basePath().'/assets/extensions/'.$extension->getId().$path; } /** @@ -219,7 +217,7 @@ class ExtensionManager public function migrate(Extension $extension, $up = true) { if ($extension->hasMigrations()) { - $migrationDir = $extension->getPath() . '/migrations'; + $migrationDir = $extension->getPath().'/migrations'; $this->app->bind('Illuminate\Database\Schema\Builder', function ($container) { return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder(); diff --git a/src/Formatter/Formatter.php b/src/Formatter/Formatter.php index 60122204f..a50f1820a 100644 --- a/src/Formatter/Formatter.php +++ b/src/Formatter/Formatter.php @@ -146,7 +146,7 @@ class Formatter */ protected function getComponent($name) { - $cacheKey = 'flarum.formatter.' . $name; + $cacheKey = 'flarum.formatter.'.$name; return $this->cache->rememberForever($cacheKey, function () use ($name) { return $this->getConfigurator()->finalize()[$name]; diff --git a/src/Forum/Controller/AbstractOAuth2Controller.php b/src/Forum/Controller/AbstractOAuth2Controller.php index 6ea3ddd73..95017ce86 100644 --- a/src/Forum/Controller/AbstractOAuth2Controller.php +++ b/src/Forum/Controller/AbstractOAuth2Controller.php @@ -14,7 +14,6 @@ use Flarum\Forum\AuthenticationResponseFactory; use Flarum\Http\Controller\ControllerInterface; use League\OAuth2\Client\Provider\ResourceOwnerInterface; use Psr\Http\Message\ServerRequestInterface as Request; -use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\RedirectResponse; abstract class AbstractOAuth2Controller implements ControllerInterface diff --git a/src/Forum/Controller/AuthorizedClientController.php b/src/Forum/Controller/AuthorizedClientController.php index 86dfe8b2d..0b81f7171 100644 --- a/src/Forum/Controller/AuthorizedClientController.php +++ b/src/Forum/Controller/AuthorizedClientController.php @@ -10,9 +10,8 @@ namespace Flarum\Forum\Controller; -use Flarum\Core\User; -use Psr\Http\Message\ServerRequestInterface as Request; use Flarum\Core\Exception\PermissionDeniedException; +use Psr\Http\Message\ServerRequestInterface as Request; class AuthorizedClientController extends ClientController { @@ -21,7 +20,7 @@ class AuthorizedClientController extends ClientController */ public function render(Request $request) { - if (!$request->getAttribute('session')->get('user_id')) { + if (! $request->getAttribute('session')->get('user_id')) { throw new PermissionDeniedException; } diff --git a/src/Forum/Controller/ClientController.php b/src/Forum/Controller/ClientController.php index feee0d573..9d7707080 100644 --- a/src/Forum/Controller/ClientController.php +++ b/src/Forum/Controller/ClientController.php @@ -13,9 +13,9 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Formatter\Formatter; use Flarum\Foundation\Application; +use Flarum\Http\Controller\AbstractClientController; use Flarum\Locale\LocaleManager; use Flarum\Settings\SettingsRepositoryInterface; -use Flarum\Http\Controller\AbstractClientController; use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Events\Dispatcher; @@ -55,7 +55,7 @@ class ClientController extends AbstractClientController } /** - * @inheritdoc + * {@inheritdoc} */ protected function getAssets() { diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index efeafa221..0454dc751 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -11,8 +11,8 @@ namespace Flarum\Forum\Controller; use Flarum\Core\User; -use Psr\Http\Message\ServerRequestInterface as Request; use Flarum\Http\Exception\RouteNotFoundException; +use Psr\Http\Message\ServerRequestInterface as Request; class DiscussionController extends ClientController { @@ -48,7 +48,7 @@ class DiscussionController extends ClientController $queryString = http_build_query($newQueryParams); return app('Flarum\Forum\UrlGenerator') - ->toRoute('discussion', ['id' => $document->data->id]) . + ->toRoute('discussion', ['id' => $document->data->id]). ($queryString ? '?'.$queryString : ''); }; diff --git a/src/Forum/Controller/LogInController.php b/src/Forum/Controller/LogInController.php index eebeb03b3..2aed09cda 100644 --- a/src/Forum/Controller/LogInController.php +++ b/src/Forum/Controller/LogInController.php @@ -12,9 +12,9 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Api\Controller\TokenController; -use Flarum\Http\AccessToken; -use Flarum\Event\UserLoggedIn; use Flarum\Core\Repository\UserRepository; +use Flarum\Event\UserLoggedIn; +use Flarum\Http\AccessToken; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; diff --git a/src/Forum/Controller/RegisterController.php b/src/Forum/Controller/RegisterController.php index dd240858a..5dd74f5c6 100644 --- a/src/Forum/Controller/RegisterController.php +++ b/src/Forum/Controller/RegisterController.php @@ -11,7 +11,6 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; -use Flarum\Http\AccessToken; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 61e661ff9..24a38902d 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -10,12 +10,12 @@ namespace Flarum\Forum\Controller; +use DateTime; +use Flarum\Core\Exception\InvalidConfirmationTokenException; use Flarum\Core\PasswordToken; use Flarum\Http\Controller\AbstractHtmlController; -use Flarum\Core\Exception\InvalidConfirmationTokenException; -use Psr\Http\Message\ServerRequestInterface as Request; use Illuminate\Contracts\View\Factory; -use DateTime; +use Psr\Http\Message\ServerRequestInterface as Request; class ResetPasswordController extends AbstractHtmlController { diff --git a/src/Forum/Controller/SavePasswordController.php b/src/Forum/Controller/SavePasswordController.php index 0ec531926..9ec31d4d2 100644 --- a/src/Forum/Controller/SavePasswordController.php +++ b/src/Forum/Controller/SavePasswordController.php @@ -11,7 +11,6 @@ namespace Flarum\Forum\Controller; use Flarum\Core\PasswordToken; -use Flarum\Core\Command\EditUser; use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; diff --git a/src/Foundation/AbstractServer.php b/src/Foundation/AbstractServer.php index fc75a4202..9feae039d 100644 --- a/src/Foundation/AbstractServer.php +++ b/src/Foundation/AbstractServer.php @@ -10,7 +10,6 @@ namespace Flarum\Foundation; -use Flarum\Core; use Illuminate\Config\Repository as ConfigRepository; use Monolog\Formatter\LineFormatter; use Monolog\Handler\StreamHandler; @@ -165,7 +164,7 @@ abstract class AbstractServer protected function registerLogger(Application $app) { $logger = new Logger($app->environment()); - $logPath = $app->storagePath() . '/logs/flarum.log'; + $logPath = $app->storagePath().'/logs/flarum.log'; $handler = new StreamHandler($logPath, Logger::DEBUG); $handler->setFormatter(new LineFormatter(null, null, true, true)); diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index a45b79186..b1d082666 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -163,7 +163,7 @@ class Application extends Container implements ApplicationContract } if ($path) { - $url .= '/' . array_get($config, "paths.$path", $path); + $url .= '/'.array_get($config, "paths.$path", $path); } return $url; diff --git a/src/Http/AbstractUrlGenerator.php b/src/Http/AbstractUrlGenerator.php index e1ededd54..ccd0d78ef 100644 --- a/src/Http/AbstractUrlGenerator.php +++ b/src/Http/AbstractUrlGenerator.php @@ -52,7 +52,7 @@ class AbstractUrlGenerator $path = $this->routes->getPath($name, $parameters); $path = ltrim($path, '/'); - return $this->toBase() . '/' . $path; + return $this->toBase().'/'.$path; } /** @@ -63,7 +63,7 @@ class AbstractUrlGenerator */ public function toPath($path) { - return $this->toBase() . '/' . $path; + return $this->toBase().'/'.$path; } /** diff --git a/src/Http/Controller/AbstractClientController.php b/src/Http/Controller/AbstractClientController.php index f3d8891ef..87d8e6a31 100644 --- a/src/Http/Controller/AbstractClientController.php +++ b/src/Http/Controller/AbstractClientController.php @@ -14,7 +14,6 @@ use Flarum\Api\Client; use Flarum\Asset\AssetManager; use Flarum\Asset\JsCompiler; use Flarum\Asset\LessCompiler; -use Flarum\Core; use Flarum\Event\ConfigureClientView; use Flarum\Foundation\Application; use Flarum\Locale\JsCompiler as LocaleJsCompiler; diff --git a/src/Http/Controller/AbstractHtmlController.php b/src/Http/Controller/AbstractHtmlController.php index 4a2a630d9..c5c722d73 100644 --- a/src/Http/Controller/AbstractHtmlController.php +++ b/src/Http/Controller/AbstractHtmlController.php @@ -10,7 +10,6 @@ namespace Flarum\Http\Controller; -use Flarum\Http\Controller\ControllerInterface; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response; diff --git a/src/Http/Controller/ClientView.php b/src/Http/Controller/ClientView.php index 97554de88..7b9875af5 100644 --- a/src/Http/Controller/ClientView.php +++ b/src/Http/Controller/ClientView.php @@ -13,9 +13,9 @@ namespace Flarum\Http\Controller; use Flarum\Api\Client; use Flarum\Asset\AssetManager; use Flarum\Core\User; +use Flarum\Locale\JsCompiler; use Illuminate\Contracts\Support\Renderable; use Psr\Http\Message\ServerRequestInterface as Request; -use Flarum\Locale\JsCompiler; /** * This class represents a view which boots up Flarum's client. @@ -255,7 +255,7 @@ class ClientView implements Renderable $noJs = array_get($this->request->getQueryParams(), 'nojs'); - $view->title = ($this->title ? $this->title . ' - ' : '') . $forum->data->attributes->title; + $view->title = ($this->title ? $this->title.' - ' : '').$forum->data->attributes->title; $view->forum = $forum->data; $view->layout = app('view')->file($this->layout, [ 'forum' => $forum->data, diff --git a/src/Http/GenerateRouteHandlerTrait.php b/src/Http/GenerateRouteHandlerTrait.php index c5a41e850..b8b901ee5 100644 --- a/src/Http/GenerateRouteHandlerTrait.php +++ b/src/Http/GenerateRouteHandlerTrait.php @@ -27,7 +27,7 @@ trait GenerateRouteHandlerTrait if (! ($controller instanceof ControllerInterface)) { throw new \InvalidArgumentException('Route handler must be an instance of ' - . ControllerInterface::class); + .ControllerInterface::class); } $request = $request->withQueryParams(array_merge($request->getQueryParams(), $routeParams)); diff --git a/src/Http/Middleware/AuthenticateWithHeader.php b/src/Http/Middleware/AuthenticateWithHeader.php index 0518133c9..3ebf46471 100644 --- a/src/Http/Middleware/AuthenticateWithHeader.php +++ b/src/Http/Middleware/AuthenticateWithHeader.php @@ -10,7 +10,6 @@ namespace Flarum\Http\Middleware; -use DateTime; use Flarum\Api\ApiKey; use Flarum\Core\User; use Flarum\Http\AccessToken; diff --git a/src/Http/Middleware/DispatchRoute.php b/src/Http/Middleware/DispatchRoute.php index f8f8d55e4..78055e5ef 100644 --- a/src/Http/Middleware/DispatchRoute.php +++ b/src/Http/Middleware/DispatchRoute.php @@ -12,7 +12,6 @@ namespace Flarum\Http\Middleware; use FastRoute\Dispatcher; -use FastRoute\RouteParser; use Flarum\Http\Exception\MethodNotAllowedException; use Flarum\Http\Exception\RouteNotFoundException; use Flarum\Http\RouteCollection; diff --git a/src/Http/Middleware/HandleErrors.php b/src/Http/Middleware/HandleErrors.php index 3e85b189f..a30018dee 100644 --- a/src/Http/Middleware/HandleErrors.php +++ b/src/Http/Middleware/HandleErrors.php @@ -10,11 +10,11 @@ namespace Flarum\Http\Middleware; +use Franzl\Middleware\Whoops\ErrorMiddleware as WhoopsMiddleware; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\HtmlResponse; use Zend\Stratigility\ErrorMiddlewareInterface; -use Franzl\Middleware\Whoops\ErrorMiddleware as WhoopsMiddleware; class HandleErrors implements ErrorMiddlewareInterface { diff --git a/src/Http/RouteCollection.php b/src/Http/RouteCollection.php index d4818ca7f..1659ae561 100644 --- a/src/Http/RouteCollection.php +++ b/src/Http/RouteCollection.php @@ -92,7 +92,7 @@ class RouteCollection $parts = $this->reverse[$name][0]; array_walk($parts, [$this, 'fixPathPart'], $parameters); - return '/' . ltrim(implode('', $parts), '/'); + return '/'.ltrim(implode('', $parts), '/'); } throw new \RuntimeException("Route $name not found"); diff --git a/src/Install/Console/FileDataProvider.php b/src/Install/Console/FileDataProvider.php index f92e8489a..fa349e68a 100644 --- a/src/Install/Console/FileDataProvider.php +++ b/src/Install/Console/FileDataProvider.php @@ -10,9 +10,9 @@ namespace Flarum\Install\Console; +use Exception; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Yaml\Yaml; -use Exception; class FileDataProvider implements DataProviderInterface { @@ -39,7 +39,7 @@ class FileDataProvider implements DataProviderInterface $this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null; $this->databaseConfiguration = isset($configuration['databaseConfiguration']) ? $configuration['databaseConfiguration'] : []; $this->adminUser = isset($configuration['adminUser']) ? $configuration['adminUser'] : []; - $this->settings = isset($configuration['settings']) ? $configuration['settings']: []; + $this->settings = isset($configuration['settings']) ? $configuration['settings'] : []; } else { throw new Exception('Configuration file does not exist.'); } @@ -52,7 +52,7 @@ class FileDataProvider implements DataProviderInterface public function getBaseUrl() { - return (!is_null($this->baseUrl)) ? $this->baseUrl : $this->default->getBaseUrl(); + return (! is_null($this->baseUrl)) ? $this->baseUrl : $this->default->getBaseUrl(); } public function getAdminUser() diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index e67d192c8..ff107b488 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -10,21 +10,17 @@ namespace Flarum\Install\Console; +use Exception; use Flarum\Console\Command\AbstractCommand; -use Flarum\Database\AbstractModel; -use Flarum\Core\User; use Flarum\Core\Group; use Flarum\Core\Permission; +use Flarum\Core\User; +use Flarum\Database\AbstractModel; use Illuminate\Contracts\Foundation\Application; use Illuminate\Filesystem\Filesystem; -use Illuminate\Support\Arr; use Illuminate\Validation\Factory; use PDO; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; -use Exception; class InstallCommand extends AbstractCommand { @@ -77,7 +73,7 @@ class InstallCommand extends AbstractCommand } /** - * @inheritdoc + * {@inheritdoc} */ protected function fire() { @@ -238,7 +234,7 @@ class InstallCommand extends AbstractCommand $migrator = $this->application->make('Flarum\Database\Migrator'); $migrator->getRepository()->createRepository(); - $migrator->run(__DIR__ . '/../../../migrations'); + $migrator->run(__DIR__.'/../../../migrations'); foreach ($migrator->getNotes() as $note) { $this->info($note); @@ -393,7 +389,7 @@ class InstallCommand extends AbstractCommand $this->info($error['message']); if (isset($error['detail'])) { - $this->output->writeln('' . $error['detail'] . ''); + $this->output->writeln(''.$error['detail'].''); } } } diff --git a/src/Install/Console/UserDataProvider.php b/src/Install/Console/UserDataProvider.php index 62436106d..cef548615 100644 --- a/src/Install/Console/UserDataProvider.php +++ b/src/Install/Console/UserDataProvider.php @@ -10,7 +10,6 @@ namespace Flarum\Install\Console; -use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -26,7 +25,6 @@ class UserDataProvider implements DataProviderInterface protected $baseUrl; - public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper) { $this->input = $input; @@ -77,13 +75,13 @@ class UserDataProvider implements DataProviderInterface 'forum_title' => $title, 'forum_description' => '', 'mail_driver' => 'mail', - 'mail_from' => 'noreply@' . preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)), + 'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)), 'theme_colored_header' => '0', 'theme_dark_mode' => '0', 'theme_primary_color' => '#4D698E', 'theme_secondary_color' => '#4D698E', 'welcome_message' => 'This is beta software and you should not use it in production.', - 'welcome_title' => 'Welcome to ' . $title, + 'welcome_title' => 'Welcome to '.$title, ]; } diff --git a/src/Install/Controller/IndexController.php b/src/Install/Controller/IndexController.php index 2aaed34a7..41c0a8835 100644 --- a/src/Install/Controller/IndexController.php +++ b/src/Install/Controller/IndexController.php @@ -10,10 +10,10 @@ namespace Flarum\Install\Controller; -use Flarum\Install\Prerequisite\PrerequisiteInterface; use Flarum\Http\Controller\AbstractHtmlController; -use Psr\Http\Message\ServerRequestInterface as Request; +use Flarum\Install\Prerequisite\PrerequisiteInterface; use Illuminate\Contracts\View\Factory; +use Psr\Http\Message\ServerRequestInterface as Request; class IndexController extends AbstractHtmlController { diff --git a/src/Install/Controller/InstallController.php b/src/Install/Controller/InstallController.php index b9c7b13a7..da2b12b69 100644 --- a/src/Install/Controller/InstallController.php +++ b/src/Install/Controller/InstallController.php @@ -10,19 +10,16 @@ namespace Flarum\Install\Controller; -use Flarum\Core\User; -use Flarum\Http\Controller\ControllerInterface; -use Flarum\Http\AccessToken; -use Flarum\Http\SessionAuthenticator; -use Psr\Http\Message\ServerRequestInterface as Request; -use Zend\Diactoros\Response\HtmlResponse; -use Zend\Diactoros\Response; -use Flarum\Install\Console\InstallCommand; -use Flarum\Install\Console\DefaultsDataProvider; -use Symfony\Component\Console\Output\StreamOutput; -use Symfony\Component\Console\Input\StringInput; use Exception; -use DateTime; +use Flarum\Http\Controller\ControllerInterface; +use Flarum\Http\SessionAuthenticator; +use Flarum\Install\Console\DefaultsDataProvider; +use Flarum\Install\Console\InstallCommand; +use Psr\Http\Message\ServerRequestInterface as Request; +use Symfony\Component\Console\Input\StringInput; +use Symfony\Component\Console\Output\StreamOutput; +use Zend\Diactoros\Response; +use Zend\Diactoros\Response\HtmlResponse; class InstallController implements ControllerInterface { @@ -74,8 +71,8 @@ class InstallController implements ControllerInterface $data->setBaseUrl($baseUrl); $data->setSetting('forum_title', array_get($input, 'forumTitle')); - $data->setSetting('mail_from', 'noreply@' . preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST))); - $data->setSetting('welcome_title', 'Welcome to ' . array_get($input, 'forumTitle')); + $data->setSetting('mail_from', 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST))); + $data->setSetting('welcome_title', 'Welcome to '.array_get($input, 'forumTitle')); $body = fopen('php://temp', 'wb+'); $input = new StringInput(''); diff --git a/src/Locale/JsCompiler.php b/src/Locale/JsCompiler.php index 6cac02c79..8800c0546 100644 --- a/src/Locale/JsCompiler.php +++ b/src/Locale/JsCompiler.php @@ -32,9 +32,9 @@ class JsCompiler extends BaseJsCompiler $output .= file_get_contents($filename); } - $output .= "} + $output .= '} }; -});"; +});'; return $this->format($output); } diff --git a/src/Locale/Translator.php b/src/Locale/Translator.php index fe78a7085..2231e707c 100644 --- a/src/Locale/Translator.php +++ b/src/Locale/Translator.php @@ -28,7 +28,7 @@ class Translator extends BaseTranslator $this->assertValidLocale($locale); } - $parse = !isset($this->catalogues[$locale]); + $parse = ! isset($this->catalogues[$locale]); $catalogue = parent::getCatalogue($locale); diff --git a/src/Settings/MemoryCacheSettingsRepository.php b/src/Settings/MemoryCacheSettingsRepository.php index 4caf6d937..60ca133f5 100644 --- a/src/Settings/MemoryCacheSettingsRepository.php +++ b/src/Settings/MemoryCacheSettingsRepository.php @@ -26,7 +26,7 @@ class MemoryCacheSettingsRepository implements SettingsRepositoryInterface public function all() { - if (!$this->isCached) { + if (! $this->isCached) { $this->cache = $this->inner->all(); $this->isCached = true; } @@ -38,7 +38,7 @@ class MemoryCacheSettingsRepository implements SettingsRepositoryInterface { if (array_key_exists($key, $this->cache)) { return $this->cache[$key]; - } elseif (!$this->isCached) { + } elseif (! $this->isCached) { return array_get($this->all(), $key, $default); } diff --git a/src/Update/Console/MigrateCommand.php b/src/Update/Console/MigrateCommand.php index 72d5e813e..9baf8e8d9 100644 --- a/src/Update/Console/MigrateCommand.php +++ b/src/Update/Console/MigrateCommand.php @@ -12,10 +12,6 @@ namespace Flarum\Update\Console; use Flarum\Console\Command\AbstractCommand; use Illuminate\Contracts\Container\Container; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; class MigrateCommand extends AbstractCommand { @@ -41,7 +37,7 @@ class MigrateCommand extends AbstractCommand { $this ->setName('migrate') - ->setDescription("Run outstanding migrations."); + ->setDescription('Run outstanding migrations.'); } /** diff --git a/src/Update/Controller/IndexController.php b/src/Update/Controller/IndexController.php index d6760ae06..407a1e5c2 100644 --- a/src/Update/Controller/IndexController.php +++ b/src/Update/Controller/IndexController.php @@ -11,8 +11,8 @@ namespace Flarum\Update\Controller; use Flarum\Http\Controller\AbstractHtmlController; -use Psr\Http\Message\ServerRequestInterface as Request; use Illuminate\Contracts\View\Factory; +use Psr\Http\Message\ServerRequestInterface as Request; class IndexController extends AbstractHtmlController { diff --git a/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php b/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php index 74e0b3dbd..60acc8719 100644 --- a/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php +++ b/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php @@ -1,4 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Tests\Flarum\Core\Settings; use Flarum\Settings\DatabaseSettingsRepository; @@ -16,17 +26,17 @@ class DatabaseSettingsRepositoryTest extends TestCase $this->connection = m::mock(ConnectionInterface::class); $this->repository = new DatabaseSettingsRepository($this->connection); } - + public function test_requesting_an_existing_setting_should_return_its_value() { - $this->connection->shouldReceive("table->where->value")->andReturn('value'); + $this->connection->shouldReceive('table->where->value')->andReturn('value'); $this->assertEquals('value', $this->repository->get('key')); } public function test_non_existent_setting_values_should_return_null() { - $this->connection->shouldReceive("table->where->value")->andReturn(null); + $this->connection->shouldReceive('table->where->value')->andReturn(null); $this->assertEquals('default', $this->repository->get('key', 'default')); } diff --git a/tests/Flarum/Core/Settings/MemoryCacheSettingsRepositoryTest.php b/tests/Flarum/Core/Settings/MemoryCacheSettingsRepositoryTest.php index 0cd8ca7d6..4ae7fd7a1 100644 --- a/tests/Flarum/Core/Settings/MemoryCacheSettingsRepositoryTest.php +++ b/tests/Flarum/Core/Settings/MemoryCacheSettingsRepositoryTest.php @@ -1,4 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Tests\Flarum\Core\Settings; use Flarum\Settings\MemoryCacheSettingsRepository; @@ -16,7 +26,7 @@ class MemoryCacheSettingsRepositoryTest extends TestCase $this->baseRepository = m::mock(SettingsRepositoryInterface::class); $this->repository = new MemoryCacheSettingsRepository($this->baseRepository); } - + public function test_it_should_return_all_settings_when_not_cached() { $this->baseRepository->shouldReceive('all')->once()->andReturn(['key' => 'value']); @@ -32,7 +42,7 @@ class MemoryCacheSettingsRepositoryTest extends TestCase $this->assertEquals('value2', $this->repository->get('key2')); $this->assertEquals('value2', $this->repository->get('key2')); // Assert twice to ensure we hit the cache } - + public function test_it_should_set_a_key_value_pair() { $this->baseRepository->shouldReceive('set')->once(); diff --git a/tests/Test/TestCase.php b/tests/Test/TestCase.php index 17bbc4a57..c00350868 100644 --- a/tests/Test/TestCase.php +++ b/tests/Test/TestCase.php @@ -1,4 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Tests\Test; use Mockery; diff --git a/views/install/app.php b/views/install/app.php index c3403a4bb..2e8601022 100644 --- a/views/install/app.php +++ b/views/install/app.php @@ -162,7 +162,7 @@

- +