Skip to content

Commit eaaea98

Browse files
committed
Rename variable in processWsMessage
If we overwrite it we won't get useful data logged in the first warning
1 parent 088715b commit eaaea98

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Discord/Discord.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -742,17 +742,17 @@ public function handleWsMessage(Message $message): void
742742
*/
743743
protected function processWsMessage(string $data): void
744744
{
745-
if (! $data = json_decode($data)) {
745+
if (! $decoded = json_decode($data)) {
746746
$this->logger->warning('failed to decode websocket message', ['payload' => $data]);
747747

748748
// @todo: handle invalid payload (reconnect), throw exception, or ignore?
749749
return;
750750
}
751751

752-
$this->emit('raw', [$data, $this]);
752+
$this->emit('raw', [$decoded, $this]);
753753

754-
if (isset($data->s)) {
755-
$this->seq = $data->s;
754+
if (isset($decoded->s)) {
755+
$this->seq = $decoded->s;
756756
}
757757

758758
static $rawOp = [
@@ -767,11 +767,11 @@ protected function processWsMessage(string $data): void
767767
Op::OP_HEARTBEAT_ACK => 'handleHeartbeatAck',
768768
];
769769

770-
isset($rawOp[$data->op])
771-
? $this->{$rawOp[$data->op]}($data)
772-
: (isset($op[$data->op])
773-
? $this->{$op[$data->op]}(Payload::new($data->op, $data->d, $data->s, $data->t))
774-
: $this->logger->debug('unknown op code', ['op' => $data->op, 'payload' => $data]));
770+
isset($rawOp[$decoded->op])
771+
? $this->{$rawOp[$decoded->op]}($decoded)
772+
: (isset($op[$decoded->op])
773+
? $this->{$op[$decoded->op]}(Payload::new($decoded->op, $decoded->d, $decoded->s, $decoded->t))
774+
: $this->logger->debug('unknown op code', ['op' => $decoded->op, 'payload' => $decoded]));
775775
}
776776

777777
/**

0 commit comments

Comments
 (0)