These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace BeyondCode\LaravelWebSockets\WebSockets\Messages; |
||
4 | |||
5 | use stdClass; |
||
6 | use Illuminate\Support\Str; |
||
7 | use Ratchet\ConnectionInterface; |
||
8 | use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger; |
||
9 | use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; |
||
10 | |||
11 | class PusherClientMessage implements PusherMessage |
||
12 | { |
||
13 | /** \stdClass */ |
||
14 | protected $payload; |
||
15 | |||
16 | /** @var \Ratchet\ConnectionInterface */ |
||
17 | protected $connection; |
||
18 | |||
19 | /** @var \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager */ |
||
20 | protected $channelManager; |
||
21 | |||
22 | public function __construct(stdClass $payload, ConnectionInterface $connection, ChannelManager $channelManager) |
||
23 | { |
||
24 | $this->payload = $payload; |
||
25 | |||
26 | $this->connection = $connection; |
||
27 | |||
28 | $this->channelManager = $channelManager; |
||
29 | } |
||
30 | |||
31 | public function respond() |
||
32 | { |
||
33 | if (! Str::startsWith($this->payload->event, 'client-')) { |
||
34 | return; |
||
35 | } |
||
36 | |||
37 | if (! $this->connection->app->clientMessagesEnabled) { |
||
0 ignored issues
–
show
|
|||
38 | return; |
||
39 | } |
||
40 | |||
41 | DashboardLogger::clientMessage($this->connection, $this->payload); |
||
42 | |||
43 | $channel = $this->channelManager->find($this->connection->app->id, $this->payload->channel); |
||
0 ignored issues
–
show
Accessing
app on the interface Ratchet\ConnectionInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
44 | |||
45 | optional($channel)->broadcastToOthers($this->connection, $this->payload); |
||
46 | } |
||
47 | } |
||
48 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: