Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit f26f892

Browse files
committed
Merge branch 'master' of github.com:beyondcode/laravel-websockets
2 parents 82bba5b + 3ec6c0a commit f26f892

File tree

12 files changed

+31
-22
lines changed

12 files changed

+31
-22
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
"cboden/ratchet": "^0.4.1",
2828
"clue/buzz-react": "^2.5",
2929
"guzzlehttp/psr7": "^1.5",
30-
"illuminate/broadcasting": "5.7.*",
31-
"illuminate/console": "5.7.*",
32-
"illuminate/http": "5.7.*",
33-
"illuminate/routing": "5.7.*",
34-
"illuminate/support": "5.7.*",
30+
"illuminate/broadcasting": "5.7.* || 5.8.*",
31+
"illuminate/console": "5.7.* || 5.8.*",
32+
"illuminate/http": "5.7.* || 5.8.*",
33+
"illuminate/routing": "5.7.* || 5.8.*",
34+
"illuminate/support": "5.7.* || 5.8.*",
3535
"pusher/pusher-php-server": "~3.0",
3636
"symfony/http-kernel": "~4.0",
3737
"symfony/psr-http-message-bridge": "^1.1"
3838
},
3939
"require-dev": {
4040
"mockery/mockery": "^1.2",
41-
"orchestra/testbench": "3.7.*",
41+
"orchestra/testbench": "3.7.* || 3.8.*",
4242
"phpunit/phpunit": "^7.0"
4343
},
4444
"autoload": {

src/HttpApi/Controllers/Controller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Exception;
66
use Pusher\Pusher;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Http\Request;
89
use GuzzleHttp\Psr7\Response;
910
use Ratchet\ConnectionInterface;
@@ -43,7 +44,7 @@ public function onOpen(ConnectionInterface $connection, RequestInterface $reques
4344

4445
$this->contentLength = $this->findContentLength($request->getHeaders());
4546

46-
$this->requestBuffer = (string)$request->getBody();
47+
$this->requestBuffer = (string) $request->getBody();
4748

4849
$this->checkContentLength($connection);
4950
}
@@ -123,7 +124,7 @@ protected function ensureValidSignature(Request $request)
123124
*
124125
* The `appId`, `appKey` & `channelName` parameters are actually route paramaters and are never supplied by the client.
125126
*/
126-
$params = array_except($request->query(), ['auth_signature', 'body_md5', 'appId', 'appKey', 'channelName']);
127+
$params = Arr::except($request->query(), ['auth_signature', 'body_md5', 'appId', 'appKey', 'channelName']);
127128

128129
if ($request->getContent() !== '') {
129130
$params['body_md5'] = md5($request->getContent());

src/HttpApi/Controllers/FetchChannelsController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers;
44

5+
use Illuminate\Support\Str;
56
use Illuminate\Http\Request;
67
use Illuminate\Support\Collection;
78
use BeyondCode\LaravelWebSockets\WebSockets\Channels\PresenceChannel;
@@ -16,7 +17,7 @@ public function __invoke(Request $request)
1617

1718
if ($request->has('filter_by_prefix')) {
1819
$channels = $channels->filter(function ($channel, $channelName) use ($request) {
19-
return starts_with($channelName, $request->filter_by_prefix);
20+
return Str::startsWith($channelName, $request->filter_by_prefix);
2021
});
2122
}
2223

src/Statistics/Events/StatisticsUpdated.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\LaravelWebSockets\Statistics\Events;
44

5+
use Illuminate\Support\Str;
56
use Illuminate\Queue\SerializesModels;
67
use Illuminate\Broadcasting\PrivateChannel;
78
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
@@ -33,7 +34,7 @@ public function broadcastWith()
3334

3435
public function broadcastOn()
3536
{
36-
$channelName = str_after(DashboardLogger::LOG_CHANNEL_PREFIX.'statistics', 'private-');
37+
$channelName = Str::after(DashboardLogger::LOG_CHANNEL_PREFIX.'statistics', 'private-');
3738

3839
return new PrivateChannel($channelName);
3940
}

src/WebSockets/Channels/Channel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\LaravelWebSockets\WebSockets\Channels;
44

55
use stdClass;
6+
use Illuminate\Support\Str;
67
use Ratchet\ConnectionInterface;
78
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
89
use BeyondCode\LaravelWebSockets\WebSockets\Exceptions\InvalidSignature;
@@ -38,7 +39,7 @@ protected function verifySignature(ConnectionInterface $connection, stdClass $pa
3839
$signature .= ":{$payload->channel_data}";
3940
}
4041

41-
if (str_after($payload->auth, ':') !== hash_hmac('sha256', $signature, $connection->app->secret)) {
42+
if (Str::after($payload->auth, ':') !== hash_hmac('sha256', $signature, $connection->app->secret)) {
4243
throw new InvalidSignature();
4344
}
4445
}

src/WebSockets/Channels/ChannelManagers/ArrayChannelManager.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers;
44

5+
use Illuminate\Support\Arr;
6+
use Illuminate\Support\Str;
57
use Ratchet\ConnectionInterface;
68
use BeyondCode\LaravelWebSockets\WebSockets\Channels\Channel;
79
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
@@ -34,11 +36,11 @@ public function find(string $appId, string $channelName): ?Channel
3436

3537
protected function determineChannelClass(string $channelName): string
3638
{
37-
if (starts_with($channelName, 'private-')) {
39+
if (Str::startsWith($channelName, 'private-')) {
3840
return PrivateChannel::class;
3941
}
4042

41-
if (starts_with($channelName, 'presence-')) {
43+
if (Str::startsWith($channelName, 'presence-')) {
4244
return PresenceChannel::class;
4345
}
4446

@@ -67,18 +69,18 @@ public function removeFromAllChannels(ConnectionInterface $connection)
6769
/*
6870
* Remove the connection from all channels.
6971
*/
70-
collect(array_get($this->channels, $connection->app->id, []))->each->unsubscribe($connection);
72+
collect(Arr::get($this->channels, $connection->app->id, []))->each->unsubscribe($connection);
7173

7274
/*
7375
* Unset all channels that have no connections so we don't leak memory.
7476
*/
75-
collect(array_get($this->channels, $connection->app->id, []))
77+
collect(Arr::get($this->channels, $connection->app->id, []))
7678
->reject->hasConnections()
7779
->each(function (Channel $channel, string $channelName) use ($connection) {
7880
unset($this->channels[$connection->app->id][$channelName]);
7981
});
8082

81-
if (count(array_get($this->channels, $connection->app->id, [])) === 0) {
83+
if (count(Arr::get($this->channels, $connection->app->id, [])) === 0) {
8284
unset($this->channels[$connection->app->id]);
8385
}
8486
}

src/WebSockets/Messages/PusherChannelProtocolMessage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages;
44

55
use stdClass;
6+
use Illuminate\Support\Str;
67
use Ratchet\ConnectionInterface;
78
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
89

@@ -28,7 +29,7 @@ public function __construct(stdClass $payload, ConnectionInterface $connection,
2829

2930
public function respond()
3031
{
31-
$eventName = camel_case(str_after($this->payload->event, ':'));
32+
$eventName = Str::camel(Str::after($this->payload->event, ':'));
3233

3334
if (method_exists($this, $eventName)) {
3435
call_user_func([$this, $eventName], $this->connection, $this->payload->data ?? new stdClass());

src/WebSockets/Messages/PusherClientMessage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages;
44

55
use stdClass;
6+
use Illuminate\Support\Str;
67
use Ratchet\ConnectionInterface;
78
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
89
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
@@ -29,7 +30,7 @@ public function __construct(stdClass $payload, ConnectionInterface $connection,
2930

3031
public function respond()
3132
{
32-
if (! starts_with($this->payload->event, 'client-')) {
33+
if (! Str::startsWith($this->payload->event, 'client-')) {
3334
return;
3435
}
3536

src/WebSockets/Messages/PusherMessageFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages;
44

5+
use Illuminate\Support\Str;
56
use Ratchet\ConnectionInterface;
67
use Ratchet\RFC6455\Messaging\MessageInterface;
78
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
@@ -15,7 +16,7 @@ public static function createForMessage(
1516
{
1617
$payload = json_decode($message->getPayload());
1718

18-
return starts_with($payload->event, 'pusher:')
19+
return Str::startsWith($payload->event, 'pusher:')
1920
? new PusherChannelProtocolMessage($payload, $connection, $channelManager)
2021
: new PusherClientMessage($payload, $connection, $channelManager);
2122
}

tests/ClientProviders/ConfigAppProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ConfigAppProviderTest extends TestCase
1010
/** @var \BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider */
1111
protected $configAppProvider;
1212

13-
public function setUp()
13+
public function setUp(): void
1414
{
1515
parent::setUp();
1616

tests/Commands/CleanStatisticsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class CleanStatisticsTest extends TestCase
1212
{
13-
public function setUp()
13+
public function setUp(): void
1414
{
1515
parent::setUp();
1616

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
1919
/** @var \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager */
2020
protected $channelManager;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
parent::setUp();
2525

0 commit comments

Comments
 (0)