Skip to content

Commit 1908914

Browse files
committed
fix: allow null body
1 parent 02b12c0 commit 1908914

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Client.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ private function withRetries(callable $callback): mixed
204204
public function fetch(
205205
string $url,
206206
string $method = self::METHOD_GET,
207-
array $body = [],
208-
array $query = [],
207+
?array $body = [],
208+
?array $query = [],
209209
): Response {
210210
if (!in_array($method, [self::METHOD_PATCH, self::METHOD_GET, self::METHOD_CONNECT, self::METHOD_DELETE, self::METHOD_POST, self::METHOD_HEAD, self::METHOD_OPTIONS, self::METHOD_PUT, self::METHOD_TRACE])) {
211211
throw new FetchException("Unsupported HTTP method");
212212
}
213213

214-
if (isset($this->headers['content-type'])) {
214+
if (isset($this->headers['content-type']) && $body !== null) {
215215
$body = match ($this->headers['content-type']) {
216216
self::CONTENT_TYPE_APPLICATION_JSON => json_encode($body),
217217
self::CONTENT_TYPE_APPLICATION_FORM_URLENCODED, self::CONTENT_TYPE_MULTIPART_FORM_DATA => self::flatten($body),

0 commit comments

Comments
 (0)