From 815eabc801a64034fa1b999dc531952399db183a Mon Sep 17 00:00:00 2001 From: rennokki Date: Thu, 13 Aug 2020 14:02:58 +0300 Subject: [PATCH] Apply fixes from StyleCI (#448) --- .../Controllers/FetchChannelsController.php | 8 ++++---- .../Broadcasters/RedisPusherBroadcaster.php | 8 ++++---- src/PubSub/Drivers/LocalClient.php | 16 ++++++++-------- src/PubSub/Drivers/RedisClient.php | 8 ++++---- src/PubSub/ReplicationInterface.php | 2 +- src/WebSocketsServiceProvider.php | 6 +++--- tests/Channels/ChannelReplicationTest.php | 2 +- .../Channels/PresenceChannelReplicationTest.php | 2 +- tests/HttpApi/FetchChannelReplicationTest.php | 2 +- tests/HttpApi/FetchChannelsReplicationTest.php | 2 +- tests/HttpApi/FetchUsersReplicationTest.php | 2 +- .../WebSocketsStatisticsControllerTest.php | 2 +- tests/TestsReplication.php | 2 +- 13 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/HttpApi/Controllers/FetchChannelsController.php b/src/HttpApi/Controllers/FetchChannelsController.php index fdf02b2836..7d0a6aa36a 100644 --- a/src/HttpApi/Controllers/FetchChannelsController.php +++ b/src/HttpApi/Controllers/FetchChannelsController.php @@ -2,13 +2,13 @@ namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers; +use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; +use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; +use BeyondCode\LaravelWebSockets\WebSockets\Channels\PresenceChannel; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Symfony\Component\HttpKernel\Exception\HttpException; -use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; -use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; -use BeyondCode\LaravelWebSockets\WebSockets\Channels\PresenceChannel; class FetchChannelsController extends Controller { @@ -45,7 +45,7 @@ public function __invoke(Request $request) // We want to get the channel user count all in one shot when // using a replication backend rather than doing individual queries. // To do so, we first collect the list of channel names. - $channelNames = $channels->map(function (PresenceChannel $channel) use ($request) { + $channelNames = $channels->map(function (PresenceChannel $channel) { return $channel->getChannelName(); })->toArray(); diff --git a/src/PubSub/Broadcasters/RedisPusherBroadcaster.php b/src/PubSub/Broadcasters/RedisPusherBroadcaster.php index f1be3a5ece..3476337388 100644 --- a/src/PubSub/Broadcasters/RedisPusherBroadcaster.php +++ b/src/PubSub/Broadcasters/RedisPusherBroadcaster.php @@ -2,12 +2,12 @@ namespace BeyondCode\LaravelWebSockets\PubSub\Broadcasters; -use Pusher\Pusher; -use Illuminate\Support\Arr; -use Illuminate\Support\Str; -use Illuminate\Contracts\Redis\Factory as Redis; use Illuminate\Broadcasting\Broadcasters\Broadcaster; use Illuminate\Broadcasting\Broadcasters\UsePusherChannelConventions; +use Illuminate\Contracts\Redis\Factory as Redis; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; +use Pusher\Pusher; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; class RedisPusherBroadcaster extends Broadcaster diff --git a/src/PubSub/Drivers/LocalClient.php b/src/PubSub/Drivers/LocalClient.php index 9d5c5e20f7..42f013b3d2 100644 --- a/src/PubSub/Drivers/LocalClient.php +++ b/src/PubSub/Drivers/LocalClient.php @@ -2,11 +2,11 @@ namespace BeyondCode\LaravelWebSockets\PubSub\Drivers; -use stdClass; +use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; use React\EventLoop\LoopInterface; use React\Promise\FulfilledPromise; use React\Promise\PromiseInterface; -use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; +use stdClass; class LocalClient implements ReplicationInterface { @@ -23,7 +23,7 @@ class LocalClient implements ReplicationInterface * @param LoopInterface $loop * @return self */ - public function boot(LoopInterface $loop) : ReplicationInterface + public function boot(LoopInterface $loop): ReplicationInterface { return $this; } @@ -36,7 +36,7 @@ public function boot(LoopInterface $loop) : ReplicationInterface * @param stdClass $payload * @return bool */ - public function publish(string $appId, string $channel, stdClass $payload) : bool + public function publish(string $appId, string $channel, stdClass $payload): bool { // Nothing to do, nobody to publish to return true; @@ -49,7 +49,7 @@ public function publish(string $appId, string $channel, stdClass $payload) : boo * @param string $channel * @return bool */ - public function subscribe(string $appId, string $channel) : bool + public function subscribe(string $appId, string $channel): bool { return true; } @@ -61,7 +61,7 @@ public function subscribe(string $appId, string $channel) : bool * @param string $channel * @return bool */ - public function unsubscribe(string $appId, string $channel) : bool + public function unsubscribe(string $appId, string $channel): bool { return true; } @@ -103,7 +103,7 @@ public function leaveChannel(string $appId, string $channel, string $socketId) * @param string $channel * @return PromiseInterface */ - public function channelMembers(string $appId, string $channel) : PromiseInterface + public function channelMembers(string $appId, string $channel): PromiseInterface { $members = $this->channelData["$appId:$channel"] ?? []; @@ -122,7 +122,7 @@ public function channelMembers(string $appId, string $channel) : PromiseInterfac * @param array $channelNames * @return PromiseInterface */ - public function channelMemberCounts(string $appId, array $channelNames) : PromiseInterface + public function channelMemberCounts(string $appId, array $channelNames): PromiseInterface { $results = []; diff --git a/src/PubSub/Drivers/RedisClient.php b/src/PubSub/Drivers/RedisClient.php index 2c8d916d9e..7a52c4ff11 100644 --- a/src/PubSub/Drivers/RedisClient.php +++ b/src/PubSub/Drivers/RedisClient.php @@ -2,14 +2,14 @@ namespace BeyondCode\LaravelWebSockets\PubSub\Drivers; -use stdClass; -use Illuminate\Support\Str; +use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; +use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; use Clue\React\Redis\Client; use Clue\React\Redis\Factory; +use Illuminate\Support\Str; use React\EventLoop\LoopInterface; use React\Promise\PromiseInterface; -use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; -use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; +use stdClass; class RedisClient implements ReplicationInterface { diff --git a/src/PubSub/ReplicationInterface.php b/src/PubSub/ReplicationInterface.php index 3e120af528..cd1a50c38f 100644 --- a/src/PubSub/ReplicationInterface.php +++ b/src/PubSub/ReplicationInterface.php @@ -2,9 +2,9 @@ namespace BeyondCode\LaravelWebSockets\PubSub; -use stdClass; use React\EventLoop\LoopInterface; use React\Promise\PromiseInterface; +use stdClass; interface ReplicationInterface { diff --git a/src/WebSocketsServiceProvider.php b/src/WebSocketsServiceProvider.php index bc107f16ad..87fb046be2 100644 --- a/src/WebSocketsServiceProvider.php +++ b/src/WebSocketsServiceProvider.php @@ -17,13 +17,13 @@ use BeyondCode\LaravelWebSockets\Statistics\Http\Middleware\Authorize as AuthorizeStatistics; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager; -use Pusher\Pusher; -use Psr\Log\LoggerInterface; use Illuminate\Broadcasting\BroadcastManager; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Route; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\ServiceProvider; +use Psr\Log\LoggerInterface; +use Pusher\Pusher; class WebSocketsServiceProvider extends ServiceProvider { diff --git a/tests/Channels/ChannelReplicationTest.php b/tests/Channels/ChannelReplicationTest.php index f8e08727f2..e107c7c705 100644 --- a/tests/Channels/ChannelReplicationTest.php +++ b/tests/Channels/ChannelReplicationTest.php @@ -8,7 +8,7 @@ class ChannelReplicationTest extends ChannelTest { use TestsReplication; - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/Channels/PresenceChannelReplicationTest.php b/tests/Channels/PresenceChannelReplicationTest.php index 70702715b0..abbcd04839 100644 --- a/tests/Channels/PresenceChannelReplicationTest.php +++ b/tests/Channels/PresenceChannelReplicationTest.php @@ -8,7 +8,7 @@ class PresenceChannelReplicationTest extends PresenceChannelTest { use TestsReplication; - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/HttpApi/FetchChannelReplicationTest.php b/tests/HttpApi/FetchChannelReplicationTest.php index 84f4c51a3a..c4c044743f 100644 --- a/tests/HttpApi/FetchChannelReplicationTest.php +++ b/tests/HttpApi/FetchChannelReplicationTest.php @@ -8,7 +8,7 @@ class FetchChannelReplicationTest extends FetchChannelTest { use TestsReplication; - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/HttpApi/FetchChannelsReplicationTest.php b/tests/HttpApi/FetchChannelsReplicationTest.php index 24eb9b419a..0b1b6aa20e 100644 --- a/tests/HttpApi/FetchChannelsReplicationTest.php +++ b/tests/HttpApi/FetchChannelsReplicationTest.php @@ -8,7 +8,7 @@ class FetchChannelsReplicationTest extends FetchChannelsTest { use TestsReplication; - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/HttpApi/FetchUsersReplicationTest.php b/tests/HttpApi/FetchUsersReplicationTest.php index 2d959a8ceb..45b87e8a7d 100644 --- a/tests/HttpApi/FetchUsersReplicationTest.php +++ b/tests/HttpApi/FetchUsersReplicationTest.php @@ -8,7 +8,7 @@ class FetchUsersReplicationTest extends FetchUsersTest { use TestsReplication; - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php b/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php index 421795c5e7..360518f67a 100644 --- a/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php +++ b/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php @@ -23,7 +23,7 @@ public function it_can_store_statistics() $this->assertCount(1, $entries); $actual = $entries->first()->attributesToArray(); - + foreach ($this->payload() as $key => $value) { $this->assertArrayHasKey($key, $actual); $this->assertSame($value, $actual[$key]); diff --git a/tests/TestsReplication.php b/tests/TestsReplication.php index e179ea0370..53c38f6cc8 100644 --- a/tests/TestsReplication.php +++ b/tests/TestsReplication.php @@ -2,9 +2,9 @@ namespace BeyondCode\LaravelWebSockets\Tests; -use Illuminate\Support\Facades\Config; use BeyondCode\LaravelWebSockets\PubSub\Drivers\LocalClient; use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; +use Illuminate\Support\Facades\Config; trait TestsReplication {