Skip to content

Commit 31bcafe

Browse files
author
John Hutcheson
committed
default request headers to empty array
1 parent a21bbd0 commit 31bcafe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Requests/MailchimpRequest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class MailchimpRequest
8282

8383
/**
8484
* The payload that is serialized and sent
85-
* @var array
85+
* @var object
8686
*/
8787
private $payload;
8888

@@ -118,6 +118,7 @@ class MailchimpRequest
118118
public function __construct($apikey = null)
119119
{
120120
if (!$apikey) {
121+
$this->setHeaders([]);
121122
return;
122123
}
123124

@@ -200,9 +201,13 @@ public function getValidMethods()
200201
/**
201202
* Get the headers
202203
* @return array
204+
* @throws MailchimpException
203205
*/
204206
public function getHeaders()
205207
{
208+
if (!is_array($this->headers)) {
209+
throw new MailchimpException("Request headers must be of type array");
210+
}
206211
return $this->headers;
207212
}
208213

@@ -423,6 +428,9 @@ public function reset()
423428
$request_vars = get_object_vars($this);
424429
foreach ($request_vars as $key => $value) {
425430
$this->$key = null;
431+
if ($key == 'headers') {
432+
$this->$key = [];
433+
}
426434
}
427435
self::__construct($apikey);
428436
}

0 commit comments

Comments
 (0)