Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Hotfix: default value for headers is string not null #204

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Header/AcceptRanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ public static function fromString($headerLine)
);
}

$header = new static($value);

return $header;
return new static($value);
}

public function __construct($rangeUnit = null)
{
if ($rangeUnit) {
if ($rangeUnit !== null) {
$this->setRangeUnit($rangeUnit);
}
}
Expand All @@ -58,7 +56,7 @@ public function setRangeUnit($rangeUnit)

public function getRangeUnit()
{
return $this->rangeUnit;
return (string) $this->rangeUnit;
}

public function toString()
Expand Down
10 changes: 4 additions & 6 deletions src/Header/Age.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ public static function fromString($headerLine)
throw new Exception\InvalidArgumentException('Invalid header line for Age string: "' . $name . '"');
}

$header = new static($value);

return $header;
return new static($value);
}

public function __construct($deltaSeconds = null)
{
if ($deltaSeconds) {
if ($deltaSeconds !== null) {
$this->setDeltaSeconds($deltaSeconds);
}
}
Expand All @@ -62,11 +60,11 @@ public function getFieldName()
/**
* Get header value (number of seconds)
*
* @return int
* @return string
*/
public function getFieldValue()
{
return $this->getDeltaSeconds();
return (string) $this->getDeltaSeconds();
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/Header/AuthenticationInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/ContentDisposition.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/ContentEncoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -50,7 +48,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/ContentLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
6 changes: 2 additions & 4 deletions src/Header/ContentLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/ContentMD5.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -48,7 +46,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/ContentRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/ContentTransferEncoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static(strtolower($value));

return $header;
return new static(strtolower($value));
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -51,7 +49,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
6 changes: 3 additions & 3 deletions src/Header/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function fromString($headerLine)

public function __construct($value = null, $mediaType = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public function getFieldName()
public function getFieldValue()
{
if (null !== $this->value) {
return $this->value;
return (string) $this->value;
}
return $this->assembleValue();
}
Expand All @@ -172,7 +172,7 @@ public function setMediaType($mediaType)
*/
public function getMediaType()
{
return $this->mediaType;
return (string) $this->mediaType;
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/Header/Etag.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -48,7 +46,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/Expect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -48,7 +46,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
8 changes: 3 additions & 5 deletions src/Header/From.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ public static function fromString($headerLine)
}

// @todo implementation details
$header = new static($value);

return $header;
return new static($value);
}

public function __construct($value = null)
{
if ($value) {
if ($value !== null) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand All @@ -48,7 +46,7 @@ public function getFieldName()

public function getFieldValue()
{
return $this->value;
return (string) $this->value;
}

public function toString()
Expand Down
Loading