Set headers and headerLookup arrays in Message::__constructor to prevent warning

This commit is contained in:
PJ Dietz 2013-03-29 13:53:51 -04:00
parent 972f8e9c26
commit 9863bee7f5
3 changed files with 13 additions and 2 deletions

View File

@ -15,6 +15,7 @@ namespace pjdietz\WellRESTed;
* *
* @property string body Entity body of the message * @property string body Entity body of the message
* @property-read array headers Associative array of HTTP headers * @property-read array headers Associative array of HTTP headers
* @property-read array headerLines Numeric array of HTTP headers
* @property string protocol The protocol, e.g. HTTP * @property string protocol The protocol, e.g. HTTP
* @property string protocolVersion The version of the protocol * @property string protocolVersion The version of the protocol
*/ */
@ -57,6 +58,14 @@ abstract class Message
*/ */
protected $protocolVersion = '1.1'; protected $protocolVersion = '1.1';
// -------------------------------------------------------------------------
public function __construct()
{
$this->headers = array();
$this->headerLines = array();
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Accessors // Accessors

View File

@ -84,6 +84,8 @@ class Request extends Message
*/ */
public function __construct($uri = null, $method = 'GET') public function __construct($uri = null, $method = 'GET')
{ {
parent::__construct();
if (!is_null($uri)) { if (!is_null($uri)) {
$this->setUri($uri); $this->setUri($uri);
} }

View File

@ -51,12 +51,12 @@ class Response extends Message
*/ */
public function __construct($statusCode = 500, $body = null, $headers = null) public function __construct($statusCode = 500, $body = null, $headers = null)
{ {
parent::__construct();
$this->statusCode = $statusCode; $this->statusCode = $statusCode;
if (is_array($headers)) { if (is_array($headers)) {
$this->headers = $headers; $this->headers = $headers;
} else {
$this->headers = array();
} }
if (!is_null($body)) { if (!is_null($body)) {