Merge pull request #831 from flarum/analysis-qvQMPx

Applied fixes from StyleCI
This commit is contained in:
Toby Zerner 2016-02-26 13:40:39 +10:30
commit 0ccfad3931
96 changed files with 240 additions and 245 deletions

View File

@ -8,7 +8,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder; use Illuminate\Database\Schema\Builder;

View File

@ -8,7 +8,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder; use Illuminate\Database\Schema\Builder;

View File

@ -10,17 +10,17 @@
namespace Flarum\Admin\Controller; 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\Foundation\Application;
use Flarum\Http\Controller\AbstractClientController as BaseClientController; use Flarum\Http\Controller\AbstractClientController as BaseClientController;
use Flarum\Extension\ExtensionManager;
use Flarum\Locale\LocaleManager; use Flarum\Locale\LocaleManager;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Psr\Http\Message\ServerRequestInterface as Request; 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 class ClientController extends BaseClientController
{ {

View File

@ -13,12 +13,10 @@ namespace Flarum\Admin\Middleware;
use Exception; use Exception;
use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Forum\Controller\LogInController; use Flarum\Forum\Controller\LogInController;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\HtmlResponse;
use Zend\Diactoros\Response\RedirectResponse;
use Zend\Stratigility\MiddlewareInterface; use Zend\Stratigility\MiddlewareInterface;
class RequireAdministrateAbility implements MiddlewareInterface class RequireAdministrateAbility implements MiddlewareInterface

View File

@ -28,7 +28,7 @@ class Server extends AbstractServer
if ($app->isInstalled()) { if ($app->isInstalled()) {
$path = parse_url($app->url('admin'), PHP_URL_PATH); $path = parse_url($app->url('admin'), PHP_URL_PATH);
$errorDir = __DIR__ . '/../../error'; $errorDir = __DIR__.'/../../error';
if ($app->isUpToDate()) { if ($app->isUpToDate()) {
$pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody')); $pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody'));

View File

@ -60,7 +60,7 @@ class Client
if (! ($controller instanceof ControllerInterface)) { if (! ($controller instanceof ControllerInterface)) {
throw new InvalidArgumentException('Endpoint must be an instance of ' throw new InvalidArgumentException('Endpoint must be an instance of '
. ControllerInterface::class); .ControllerInterface::class);
} }
try { try {

View File

@ -87,7 +87,7 @@ class ListPostsController extends AbstractCollectionController
if (($near = array_get($queryParams, 'page.near')) > 1) { if (($near = array_get($queryParams, 'page.near')) > 1) {
if (count($filter) > 1 || ! isset($filter['discussion']) || $sort) { if (count($filter) > 1 || ! isset($filter['discussion']) || $sort) {
throw new InvalidParameterException('You can only use page[near] with ' 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); $offset = $this->posts->getIndexForNumber($filter['discussion'], $near, $actor);

View File

@ -25,12 +25,12 @@ class ShowDiscussionController extends AbstractResourceController
protected $discussions; protected $discussions;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer'; public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer';
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public $include = [ public $include = [
'posts', 'posts',
@ -42,7 +42,7 @@ class ShowDiscussionController extends AbstractResourceController
]; ];
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public $optionalInclude = [ public $optionalInclude = [
'startUser', 'startUser',

View File

@ -68,9 +68,9 @@ class TokenController implements ControllerInterface
$token = AccessToken::generate($user->id, $lifetime); $token = AccessToken::generate($user->id, $lifetime);
$token->save(); $token->save();
return (new JsonResponse([ return new JsonResponse([
'token' => $token->id, 'token' => $token->id,
'userId' => $user->id 'userId' => $user->id
])); ]);
} }
} }

View File

@ -12,8 +12,6 @@ namespace Flarum\Api\Serializer;
use Closure; use Closure;
use DateTime; use DateTime;
use Flarum\Api\Relationship\HasManyBuilder;
use Flarum\Api\Relationship\HasOneBuilder;
use Flarum\Core\User; use Flarum\Core\User;
use Flarum\Event\GetApiRelationship; use Flarum\Event\GetApiRelationship;
use Flarum\Event\PrepareApiAttributes; use Flarum\Event\PrepareApiAttributes;
@ -24,7 +22,6 @@ use LogicException;
use Tobscure\JsonApi\AbstractSerializer as BaseAbstractSerializer; use Tobscure\JsonApi\AbstractSerializer as BaseAbstractSerializer;
use Tobscure\JsonApi\Collection; use Tobscure\JsonApi\Collection;
use Tobscure\JsonApi\Relationship; use Tobscure\JsonApi\Relationship;
use Tobscure\JsonApi\Relationship\BuilderInterface;
use Tobscure\JsonApi\Resource; use Tobscure\JsonApi\Resource;
use Tobscure\JsonApi\SerializerInterface; use Tobscure\JsonApi\SerializerInterface;
@ -125,7 +122,7 @@ abstract class AbstractSerializer extends BaseAbstractSerializer
if ($relationship && ! ($relationship instanceof Relationship)) { if ($relationship && ! ($relationship instanceof Relationship)) {
throw new LogicException('GetApiRelationship handler must return an instance of ' throw new LogicException('GetApiRelationship handler must return an instance of '
. Relationship::class); .Relationship::class);
} }
return $relationship; return $relationship;

View File

@ -30,7 +30,7 @@ class DiscussionBasicSerializer extends AbstractSerializer
{ {
if (! ($discussion instanceof Discussion)) { if (! ($discussion instanceof Discussion)) {
throw new InvalidArgumentException(get_class($this) throw new InvalidArgumentException(get_class($this)
. ' can only serialize instances of ' . Discussion::class); .' can only serialize instances of '.Discussion::class);
} }
return [ return [

View File

@ -44,7 +44,7 @@ class GroupSerializer extends AbstractSerializer
{ {
if (! ($group instanceof Group)) { if (! ($group instanceof Group)) {
throw new InvalidArgumentException(get_class($this) throw new InvalidArgumentException(get_class($this)
. ' can only serialize instances of ' . Group::class); .' can only serialize instances of '.Group::class);
} }
return [ return [

View File

@ -38,7 +38,7 @@ class NotificationSerializer extends AbstractSerializer
{ {
if (! ($notification instanceof Notification)) { if (! ($notification instanceof Notification)) {
throw new InvalidArgumentException(get_class($this) throw new InvalidArgumentException(get_class($this)
. ' can only serialize instances of ' . Notification::class); .' can only serialize instances of '.Notification::class);
} }
return [ return [

View File

@ -31,7 +31,7 @@ class PostBasicSerializer extends AbstractSerializer
{ {
if (! ($post instanceof Post)) { if (! ($post instanceof Post)) {
throw new InvalidArgumentException(get_class($this) throw new InvalidArgumentException(get_class($this)
. ' can only serialize instances of ' . Post::class); .' can only serialize instances of '.Post::class);
} }
$attributes = [ $attributes = [

View File

@ -30,7 +30,7 @@ class UserBasicSerializer extends AbstractSerializer
{ {
if (! ($user instanceof User)) { if (! ($user instanceof User)) {
throw new InvalidArgumentException(get_class($this) throw new InvalidArgumentException(get_class($this)
. ' can only serialize instances of ' . User::class); .' can only serialize instances of '.User::class);
} }
return [ return [

View File

@ -39,8 +39,8 @@ class AssetManager
*/ */
public function setFilename($filename) public function setFilename($filename)
{ {
$this->js->setFilename($filename . '.js'); $this->js->setFilename($filename.'.js');
$this->less->setFilename($filename . '.css'); $this->less->setFilename($filename.'.css');
} }
/** /**
@ -61,7 +61,7 @@ class AssetManager
break; break;
default: default:
throw new DomainException('Unsupported asset type: ' . $ext); throw new DomainException('Unsupported asset type: '.$ext);
} }
} }

View File

@ -53,7 +53,7 @@ class JsCompiler extends RevisionCompiler
} }
/** /**
* @inheritDoc * {@inheritdoc}
*/ */
protected function getCacheDifferentiator() protected function getCacheDifferentiator()
{ {

View File

@ -104,7 +104,7 @@ class RevisionCompiler implements CompilerInterface
*/ */
protected function getCacheDifferentiator() protected function getCacheDifferentiator()
{ {
return null; return;
} }
/** /**
@ -189,7 +189,7 @@ class RevisionCompiler implements CompilerInterface
$ext = pathinfo($this->filename, PATHINFO_EXTENSION); $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)) { if (file_exists($file)) {
unlink($file); unlink($file);

View File

@ -10,10 +10,8 @@
namespace Flarum\Console\Command; 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 Flarum\Foundation\Application;
use Symfony\Component\Console\Question\Question;
class GenerateExtensionCommand extends AbstractCommand class GenerateExtensionCommand extends AbstractCommand
{ {
@ -21,7 +19,7 @@ class GenerateExtensionCommand extends AbstractCommand
{ {
$this $this
->setName('generate:extension') ->setName('generate:extension')
->setDescription("Generate a Flarum extension skeleton."); ->setDescription('Generate a Flarum extension skeleton.');
} }
/** /**

View File

@ -10,10 +10,9 @@
namespace Flarum\Console\Command; 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 Flarum\Database\MigrationCreator;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class GenerateMigrationCommand extends AbstractCommand class GenerateMigrationCommand extends AbstractCommand
{ {
@ -39,7 +38,7 @@ class GenerateMigrationCommand extends AbstractCommand
{ {
$this $this
->setName('generate:migration') ->setName('generate:migration')
->setDescription("Generate a migration.") ->setDescription('Generate a migration.')
->addArgument( ->addArgument(
'name', 'name',
InputArgument::REQUIRED, InputArgument::REQUIRED,

View File

@ -1,5 +1,14 @@
<?php <?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Core\Access; namespace Flarum\Core\Access;
use Illuminate\Contracts\Auth\Access\Gate as GateContract; use Illuminate\Contracts\Auth\Access\Gate as GateContract;

View File

@ -45,7 +45,7 @@ class PostPolicy extends AbstractPolicy
} }
/** /**
* @inheritDoc * {@inheritdoc}
*/ */
public function subscribe(Dispatcher $events) public function subscribe(Dispatcher $events)
{ {

View File

@ -17,7 +17,7 @@ class EditDiscussion
/** /**
* The ID of the discussion to edit. * The ID of the discussion to edit.
* *
* @var integer * @var int
*/ */
public $discussionId; public $discussionId;
@ -36,7 +36,7 @@ class EditDiscussion
public $data; 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 \Flarum\Core\User $actor The user performing the action.
* @param array $data The attributes to update on the discussion. * @param array $data The attributes to update on the discussion.
*/ */

View File

@ -11,7 +11,6 @@
namespace Flarum\Core\Command; namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Notification;
use Flarum\Core\Repository\NotificationRepository; use Flarum\Core\Repository\NotificationRepository;
class ReadAllNotificationsHandler class ReadAllNotificationsHandler

View File

@ -17,7 +17,7 @@ class ReadDiscussion
/** /**
* The ID of the discussion to mark as read. * The ID of the discussion to mark as read.
* *
* @var integer * @var int
*/ */
public $discussionId; public $discussionId;
@ -31,14 +31,14 @@ class ReadDiscussion
/** /**
* The number of the post to mark as read. * The number of the post to mark as read.
* *
* @var integer * @var int
*/ */
public $readNumber; 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 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) public function __construct($discussionId, User $actor, $readNumber)
{ {

View File

@ -170,10 +170,10 @@ class RegisterUserHandler
'target' => $this->uploadDir, 'target' => $this->uploadDir,
]); ]);
$uploadName = Str::lower(Str::quickRandom()) . '.jpg'; $uploadName = Str::lower(Str::quickRandom()).'.jpg';
$user->changeAvatarPath($uploadName); $user->changeAvatarPath($uploadName);
$mount->move("source://".pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName"); $mount->move('source://'.pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName");
} }
} }

View File

@ -10,14 +10,14 @@
namespace Flarum\Core\Command; namespace Flarum\Core\Command;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Core;
use Flarum\Core\PasswordToken; use Flarum\Core\PasswordToken;
use Flarum\Core\Repository\UserRepository; 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\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; use Symfony\Component\Translation\TranslatorInterface;
class RequestPasswordResetHandler class RequestPasswordResetHandler

View File

@ -111,11 +111,11 @@ class UploadAvatarHandler
$mount->delete($file); $mount->delete($file);
} }
$uploadName = Str::lower(Str::quickRandom()) . '.jpg'; $uploadName = Str::lower(Str::quickRandom()).'.jpg';
$user->changeAvatarPath($uploadName); $user->changeAvatarPath($uploadName);
$mount->move("source://".pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName"); $mount->move('source://'.pathinfo($tmpFile, PATHINFO_BASENAME), "target://$uploadName");
$user->save(); $user->save();

View File

@ -10,7 +10,6 @@
namespace Flarum\Core; namespace Flarum\Core;
use Flarum\Core\Post;
use Flarum\Core\Post\MergeableInterface; use Flarum\Core\Post\MergeableInterface;
use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Core\Support\EventGeneratorTrait;
use Flarum\Core\Support\ScopeVisibilityTrait; use Flarum\Core\Support\ScopeVisibilityTrait;
@ -119,8 +118,8 @@ class Discussion extends AbstractModel
{ {
$discussion = new static; $discussion = new static;
$discussion->title = $title; $discussion->title = $title;
$discussion->start_time = time(); $discussion->start_time = time();
$discussion->start_user_id = $user->id; $discussion->start_user_id = $user->id;
$discussion->setRelation('startUser', $user); $discussion->setRelation('startUser', $user);
@ -191,7 +190,7 @@ class Discussion extends AbstractModel
*/ */
public function setStartPost(Post $post) public function setStartPost(Post $post)
{ {
$this->start_time = $post->time; $this->start_time = $post->time;
$this->start_user_id = $post->user_id; $this->start_user_id = $post->user_id;
$this->start_post_id = $post->id; $this->start_post_id = $post->id;
@ -206,9 +205,9 @@ class Discussion extends AbstractModel
*/ */
public function setLastPost(Post $post) public function setLastPost(Post $post)
{ {
$this->last_time = $post->time; $this->last_time = $post->time;
$this->last_user_id = $post->user_id; $this->last_user_id = $post->user_id;
$this->last_post_id = $post->id; $this->last_post_id = $post->id;
$this->last_post_number = $post->number; $this->last_post_number = $post->number;
return $this; return $this;

View File

@ -54,7 +54,7 @@ class DiscussionState extends AbstractModel
{ {
if ($number > $this->read_number) { if ($number > $this->read_number) {
$this->read_number = $number; $this->read_number = $number;
$this->read_time = time(); $this->read_time = time();
$this->raise(new DiscussionWasRead($this)); $this->raise(new DiscussionWasRead($this));
} }

View File

@ -81,9 +81,9 @@ class Group extends AbstractModel
$group = new static; $group = new static;
$group->name_singular = $nameSingular; $group->name_singular = $nameSingular;
$group->name_plural = $namePlural; $group->name_plural = $namePlural;
$group->color = $color; $group->color = $color;
$group->icon = $icon; $group->icon = $icon;
$group->raise(new GroupWasCreated($group)); $group->raise(new GroupWasCreated($group));
@ -100,7 +100,7 @@ class Group extends AbstractModel
public function rename($nameSingular, $namePlural) public function rename($nameSingular, $namePlural)
{ {
$this->name_singular = $nameSingular; $this->name_singular = $nameSingular;
$this->name_plural = $namePlural; $this->name_plural = $namePlural;
$this->raise(new GroupWasRenamed($this)); $this->raise(new GroupWasRenamed($this));

View File

@ -11,9 +11,9 @@
namespace Flarum\Core\Listener; namespace Flarum\Core\Listener;
use Flarum\Core\Post; use Flarum\Core\Post;
use Flarum\Event\PostWasPosted;
use Flarum\Event\PostWasDeleted; use Flarum\Event\PostWasDeleted;
use Flarum\Event\PostWasHidden; use Flarum\Event\PostWasHidden;
use Flarum\Event\PostWasPosted;
use Flarum\Event\PostWasRestored; use Flarum\Event\PostWasRestored;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;

View File

@ -10,10 +10,10 @@
namespace Flarum\Core\Listener; namespace Flarum\Core\Listener;
use Flarum\Event\DiscussionWasRenamed;
use Flarum\Core\Post\DiscussionRenamedPost;
use Flarum\Core\Notification\DiscussionRenamedBlueprint; use Flarum\Core\Notification\DiscussionRenamedBlueprint;
use Flarum\Core\Notification\NotificationSyncer; use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Core\Post\DiscussionRenamedPost;
use Flarum\Event\DiscussionWasRenamed;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class DiscussionRenamedNotifier class DiscussionRenamedNotifier

View File

@ -10,14 +10,14 @@
namespace Flarum\Core\Listener; namespace Flarum\Core\Listener;
use Flarum\Core\Post;
use Flarum\Core\Discussion; 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\PostWasDeleted;
use Flarum\Event\PostWasHidden; use Flarum\Event\PostWasHidden;
use Flarum\Event\PostWasPosted;
use Flarum\Event\PostWasRestored; use Flarum\Event\PostWasRestored;
use Flarum\Event\DiscussionWasStarted;
use Flarum\Event\DiscussionWasDeleted;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class UserMetadataUpdater class UserMetadataUpdater

View File

@ -14,7 +14,6 @@ use Flarum\Core\Notification;
use Flarum\Core\User; use Flarum\Core\User;
use Flarum\Event\ConfigureNotificationTypes; use Flarum\Event\ConfigureNotificationTypes;
use Flarum\Foundation\AbstractServiceProvider; use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Extend;
use ReflectionClass; use ReflectionClass;
class NotificationServiceProvider extends AbstractServiceProvider class NotificationServiceProvider extends AbstractServiceProvider

View File

@ -10,11 +10,11 @@
namespace Flarum\Core\Notification; namespace Flarum\Core\Notification;
use Carbon\Carbon;
use Flarum\Core\Notification; use Flarum\Core\Notification;
use Flarum\Core\Repository\NotificationRepository; use Flarum\Core\Repository\NotificationRepository;
use Flarum\Event\NotificationWillBeSent;
use Flarum\Core\User; use Flarum\Core\User;
use Carbon\Carbon; use Flarum\Event\NotificationWillBeSent;
/** /**
* The Notification Syncer commits notification blueprints to the database, and * The Notification Syncer commits notification blueprints to the database, and

View File

@ -10,12 +10,9 @@
namespace Flarum\Core; namespace Flarum\Core;
use DomainException;
use Flarum\Core\Post\RegisteredTypesScope; use Flarum\Core\Post\RegisteredTypesScope;
use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Core\Support\EventGeneratorTrait;
use Flarum\Core\Support\Locked;
use Flarum\Core\Support\ScopeVisibilityTrait; use Flarum\Core\Support\ScopeVisibilityTrait;
use Flarum\Core\Support\ValidateBeforeSaveTrait;
use Flarum\Database\AbstractModel; use Flarum\Database\AbstractModel;
use Flarum\Event\PostWasDeleted; use Flarum\Event\PostWasDeleted;
use Illuminate\Database\Eloquent\Builder; 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. * Determine whether or not this post is visible to the given user.
* *
* @param User $user * @param User $user
* @return boolean * @return bool
*/ */
public function isVisibleTo(User $user) public function isVisibleTo(User $user)
{ {

View File

@ -51,11 +51,11 @@ class CommentPost extends Post
{ {
$post = new static; $post = new static;
$post->time = time(); $post->time = time();
$post->discussion_id = $discussionId; $post->discussion_id = $discussionId;
$post->user_id = $userId; $post->user_id = $userId;
$post->type = static::$type; $post->type = static::$type;
$post->ip_address = $ipAddress; $post->ip_address = $ipAddress;
// Set content last, as the parsing may rely on other post attributes. // Set content last, as the parsing may rely on other post attributes.
$post->content = $content; $post->content = $content;

View File

@ -21,12 +21,12 @@ use Flarum\Core\Post;
class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterface class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static $type = 'discussionRenamed'; public static $type = 'discussionRenamed';
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function saveAfter(Post $previous) public function saveAfter(Post $previous)
{ {
@ -64,10 +64,10 @@ class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterf
{ {
$post = new static; $post = new static;
$post->content = static::buildContent($oldTitle, $newTitle); $post->content = static::buildContent($oldTitle, $newTitle);
$post->time = time(); $post->time = time();
$post->discussion_id = $discussionId; $post->discussion_id = $discussionId;
$post->user_id = $userId; $post->user_id = $userId;
return $post; return $post;
} }

View File

@ -11,8 +11,8 @@
namespace Flarum\Core\Repository; namespace Flarum\Core\Repository;
use Flarum\Core\Discussion; use Flarum\Core\Discussion;
use Illuminate\Database\Eloquent\Builder;
use Flarum\Core\User; use Flarum\Core\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\Expression;
class DiscussionRepository class DiscussionRepository
@ -31,7 +31,7 @@ class DiscussionRepository
* Find a discussion by ID, optionally making sure it is visible to a * Find a discussion by ID, optionally making sure it is visible to a
* certain user, or throw an exception. * certain user, or throw an exception.
* *
* @param integer $id * @param int $id
* @param User $user * @param User $user
* @return \Flarum\Core\Discussion * @return \Flarum\Core\Discussion
*/ */

View File

@ -10,11 +10,11 @@
namespace Flarum\Core\Repository; namespace Flarum\Core\Repository;
use Flarum\Core\Discussion;
use Flarum\Core\Post; use Flarum\Core\Post;
use Flarum\Core\User;
use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePostVisibility;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Flarum\Core\User;
use Flarum\Core\Discussion;
class PostRepository class PostRepository
{ {
@ -32,7 +32,7 @@ class PostRepository
* Find a post by ID, optionally making sure it is visible to a certain * Find a post by ID, optionally making sure it is visible to a certain
* user, or throw an exception. * user, or throw an exception.
* *
* @param integer $id * @param int $id
* @param \Flarum\Core\User $actor * @param \Flarum\Core\User $actor
* @return \Flarum\Core\Post * @return \Flarum\Core\Post
* *
@ -56,8 +56,8 @@ class PostRepository
* @param array $where * @param array $where
* @param \Flarum\Core\User|null $actor * @param \Flarum\Core\User|null $actor
* @param array $sort * @param array $sort
* @param integer $count * @param int $count
* @param integer $start * @param int $start
* @return \Illuminate\Database\Eloquent\Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
public function findWhere(array $where = [], User $actor = null, $sort = [], $count = null, $start = 0) 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 * is. If the post with that number does not exist, the index of the
* closest post to it will be returned. * closest post to it will be returned.
* *
* @param integer $discussionId * @param int $discussionId
* @param integer $number * @param int $number
* @param \Flarum\Core\User|null $actor * @param \Flarum\Core\User|null $actor
* @return integer * @return int
*/ */
public function getIndexForNumber($discussionId, $number, User $actor = null) public function getIndexForNumber($discussionId, $number, User $actor = null)
{ {

View File

@ -71,7 +71,7 @@ class UserRepository
* *
* @param string $username * @param string $username
* @param User|null $actor * @param User|null $actor
* @return integer|null * @return int|null
*/ */
public function getIdForUsername($username, User $actor = null) public function getIdForUsername($username, User $actor = null)
{ {

View File

@ -27,10 +27,10 @@ abstract class AbstractRegexGambit implements GambitInterface
if ($matches = $this->match($bit)) { if ($matches = $this->match($bit)) {
list($negate) = array_splice($matches, 1, 1); list($negate) = array_splice($matches, 1, 1);
$this->conditions($search, $matches, !! $negate); $this->conditions($search, $matches, (bool) $negate);
} }
return !! $matches; return (bool) $matches;
} }
/** /**

View File

@ -11,13 +11,13 @@
namespace Flarum\Core\Search\Discussion; namespace Flarum\Core\Search\Discussion;
use Flarum\Core\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\DiscussionRepository;
use Flarum\Core\Repository\PostRepository; 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\Core\Search\SearchResults;
use Flarum\Event\ConfigureDiscussionSearch;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
/** /**

View File

@ -10,10 +10,10 @@
namespace Flarum\Core\Search\Discussion\Gambit; namespace Flarum\Core\Search\Discussion\Gambit;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Core\Repository\UserRepository; use Flarum\Core\Repository\UserRepository;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use LogicException; use LogicException;
class AuthorGambit extends AbstractRegexGambit class AuthorGambit extends AbstractRegexGambit

View File

@ -10,9 +10,9 @@
namespace Flarum\Core\Search\Discussion\Gambit; namespace Flarum\Core\Search\Discussion\Gambit;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch; use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Core\Search\Discussion\Fulltext\DriverInterface; use Flarum\Core\Search\Discussion\Fulltext\DriverInterface;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\GambitInterface; use Flarum\Core\Search\GambitInterface;
use LogicException; use LogicException;

View File

@ -10,9 +10,9 @@
namespace Flarum\Core\Search\Discussion\Gambit; namespace Flarum\Core\Search\Discussion\Gambit;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use LogicException; use LogicException;
class HiddenGambit extends AbstractRegexGambit class HiddenGambit extends AbstractRegexGambit

View File

@ -11,9 +11,9 @@
namespace Flarum\Core\Search\Discussion\Gambit; namespace Flarum\Core\Search\Discussion\Gambit;
use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use LogicException; use LogicException;
class UnreadGambit extends AbstractRegexGambit class UnreadGambit extends AbstractRegexGambit

View File

@ -105,8 +105,8 @@ class GambitManager
foreach ($bits as $k => $bit) { foreach ($bits as $k => $bit) {
foreach ($gambits as $gambit) { foreach ($gambits as $gambit) {
if (! $gambit instanceof GambitInterface) { if (! $gambit instanceof GambitInterface) {
throw new LogicException('GambitInterface ' . get_class($gambit) throw new LogicException('GambitInterface '.get_class($gambit)
. ' does not implement ' . GambitInterface::class); .' does not implement '.GambitInterface::class);
} }
if ($gambit->apply($search, $bit)) { if ($gambit->apply($search, $bit)) {

View File

@ -10,10 +10,10 @@
namespace Flarum\Core\Search\User\Gambit; namespace Flarum\Core\Search\User\Gambit;
use Flarum\Core\Search\User\UserSearch;
use Flarum\Core\Repository\UserRepository; use Flarum\Core\Repository\UserRepository;
use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\User\UserSearch;
use LogicException; use LogicException;
class EmailGambit extends AbstractRegexGambit class EmailGambit extends AbstractRegexGambit

View File

@ -10,11 +10,11 @@
namespace Flarum\Core\Search\User; namespace Flarum\Core\Search\User;
use Flarum\Core\Repository\UserRepository;
use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\ApplySearchParametersTrait;
use Flarum\Core\Search\GambitManager; use Flarum\Core\Search\GambitManager;
use Flarum\Core\Search\SearchCriteria; use Flarum\Core\Search\SearchCriteria;
use Flarum\Core\Search\SearchResults; use Flarum\Core\Search\SearchResults;
use Flarum\Core\Repository\UserRepository;
use Flarum\Event\ConfigureUserSearch; use Flarum\Event\ConfigureUserSearch;
/** /**

View File

@ -10,9 +10,9 @@
namespace Flarum\Core\Support; namespace Flarum\Core\Support;
use Flarum\Core\User;
use Flarum\Event\ScopeModelVisibility; use Flarum\Event\ScopeModelVisibility;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Flarum\Core\User;
trait ScopeVisibilityTrait trait ScopeVisibilityTrait
{ {

View File

@ -11,9 +11,7 @@
namespace Flarum\Core; namespace Flarum\Core;
use DomainException; use DomainException;
use Flarum\Core;
use Flarum\Core\Access\Gate; use Flarum\Core\Access\Gate;
use Flarum\Core\Notification;
use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Core\Support\EventGeneratorTrait;
use Flarum\Core\Support\ScopeVisibilityTrait; use Flarum\Core\Support\ScopeVisibilityTrait;
use Flarum\Database\AbstractModel; use Flarum\Database\AbstractModel;
@ -79,7 +77,7 @@ class User extends AbstractModel
/** /**
* An array of registered user preferences. Each preference is defined with * 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 * - transformer: a callback that confines the value of the preference
* - default: a default value if the preference isn't set * - default: a default value if the preference isn't set
@ -155,9 +153,9 @@ class User extends AbstractModel
{ {
$user = new static; $user = new static;
$user->username = $username; $user->username = $username;
$user->email = $email; $user->email = $email;
$user->password = $password; $user->password = $password;
$user->join_time = time(); $user->join_time = time();
$user->raise(new UserWasRegistered($user)); $user->raise(new UserWasRegistered($user));
@ -338,7 +336,7 @@ class User extends AbstractModel
* Check if a given password matches the user's password. * Check if a given password matches the user's password.
* *
* @param string $password * @param string $password
* @return boolean * @return bool
*/ */
public function checkPassword($password) public function checkPassword($password)
{ {
@ -365,7 +363,7 @@ class User extends AbstractModel
* Check whether the user has a certain permission based on their groups. * Check whether the user has a certain permission based on their groups.
* *
* @param string $permission * @param string $permission
* @return boolean * @return bool
*/ */
public function hasPermission($permission) public function hasPermission($permission)
{ {
@ -385,7 +383,7 @@ class User extends AbstractModel
* based on their groups. * based on their groups.
* *
* @param string $match * @param string $match
* @return boolean * @return bool
*/ */
public function hasPermissionLike($match) 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 * @return \Illuminate\Database\Eloquent\Collection
*/ */

View File

@ -28,7 +28,7 @@ abstract class AbstractModel extends Eloquent
/** /**
* Indicates if the model should be timestamped. Turn off by default. * Indicates if the model should be timestamped. Turn off by default.
* *
* @var boolean * @var bool
*/ */
public $timestamps = false; public $timestamps = false;
@ -107,7 +107,7 @@ abstract class AbstractModel extends Eloquent
if (! $this->relationLoaded($key) && ($relation = $this->getCustomRelation($key))) { if (! $this->relationLoaded($key) && ($relation = $this->getCustomRelation($key))) {
if (! $relation instanceof Relation) { if (! $relation instanceof Relation) {
throw new LogicException('Relationship method must return an object of type ' 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(); return $this->relations[$key] = $relation->getResults();

View File

@ -10,7 +10,6 @@
namespace Flarum\Database; namespace Flarum\Database;
use Flarum\Core;
use Flarum\Foundation\AbstractServiceProvider; use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Foundation\Application; use Flarum\Foundation\Application;
use Illuminate\Database\ConnectionResolver; use Illuminate\Database\ConnectionResolver;

View File

@ -65,8 +65,8 @@ class Migrator
Resolver $resolver, Resolver $resolver,
Filesystem $files Filesystem $files
) { ) {
$this->files = $files; $this->files = $files;
$this->resolver = $resolver; $this->resolver = $resolver;
$this->repository = $repository; $this->repository = $repository;
} }
@ -213,7 +213,7 @@ class Migrator
*/ */
public function getMigrationFiles($path) public function getMigrationFiles($path)
{ {
$files = $this->files->glob($path . '/*_*.php'); $files = $this->files->glob($path.'/*_*.php');
if ($files === false) { if ($files === false) {
return []; return [];
@ -287,7 +287,7 @@ class Migrator
*/ */
public function setConnection($name) public function setConnection($name)
{ {
if (!is_null($name)) { if (! is_null($name)) {
$this->resolver->setDefaultConnection($name); $this->resolver->setDefaultConnection($name);
} }

View File

@ -44,8 +44,8 @@ class ConfigureNotificationTypes
public function add($blueprint, $serializer, $enabledByDefault = []) public function add($blueprint, $serializer, $enabledByDefault = [])
{ {
if (! (new ReflectionClass($blueprint))->implementsInterface(BlueprintInterface::class)) { if (! (new ReflectionClass($blueprint))->implementsInterface(BlueprintInterface::class)) {
throw new InvalidArgumentException('Notification blueprint ' . $blueprint throw new InvalidArgumentException('Notification blueprint '.$blueprint
. ' must implement '.BlueprintInterface::class); .' must implement '.BlueprintInterface::class);
} }
$this->blueprints[$blueprint] = $enabledByDefault; $this->blueprints[$blueprint] = $enabledByDefault;

View File

@ -13,7 +13,7 @@ namespace Flarum\Event;
use Flarum\Core\User; use Flarum\Core\User;
/** /**
* The `PrepareUserGroups` event * The `PrepareUserGroups` event.
*/ */
class PrepareUserGroups class PrepareUserGroups
{ {

View File

@ -14,7 +14,7 @@ use Flarum\Core\User;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
/** /**
* The `ScopeHiddenDiscussionVisibility` event * The `ScopeHiddenDiscussionVisibility` event.
*/ */
class ScopeHiddenDiscussionVisibility class ScopeHiddenDiscussionVisibility
{ {

View File

@ -15,7 +15,7 @@ use Flarum\Core\User;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
/** /**
* The `ScopePostVisibility` event * The `ScopePostVisibility` event.
*/ */
class ScopePostVisibility class ScopePostVisibility
{ {

View File

@ -86,7 +86,7 @@ class Extension implements Arrayable
*/ */
public function __construct($path, $composerJson) public function __construct($path, $composerJson)
{ {
$this->path = $path; $this->path = $path;
$this->composerJson = $composerJson; $this->composerJson = $composerJson;
$this->assignId(); $this->assignId();
} }
@ -116,7 +116,6 @@ class Extension implements Arrayable
return isset($this->{$name}) || $this->composerJsonAttribute(Str::snake($name, '-')); return isset($this->{$name}) || $this->composerJsonAttribute(Str::snake($name, '-'));
} }
/** /**
* Dot notation getter for composer.json attributes. * Dot notation getter for composer.json attributes.
* *
@ -131,7 +130,7 @@ class Extension implements Arrayable
} }
/** /**
* @param boolean $installed * @param bool $installed
* @return Extension * @return Extension
*/ */
public function setInstalled($installed) public function setInstalled($installed)
@ -142,7 +141,7 @@ class Extension implements Arrayable
} }
/** /**
* @return boolean * @return bool
*/ */
public function isInstalled() public function isInstalled()
{ {
@ -177,15 +176,15 @@ class Extension implements Arrayable
{ {
if (($icon = $this->composerJsonAttribute('extra.flarum-extension.icon'))) { if (($icon = $this->composerJsonAttribute('extra.flarum-extension.icon'))) {
if ($file = Arr::get($icon, 'image')) { if ($file = Arr::get($icon, 'image')) {
$file = $this->path . '/' . $file; $file = $this->path.'/'.$file;
if (file_exists($file)) { if (file_exists($file)) {
$mimetype = pathinfo($file, PATHINFO_EXTENSION) === 'svg' $mimetype = pathinfo($file, PATHINFO_EXTENSION) === 'svg'
? 'image/svg+xml' ? 'image/svg+xml'
: finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file); : 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 * @return Extension
*/ */
public function setEnabled($enabled) public function setEnabled($enabled)
@ -205,7 +204,7 @@ class Extension implements Arrayable
} }
/** /**
* @return boolean * @return bool
*/ */
public function isEnabled() public function isEnabled()
{ {
@ -237,7 +236,7 @@ class Extension implements Arrayable
*/ */
public function hasAssets() 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() public function hasMigrations()
{ {
return realpath($this->path . '/migrations/') !== false; return realpath($this->path.'/migrations/') !== false;
} }
/** /**

View File

@ -10,7 +10,6 @@
namespace Flarum\Extension; namespace Flarum\Extension;
use Flarum\Core;
use Flarum\Database\Migrator; use Flarum\Database\Migrator;
use Flarum\Event\ExtensionWasDisabled; use Flarum\Event\ExtensionWasDisabled;
use Flarum\Event\ExtensionWasEnabled; use Flarum\Event\ExtensionWasEnabled;
@ -19,7 +18,6 @@ use Flarum\Foundation\Application;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
class ExtensionManager class ExtensionManager
@ -47,9 +45,9 @@ class ExtensionManager
Dispatcher $dispatcher, Dispatcher $dispatcher,
Filesystem $filesystem Filesystem $filesystem
) { ) {
$this->config = $config; $this->config = $config;
$this->app = $app; $this->app = $app;
$this->migrator = $migrator; $this->migrator = $migrator;
$this->dispatcher = $dispatcher; $this->dispatcher = $dispatcher;
$this->filesystem = $filesystem; $this->filesystem = $filesystem;
} }
@ -61,15 +59,15 @@ class ExtensionManager
{ {
$extensionsDir = $this->getExtensionsDir(); $extensionsDir = $this->getExtensionsDir();
$dirs = array_diff(scandir($extensionsDir), ['.', '..']); $dirs = array_diff(scandir($extensionsDir), ['.', '..']);
$extensions = new Collection(); $extensions = new Collection();
$installed = json_decode(file_get_contents(public_path('vendor/composer/installed.json')), true); $installed = json_decode(file_get_contents(public_path('vendor/composer/installed.json')), true);
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
if (file_exists($manifest = $extensionsDir . '/' . $dir . '/composer.json')) { if (file_exists($manifest = $extensionsDir.'/'.$dir.'/composer.json')) {
$extension = new Extension( $extension = new Extension(
$extensionsDir . '/' . $dir, $extensionsDir.'/'.$dir,
json_decode(file_get_contents($manifest), true) json_decode(file_get_contents($manifest), true)
); );
@ -112,7 +110,7 @@ class ExtensionManager
*/ */
public function enable($name) public function enable($name)
{ {
if (!$this->isEnabled($name)) { if (! $this->isEnabled($name)) {
$extension = $this->getExtension($name); $extension = $this->getExtension($name);
$enabled = $this->getEnabled(); $enabled = $this->getEnabled();
@ -182,8 +180,8 @@ class ExtensionManager
{ {
if ($extension->hasAssets()) { if ($extension->hasAssets()) {
$this->filesystem->copyDirectory( $this->filesystem->copyDirectory(
$extension->getPath() . '/assets', $extension->getPath().'/assets',
$this->app->basePath() . '/assets/extensions/' . $extension->getId() $this->app->basePath().'/assets/extensions/'.$extension->getId()
); );
} }
} }
@ -195,7 +193,7 @@ class ExtensionManager
*/ */
protected function unpublishAssets(Extension $extension) 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) 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) public function migrate(Extension $extension, $up = true)
{ {
if ($extension->hasMigrations()) { if ($extension->hasMigrations()) {
$migrationDir = $extension->getPath() . '/migrations'; $migrationDir = $extension->getPath().'/migrations';
$this->app->bind('Illuminate\Database\Schema\Builder', function ($container) { $this->app->bind('Illuminate\Database\Schema\Builder', function ($container) {
return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder(); return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder();

View File

@ -146,7 +146,7 @@ class Formatter
*/ */
protected function getComponent($name) protected function getComponent($name)
{ {
$cacheKey = 'flarum.formatter.' . $name; $cacheKey = 'flarum.formatter.'.$name;
return $this->cache->rememberForever($cacheKey, function () use ($name) { return $this->cache->rememberForever($cacheKey, function () use ($name) {
return $this->getConfigurator()->finalize()[$name]; return $this->getConfigurator()->finalize()[$name];

View File

@ -14,7 +14,6 @@ use Flarum\Forum\AuthenticationResponseFactory;
use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Controller\ControllerInterface;
use League\OAuth2\Client\Provider\ResourceOwnerInterface; use League\OAuth2\Client\Provider\ResourceOwnerInterface;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response\HtmlResponse;
use Zend\Diactoros\Response\RedirectResponse; use Zend\Diactoros\Response\RedirectResponse;
abstract class AbstractOAuth2Controller implements ControllerInterface abstract class AbstractOAuth2Controller implements ControllerInterface

View File

@ -10,9 +10,8 @@
namespace Flarum\Forum\Controller; namespace Flarum\Forum\Controller;
use Flarum\Core\User;
use Psr\Http\Message\ServerRequestInterface as Request;
use Flarum\Core\Exception\PermissionDeniedException; use Flarum\Core\Exception\PermissionDeniedException;
use Psr\Http\Message\ServerRequestInterface as Request;
class AuthorizedClientController extends ClientController class AuthorizedClientController extends ClientController
{ {
@ -21,7 +20,7 @@ class AuthorizedClientController extends ClientController
*/ */
public function render(Request $request) public function render(Request $request)
{ {
if (!$request->getAttribute('session')->get('user_id')) { if (! $request->getAttribute('session')->get('user_id')) {
throw new PermissionDeniedException; throw new PermissionDeniedException;
} }

View File

@ -13,9 +13,9 @@ namespace Flarum\Forum\Controller;
use Flarum\Api\Client; use Flarum\Api\Client;
use Flarum\Formatter\Formatter; use Flarum\Formatter\Formatter;
use Flarum\Foundation\Application; use Flarum\Foundation\Application;
use Flarum\Http\Controller\AbstractClientController;
use Flarum\Locale\LocaleManager; use Flarum\Locale\LocaleManager;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Http\Controller\AbstractClientController;
use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
@ -55,7 +55,7 @@ class ClientController extends AbstractClientController
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getAssets() protected function getAssets()
{ {

View File

@ -11,8 +11,8 @@
namespace Flarum\Forum\Controller; namespace Flarum\Forum\Controller;
use Flarum\Core\User; use Flarum\Core\User;
use Psr\Http\Message\ServerRequestInterface as Request;
use Flarum\Http\Exception\RouteNotFoundException; use Flarum\Http\Exception\RouteNotFoundException;
use Psr\Http\Message\ServerRequestInterface as Request;
class DiscussionController extends ClientController class DiscussionController extends ClientController
{ {
@ -48,7 +48,7 @@ class DiscussionController extends ClientController
$queryString = http_build_query($newQueryParams); $queryString = http_build_query($newQueryParams);
return app('Flarum\Forum\UrlGenerator') return app('Flarum\Forum\UrlGenerator')
->toRoute('discussion', ['id' => $document->data->id]) . ->toRoute('discussion', ['id' => $document->data->id]).
($queryString ? '?'.$queryString : ''); ($queryString ? '?'.$queryString : '');
}; };

View File

@ -12,9 +12,9 @@ namespace Flarum\Forum\Controller;
use Flarum\Api\Client; use Flarum\Api\Client;
use Flarum\Api\Controller\TokenController; use Flarum\Api\Controller\TokenController;
use Flarum\Http\AccessToken;
use Flarum\Event\UserLoggedIn;
use Flarum\Core\Repository\UserRepository; use Flarum\Core\Repository\UserRepository;
use Flarum\Event\UserLoggedIn;
use Flarum\Http\AccessToken;
use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Controller\ControllerInterface;
use Flarum\Http\Rememberer; use Flarum\Http\Rememberer;
use Flarum\Http\SessionAuthenticator; use Flarum\Http\SessionAuthenticator;

View File

@ -11,7 +11,6 @@
namespace Flarum\Forum\Controller; namespace Flarum\Forum\Controller;
use Flarum\Api\Client; use Flarum\Api\Client;
use Flarum\Http\AccessToken;
use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Controller\ControllerInterface;
use Flarum\Http\Rememberer; use Flarum\Http\Rememberer;
use Flarum\Http\SessionAuthenticator; use Flarum\Http\SessionAuthenticator;

View File

@ -10,12 +10,12 @@
namespace Flarum\Forum\Controller; namespace Flarum\Forum\Controller;
use DateTime;
use Flarum\Core\Exception\InvalidConfirmationTokenException;
use Flarum\Core\PasswordToken; use Flarum\Core\PasswordToken;
use Flarum\Http\Controller\AbstractHtmlController; use Flarum\Http\Controller\AbstractHtmlController;
use Flarum\Core\Exception\InvalidConfirmationTokenException;
use Psr\Http\Message\ServerRequestInterface as Request;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use DateTime; use Psr\Http\Message\ServerRequestInterface as Request;
class ResetPasswordController extends AbstractHtmlController class ResetPasswordController extends AbstractHtmlController
{ {

View File

@ -11,7 +11,6 @@
namespace Flarum\Forum\Controller; namespace Flarum\Forum\Controller;
use Flarum\Core\PasswordToken; use Flarum\Core\PasswordToken;
use Flarum\Core\Command\EditUser;
use Flarum\Forum\UrlGenerator; use Flarum\Forum\UrlGenerator;
use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Controller\ControllerInterface;
use Flarum\Http\SessionAuthenticator; use Flarum\Http\SessionAuthenticator;

View File

@ -10,7 +10,6 @@
namespace Flarum\Foundation; namespace Flarum\Foundation;
use Flarum\Core;
use Illuminate\Config\Repository as ConfigRepository; use Illuminate\Config\Repository as ConfigRepository;
use Monolog\Formatter\LineFormatter; use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
@ -165,7 +164,7 @@ abstract class AbstractServer
protected function registerLogger(Application $app) protected function registerLogger(Application $app)
{ {
$logger = new Logger($app->environment()); $logger = new Logger($app->environment());
$logPath = $app->storagePath() . '/logs/flarum.log'; $logPath = $app->storagePath().'/logs/flarum.log';
$handler = new StreamHandler($logPath, Logger::DEBUG); $handler = new StreamHandler($logPath, Logger::DEBUG);
$handler->setFormatter(new LineFormatter(null, null, true, true)); $handler->setFormatter(new LineFormatter(null, null, true, true));

View File

@ -163,7 +163,7 @@ class Application extends Container implements ApplicationContract
} }
if ($path) { if ($path) {
$url .= '/' . array_get($config, "paths.$path", $path); $url .= '/'.array_get($config, "paths.$path", $path);
} }
return $url; return $url;

View File

@ -52,7 +52,7 @@ class AbstractUrlGenerator
$path = $this->routes->getPath($name, $parameters); $path = $this->routes->getPath($name, $parameters);
$path = ltrim($path, '/'); $path = ltrim($path, '/');
return $this->toBase() . '/' . $path; return $this->toBase().'/'.$path;
} }
/** /**
@ -63,7 +63,7 @@ class AbstractUrlGenerator
*/ */
public function toPath($path) public function toPath($path)
{ {
return $this->toBase() . '/' . $path; return $this->toBase().'/'.$path;
} }
/** /**

View File

@ -14,7 +14,6 @@ use Flarum\Api\Client;
use Flarum\Asset\AssetManager; use Flarum\Asset\AssetManager;
use Flarum\Asset\JsCompiler; use Flarum\Asset\JsCompiler;
use Flarum\Asset\LessCompiler; use Flarum\Asset\LessCompiler;
use Flarum\Core;
use Flarum\Event\ConfigureClientView; use Flarum\Event\ConfigureClientView;
use Flarum\Foundation\Application; use Flarum\Foundation\Application;
use Flarum\Locale\JsCompiler as LocaleJsCompiler; use Flarum\Locale\JsCompiler as LocaleJsCompiler;

View File

@ -10,7 +10,6 @@
namespace Flarum\Http\Controller; namespace Flarum\Http\Controller;
use Flarum\Http\Controller\ControllerInterface;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response; use Zend\Diactoros\Response;

View File

@ -13,9 +13,9 @@ namespace Flarum\Http\Controller;
use Flarum\Api\Client; use Flarum\Api\Client;
use Flarum\Asset\AssetManager; use Flarum\Asset\AssetManager;
use Flarum\Core\User; use Flarum\Core\User;
use Flarum\Locale\JsCompiler;
use Illuminate\Contracts\Support\Renderable; use Illuminate\Contracts\Support\Renderable;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Flarum\Locale\JsCompiler;
/** /**
* This class represents a view which boots up Flarum's client. * 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'); $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->forum = $forum->data;
$view->layout = app('view')->file($this->layout, [ $view->layout = app('view')->file($this->layout, [
'forum' => $forum->data, 'forum' => $forum->data,

View File

@ -27,7 +27,7 @@ trait GenerateRouteHandlerTrait
if (! ($controller instanceof ControllerInterface)) { if (! ($controller instanceof ControllerInterface)) {
throw new \InvalidArgumentException('Route handler must be an instance of ' throw new \InvalidArgumentException('Route handler must be an instance of '
. ControllerInterface::class); .ControllerInterface::class);
} }
$request = $request->withQueryParams(array_merge($request->getQueryParams(), $routeParams)); $request = $request->withQueryParams(array_merge($request->getQueryParams(), $routeParams));

View File

@ -10,7 +10,6 @@
namespace Flarum\Http\Middleware; namespace Flarum\Http\Middleware;
use DateTime;
use Flarum\Api\ApiKey; use Flarum\Api\ApiKey;
use Flarum\Core\User; use Flarum\Core\User;
use Flarum\Http\AccessToken; use Flarum\Http\AccessToken;

View File

@ -12,7 +12,6 @@
namespace Flarum\Http\Middleware; namespace Flarum\Http\Middleware;
use FastRoute\Dispatcher; use FastRoute\Dispatcher;
use FastRoute\RouteParser;
use Flarum\Http\Exception\MethodNotAllowedException; use Flarum\Http\Exception\MethodNotAllowedException;
use Flarum\Http\Exception\RouteNotFoundException; use Flarum\Http\Exception\RouteNotFoundException;
use Flarum\Http\RouteCollection; use Flarum\Http\RouteCollection;

View File

@ -10,11 +10,11 @@
namespace Flarum\Http\Middleware; namespace Flarum\Http\Middleware;
use Franzl\Middleware\Whoops\ErrorMiddleware as WhoopsMiddleware;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\HtmlResponse;
use Zend\Stratigility\ErrorMiddlewareInterface; use Zend\Stratigility\ErrorMiddlewareInterface;
use Franzl\Middleware\Whoops\ErrorMiddleware as WhoopsMiddleware;
class HandleErrors implements ErrorMiddlewareInterface class HandleErrors implements ErrorMiddlewareInterface
{ {

View File

@ -92,7 +92,7 @@ class RouteCollection
$parts = $this->reverse[$name][0]; $parts = $this->reverse[$name][0];
array_walk($parts, [$this, 'fixPathPart'], $parameters); array_walk($parts, [$this, 'fixPathPart'], $parameters);
return '/' . ltrim(implode('', $parts), '/'); return '/'.ltrim(implode('', $parts), '/');
} }
throw new \RuntimeException("Route $name not found"); throw new \RuntimeException("Route $name not found");

View File

@ -10,9 +10,9 @@
namespace Flarum\Install\Console; namespace Flarum\Install\Console;
use Exception;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Exception;
class FileDataProvider implements DataProviderInterface class FileDataProvider implements DataProviderInterface
{ {
@ -39,7 +39,7 @@ class FileDataProvider implements DataProviderInterface
$this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null; $this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null;
$this->databaseConfiguration = isset($configuration['databaseConfiguration']) ? $configuration['databaseConfiguration'] : []; $this->databaseConfiguration = isset($configuration['databaseConfiguration']) ? $configuration['databaseConfiguration'] : [];
$this->adminUser = isset($configuration['adminUser']) ? $configuration['adminUser'] : []; $this->adminUser = isset($configuration['adminUser']) ? $configuration['adminUser'] : [];
$this->settings = isset($configuration['settings']) ? $configuration['settings']: []; $this->settings = isset($configuration['settings']) ? $configuration['settings'] : [];
} else { } else {
throw new Exception('Configuration file does not exist.'); throw new Exception('Configuration file does not exist.');
} }
@ -52,7 +52,7 @@ class FileDataProvider implements DataProviderInterface
public function getBaseUrl() 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() public function getAdminUser()

View File

@ -10,21 +10,17 @@
namespace Flarum\Install\Console; namespace Flarum\Install\Console;
use Exception;
use Flarum\Console\Command\AbstractCommand; use Flarum\Console\Command\AbstractCommand;
use Flarum\Database\AbstractModel;
use Flarum\Core\User;
use Flarum\Core\Group; use Flarum\Core\Group;
use Flarum\Core\Permission; use Flarum\Core\Permission;
use Flarum\Core\User;
use Flarum\Database\AbstractModel;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Validation\Factory; use Illuminate\Validation\Factory;
use PDO; use PDO;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Exception;
class InstallCommand extends AbstractCommand class InstallCommand extends AbstractCommand
{ {
@ -77,7 +73,7 @@ class InstallCommand extends AbstractCommand
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function fire() protected function fire()
{ {
@ -238,7 +234,7 @@ class InstallCommand extends AbstractCommand
$migrator = $this->application->make('Flarum\Database\Migrator'); $migrator = $this->application->make('Flarum\Database\Migrator');
$migrator->getRepository()->createRepository(); $migrator->getRepository()->createRepository();
$migrator->run(__DIR__ . '/../../../migrations'); $migrator->run(__DIR__.'/../../../migrations');
foreach ($migrator->getNotes() as $note) { foreach ($migrator->getNotes() as $note) {
$this->info($note); $this->info($note);
@ -393,7 +389,7 @@ class InstallCommand extends AbstractCommand
$this->info($error['message']); $this->info($error['message']);
if (isset($error['detail'])) { if (isset($error['detail'])) {
$this->output->writeln('<comment>' . $error['detail'] . '</comment>'); $this->output->writeln('<comment>'.$error['detail'].'</comment>');
} }
} }
} }

View File

@ -10,7 +10,6 @@
namespace Flarum\Install\Console; namespace Flarum\Install\Console;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -26,7 +25,6 @@ class UserDataProvider implements DataProviderInterface
protected $baseUrl; protected $baseUrl;
public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper) public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper)
{ {
$this->input = $input; $this->input = $input;
@ -77,13 +75,13 @@ class UserDataProvider implements DataProviderInterface
'forum_title' => $title, 'forum_title' => $title,
'forum_description' => '', 'forum_description' => '',
'mail_driver' => 'mail', '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_colored_header' => '0',
'theme_dark_mode' => '0', 'theme_dark_mode' => '0',
'theme_primary_color' => '#4D698E', 'theme_primary_color' => '#4D698E',
'theme_secondary_color' => '#4D698E', 'theme_secondary_color' => '#4D698E',
'welcome_message' => 'This is beta software and you should not use it in production.', 'welcome_message' => 'This is beta software and you should not use it in production.',
'welcome_title' => 'Welcome to ' . $title, 'welcome_title' => 'Welcome to '.$title,
]; ];
} }

View File

@ -10,10 +10,10 @@
namespace Flarum\Install\Controller; namespace Flarum\Install\Controller;
use Flarum\Install\Prerequisite\PrerequisiteInterface;
use Flarum\Http\Controller\AbstractHtmlController; use Flarum\Http\Controller\AbstractHtmlController;
use Psr\Http\Message\ServerRequestInterface as Request; use Flarum\Install\Prerequisite\PrerequisiteInterface;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Psr\Http\Message\ServerRequestInterface as Request;
class IndexController extends AbstractHtmlController class IndexController extends AbstractHtmlController
{ {

View File

@ -10,19 +10,16 @@
namespace Flarum\Install\Controller; 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 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 class InstallController implements ControllerInterface
{ {
@ -74,8 +71,8 @@ class InstallController implements ControllerInterface
$data->setBaseUrl($baseUrl); $data->setBaseUrl($baseUrl);
$data->setSetting('forum_title', array_get($input, 'forumTitle')); $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('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('welcome_title', 'Welcome to '.array_get($input, 'forumTitle'));
$body = fopen('php://temp', 'wb+'); $body = fopen('php://temp', 'wb+');
$input = new StringInput(''); $input = new StringInput('');

View File

@ -32,9 +32,9 @@ class JsCompiler extends BaseJsCompiler
$output .= file_get_contents($filename); $output .= file_get_contents($filename);
} }
$output .= "} $output .= '}
}; };
});"; });';
return $this->format($output); return $this->format($output);
} }

View File

@ -28,7 +28,7 @@ class Translator extends BaseTranslator
$this->assertValidLocale($locale); $this->assertValidLocale($locale);
} }
$parse = !isset($this->catalogues[$locale]); $parse = ! isset($this->catalogues[$locale]);
$catalogue = parent::getCatalogue($locale); $catalogue = parent::getCatalogue($locale);

View File

@ -26,7 +26,7 @@ class MemoryCacheSettingsRepository implements SettingsRepositoryInterface
public function all() public function all()
{ {
if (!$this->isCached) { if (! $this->isCached) {
$this->cache = $this->inner->all(); $this->cache = $this->inner->all();
$this->isCached = true; $this->isCached = true;
} }
@ -38,7 +38,7 @@ class MemoryCacheSettingsRepository implements SettingsRepositoryInterface
{ {
if (array_key_exists($key, $this->cache)) { if (array_key_exists($key, $this->cache)) {
return $this->cache[$key]; return $this->cache[$key];
} elseif (!$this->isCached) { } elseif (! $this->isCached) {
return array_get($this->all(), $key, $default); return array_get($this->all(), $key, $default);
} }

View File

@ -12,10 +12,6 @@ namespace Flarum\Update\Console;
use Flarum\Console\Command\AbstractCommand; use Flarum\Console\Command\AbstractCommand;
use Illuminate\Contracts\Container\Container; 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 class MigrateCommand extends AbstractCommand
{ {
@ -41,7 +37,7 @@ class MigrateCommand extends AbstractCommand
{ {
$this $this
->setName('migrate') ->setName('migrate')
->setDescription("Run outstanding migrations."); ->setDescription('Run outstanding migrations.');
} }
/** /**

View File

@ -11,8 +11,8 @@
namespace Flarum\Update\Controller; namespace Flarum\Update\Controller;
use Flarum\Http\Controller\AbstractHtmlController; use Flarum\Http\Controller\AbstractHtmlController;
use Psr\Http\Message\ServerRequestInterface as Request;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Psr\Http\Message\ServerRequestInterface as Request;
class IndexController extends AbstractHtmlController class IndexController extends AbstractHtmlController
{ {

View File

@ -1,4 +1,14 @@
<?php <?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests\Flarum\Core\Settings; namespace Tests\Flarum\Core\Settings;
use Flarum\Settings\DatabaseSettingsRepository; use Flarum\Settings\DatabaseSettingsRepository;
@ -16,17 +26,17 @@ class DatabaseSettingsRepositoryTest extends TestCase
$this->connection = m::mock(ConnectionInterface::class); $this->connection = m::mock(ConnectionInterface::class);
$this->repository = new DatabaseSettingsRepository($this->connection); $this->repository = new DatabaseSettingsRepository($this->connection);
} }
public function test_requesting_an_existing_setting_should_return_its_value() 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')); $this->assertEquals('value', $this->repository->get('key'));
} }
public function test_non_existent_setting_values_should_return_null() 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')); $this->assertEquals('default', $this->repository->get('key', 'default'));
} }

View File

@ -1,4 +1,14 @@
<?php <?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests\Flarum\Core\Settings; namespace Tests\Flarum\Core\Settings;
use Flarum\Settings\MemoryCacheSettingsRepository; use Flarum\Settings\MemoryCacheSettingsRepository;
@ -16,7 +26,7 @@ class MemoryCacheSettingsRepositoryTest extends TestCase
$this->baseRepository = m::mock(SettingsRepositoryInterface::class); $this->baseRepository = m::mock(SettingsRepositoryInterface::class);
$this->repository = new MemoryCacheSettingsRepository($this->baseRepository); $this->repository = new MemoryCacheSettingsRepository($this->baseRepository);
} }
public function test_it_should_return_all_settings_when_not_cached() public function test_it_should_return_all_settings_when_not_cached()
{ {
$this->baseRepository->shouldReceive('all')->once()->andReturn(['key' => 'value']); $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'));
$this->assertEquals('value2', $this->repository->get('key2')); // Assert twice to ensure we hit the cache $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() public function test_it_should_set_a_key_value_pair()
{ {
$this->baseRepository->shouldReceive('set')->once(); $this->baseRepository->shouldReceive('set')->once();

View File

@ -1,4 +1,14 @@
<?php <?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests\Test; namespace Tests\Test;
use Mockery; use Mockery;

View File

@ -162,7 +162,7 @@
<body> <body>
<div class="container"> <div class="container">
<h1> <h1>
<?php echo file_get_contents(__DIR__ . '/logo.svg'); ?> <?php echo file_get_contents(__DIR__.'/logo.svg'); ?>
</h1> </h1>
<div class="animated fadeIn"> <div class="animated fadeIn">