Use ::class instead of some hardcoded class names

This gives us better refactoring functionality in IDEs like
PhpStorm, and also more quickly surfaces typos through errors
about undefined classes. :)
This commit is contained in:
Franz Liedke 2018-01-02 19:36:48 +01:00
parent 3f7e7520b0
commit 936f67e953
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
20 changed files with 40 additions and 20 deletions

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Discussion\Command\ReadDiscussion;
use Flarum\Discussion\Command\StartDiscussion;
use Flarum\Post\Floodgate;
@ -23,7 +24,7 @@ class CreateDiscussionController extends AbstractCreateController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer';
public $serializer = DiscussionSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\GroupSerializer;
use Flarum\Group\Command\CreateGroup;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class CreateGroupController extends AbstractCreateController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\GroupSerializer';
public $serializer = GroupSerializer::class;
/**
* @var Dispatcher

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Discussion\Command\ReadDiscussion;
use Flarum\Post\Command\PostReply;
use Flarum\Post\Floodgate;
@ -23,7 +24,7 @@ class CreatePostController extends AbstractCreateController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\PostSerializer';
public $serializer = PostSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\CurrentUserSerializer;
use Flarum\User\Command\RegisterUser;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class CreateUserController extends AbstractCreateController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\CurrentUserSerializer';
public $serializer = CurrentUserSerializer::class;
/**
* @var Dispatcher

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\User\Command\DeleteAvatar;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class DeleteAvatarController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\UserSerializer';
public $serializer = UserSerializer::class;
/**
* @var Dispatcher

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Discussion\Search\DiscussionSearcher;
use Flarum\Http\UrlGenerator;
use Flarum\Search\SearchCriteria;
@ -22,7 +23,7 @@ class ListDiscussionsController extends AbstractListController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer';
public $serializer = DiscussionSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\GroupSerializer;
use Flarum\Group\Group;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
@ -20,7 +21,7 @@ class ListGroupsController extends AbstractListController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\GroupSerializer';
public $serializer = GroupSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\NotificationSerializer;
use Flarum\Discussion\Discussion;
use Flarum\Http\UrlGenerator;
use Flarum\Notification\NotificationRepository;
@ -23,7 +24,7 @@ class ListNotificationsController extends AbstractListController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\NotificationSerializer';
public $serializer = NotificationSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Event\ConfigurePostsQuery;
use Flarum\Post\PostRepository;
use Illuminate\Database\Eloquent\Builder;
@ -23,7 +24,7 @@ class ListPostsController extends AbstractListController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\PostSerializer';
public $serializer = PostSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\Http\UrlGenerator;
use Flarum\Search\SearchCriteria;
use Flarum\User\Exception\PermissionDeniedException;
@ -23,7 +24,7 @@ class ListUsersController extends AbstractListController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\UserSerializer';
public $serializer = UserSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Discussion\Discussion;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Post\PostRepository;
@ -33,7 +34,7 @@ class ShowDiscussionController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer';
public $serializer = DiscussionSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Group\Group;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
@ -20,7 +21,7 @@ class ShowForumController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\ForumSerializer';
public $serializer = ForumSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Post\PostRepository;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
@ -20,7 +21,7 @@ class ShowPostController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\PostSerializer';
public $serializer = PostSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\User\UserRepository;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
@ -20,7 +21,7 @@ class ShowUserController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\UserSerializer';
public $serializer = UserSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Discussion\Command\EditDiscussion;
use Flarum\Discussion\Command\ReadDiscussion;
use Illuminate\Contracts\Bus\Dispatcher;
@ -23,7 +24,7 @@ class UpdateDiscussionController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer';
public $serializer = DiscussionSerializer::class;
/**
* @var Dispatcher

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\GroupSerializer;
use Flarum\Group\Command\EditGroup;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class UpdateGroupController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\GroupSerializer';
public $serializer = GroupSerializer::class;
/**
* @var Dispatcher

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\NotificationSerializer;
use Flarum\Notification\Command\ReadNotification;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class UpdateNotificationController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\NotificationSerializer';
public $serializer = NotificationSerializer::class;
/**
* @var Dispatcher

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Post\Command\EditPost;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class UpdatePostController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\PostSerializer';
public $serializer = PostSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\CurrentUserSerializer;
use Flarum\User\Command\EditUser;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Contracts\Bus\Dispatcher;
@ -22,7 +23,7 @@ class UpdateUserController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\CurrentUserSerializer';
public $serializer = CurrentUserSerializer::class;
/**
* {@inheritdoc}

View File

@ -11,6 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\User\Command\UploadAvatar;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
@ -21,7 +22,7 @@ class UploadAvatarController extends AbstractShowController
/**
* {@inheritdoc}
*/
public $serializer = 'Flarum\Api\Serializer\UserSerializer';
public $serializer = UserSerializer::class;
/**
* @var Dispatcher