You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public function publish(string $name, mixed $payload, ?string $replyTo = null): self
{
return $this->send(new Publish([
'payload' => Payload::parse($payload),
'replyTo' => $replyTo,
'subject' => $name,
]));
}
public static function parse(mixed $data): self
{
if ($data instanceof self) {
return $data;
}
if (is_string($data)) {
return new self($data);
}
if (is_array($data)) {
return new self(json_encode($data));
}
return new self("");
}```
Causes nil bodies to be published to NATS if data type is not string or array
The text was updated successfully, but these errors were encountered:
IvanWillsBI
changed the title
class Payload cannot handle mixed types in publish despute publish function accepting mixed payload
class Payload cannot handle mixed types in publish despite publish function accepting mixed payload
May 8, 2024
public static function parse(mixed $data): self
{
if ($data instanceof self) {
return $data;
}
if (is_string($data)) {
return new self($data);
}
if (is_array($data)) {
return new self(json_encode($data));
}
if (is_resource($data)) {
return new self('');
}
return new self(json_encode($data));
}
public static function parse(mixed $data): self
{
if ($data instanceof self) {
return $data;
}
if (is_string($data)) {
return new self($data);
}
if (is_array($data)) {
return new self(json_encode($data));
}
if (is_resource($data)) {
return new self('');
}
return new self(json_encode($data));
}
Is this a viable fix, I would raise a PR but encountering a permissions issue
The text was updated successfully, but these errors were encountered: