Merge pull request #1 from deviouspk/analysis-z3nD5L

Apply fixes from StyleCI
This commit is contained in:
Arthur Vandenberghe 2019-07-28 21:29:16 +02:00 committed by Francis Lavoie
parent d43ac821d9
commit 11e1f89b5e
No known key found for this signature in database
GPG Key ID: B9E0E04A76AF4692
5 changed files with 17 additions and 19 deletions

View File

@ -116,6 +116,7 @@ class StartWebSocketServer extends Command
protected function registerCustomRoutes() protected function registerCustomRoutes()
{ {
WebSocketsRouter::customRoutes(); WebSocketsRouter::customRoutes();
return $this; return $this;
} }

View File

@ -10,7 +10,6 @@ use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface;
class EmptyClient implements ReplicationInterface class EmptyClient implements ReplicationInterface
{ {
/** /**
* Boot the pub/sub provider (open connections, initial subscriptions, etc). * Boot the pub/sub provider (open connections, initial subscriptions, etc).
* *
@ -70,7 +69,6 @@ class EmptyClient implements ReplicationInterface
*/ */
public function joinChannel(string $appId, string $channel, string $socketId, string $data) public function joinChannel(string $appId, string $channel, string $socketId, string $data)
{ {
} }
/** /**
@ -83,7 +81,6 @@ class EmptyClient implements ReplicationInterface
*/ */
public function leaveChannel(string $appId, string $channel, string $socketId) public function leaveChannel(string $appId, string $channel, string $socketId)
{ {
} }
/** /**

View File

@ -52,7 +52,7 @@ class Channel
$signature .= ":{$payload->channel_data}"; $signature .= ":{$payload->channel_data}";
} }
if (!hash_equals( if (! hash_equals(
hash_hmac('sha256', $signature, $connection->app->secret), hash_hmac('sha256', $signature, $connection->app->secret),
Str::after($payload->auth, ':')) Str::after($payload->auth, ':'))
) { ) {
@ -83,7 +83,7 @@ class Channel
// Unsubscribe from the pub/sub backend // Unsubscribe from the pub/sub backend
$this->pubSub->unsubscribe($connection->app->id, $this->channelName); $this->pubSub->unsubscribe($connection->app->id, $this->channelName);
if (!$this->hasConnections()) { if (! $this->hasConnections()) {
DashboardLogger::vacated($connection, $this->channelName); DashboardLogger::vacated($connection, $this->channelName);
} }
} }
@ -94,7 +94,7 @@ class Channel
$this->subscribedConnections[$connection->socketId] = $connection; $this->subscribedConnections[$connection->socketId] = $connection;
if (!$hadConnectionsPreviously) { if (! $hadConnectionsPreviously) {
DashboardLogger::occupied($connection, $this->channelName); DashboardLogger::occupied($connection, $this->channelName);
} }

View File

@ -2,10 +2,6 @@
namespace BeyondCode\LaravelWebSockets; namespace BeyondCode\LaravelWebSockets;
use BeyondCode\LaravelWebSockets\PubSub\Broadcasters\RedisPusherBroadcaster;
use BeyondCode\LaravelWebSockets\PubSub\Drivers\EmptyClient;
use BeyondCode\LaravelWebSockets\PubSub\Drivers\RedisClient;
use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface;
use Pusher\Pusher; use Pusher\Pusher;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
@ -14,9 +10,13 @@ use Illuminate\Support\ServiceProvider;
use Illuminate\Broadcasting\BroadcastManager; use Illuminate\Broadcasting\BroadcastManager;
use BeyondCode\LaravelWebSockets\Server\Router; use BeyondCode\LaravelWebSockets\Server\Router;
use BeyondCode\LaravelWebSockets\Apps\AppProvider; use BeyondCode\LaravelWebSockets\Apps\AppProvider;
use BeyondCode\LaravelWebSockets\PubSub\Drivers\EmptyClient;
use BeyondCode\LaravelWebSockets\PubSub\Drivers\RedisClient;
use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface;
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
use BeyondCode\LaravelWebSockets\PubSub\Broadcasters\RedisPusherBroadcaster;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboard; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboard;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\DashboardApiController; use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\DashboardApiController;
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager;
@ -29,12 +29,12 @@ class WebSocketsServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
$this->publishes([ $this->publishes([
__DIR__ . '/../config/websockets.php' => base_path('config/websockets.php'), __DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
], 'config'); ], 'config');
if (!class_exists('CreateWebSocketsStatisticsEntries')) { if (! class_exists('CreateWebSocketsStatisticsEntries')) {
$this->publishes([ $this->publishes([
__DIR__ . '/../database/migrations/create_websockets_statistics_entries_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_websockets_statistics_entries_table.php'), __DIR__.'/../database/migrations/create_websockets_statistics_entries_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_websockets_statistics_entries_table.php'),
], 'migrations'); ], 'migrations');
} }
@ -42,7 +42,7 @@ class WebSocketsServiceProvider extends ServiceProvider
->registerRoutes() ->registerRoutes()
->registerDashboardGate(); ->registerDashboardGate();
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets'); $this->loadViewsFrom(__DIR__.'/../resources/views/', 'websockets');
$this->commands([ $this->commands([
Console\StartWebSocketServer::class, Console\StartWebSocketServer::class,
@ -50,15 +50,15 @@ class WebSocketsServiceProvider extends ServiceProvider
]); ]);
$this->configurePubSub(); $this->configurePubSub();
} }
protected function configurePubSub() protected function configurePubSub()
{ {
if (config('websockets.replication.enabled') !== true || config('websockets.replication.driver') !== 'redis') { if (config('websockets.replication.enabled') !== true || config('websockets.replication.driver') !== 'redis') {
$this->app->singleton(ReplicationInterface::class, function () { $this->app->singleton(ReplicationInterface::class, function () {
return (new EmptyClient()); return new EmptyClient();
}); });
return; return;
} }
@ -87,7 +87,7 @@ class WebSocketsServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->mergeConfigFrom(__DIR__ . '/../config/websockets.php', 'websockets'); $this->mergeConfigFrom(__DIR__.'/../config/websockets.php', 'websockets');
$this->app->singleton('websockets.router', function () { $this->app->singleton('websockets.router', function () {
return new Router(); return new Router();

View File

@ -2,10 +2,10 @@
namespace BeyondCode\LaravelWebSockets\Tests; namespace BeyondCode\LaravelWebSockets\Tests;
use BeyondCode\LaravelWebSockets\Tests\Mocks\FakeReplicationClient;
use Illuminate\Support\Facades\Config;
use React\EventLoop\Factory; use React\EventLoop\Factory;
use Illuminate\Support\Facades\Config;
use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface;
use BeyondCode\LaravelWebSockets\Tests\Mocks\FakeReplicationClient;
trait TestsReplication trait TestsReplication
{ {