1
0
mirror of https://github.com/flarum/core.git synced 2025-10-13 16:05:05 +02:00

Applied fixes from StyleCI

This commit is contained in:
Toby Zerner
2016-02-25 22:09:39 -05:00
committed by StyleCI Bot
parent 83c22d73a4
commit a6cf10f854
96 changed files with 240 additions and 245 deletions

View File

@@ -1,5 +1,14 @@
<?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;
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)
{

View File

@@ -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.
*/

View File

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

View File

@@ -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)
{

View File

@@ -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");
}
}

View File

@@ -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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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));
}

View File

@@ -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));

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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
*/

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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;
}
/**

View File

@@ -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;
/**

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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)) {

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -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
{

View File

@@ -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
*/