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

Commit 31570fb

Browse files
committed
Merge pull request #204 from michalbundyra/hotfix/header-field-value
Hotfix: default value for headers is string not null
2 parents e107186 + c18aca6 commit 31570fb

38 files changed

+270
-181
lines changed

src/Header/AcceptRanges.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ public static function fromString($headerLine)
2727
);
2828
}
2929

30-
$header = new static($value);
31-
32-
return $header;
30+
return new static($value);
3331
}
3432

3533
public function __construct($rangeUnit = null)
3634
{
37-
if ($rangeUnit) {
35+
if ($rangeUnit !== null) {
3836
$this->setRangeUnit($rangeUnit);
3937
}
4038
}
@@ -58,7 +56,7 @@ public function setRangeUnit($rangeUnit)
5856

5957
public function getRangeUnit()
6058
{
61-
return $this->rangeUnit;
59+
return (string) $this->rangeUnit;
6260
}
6361

6462
public function toString()

src/Header/Age.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ public static function fromString($headerLine)
3737
throw new Exception\InvalidArgumentException('Invalid header line for Age string: "' . $name . '"');
3838
}
3939

40-
$header = new static($value);
41-
42-
return $header;
40+
return new static($value);
4341
}
4442

4543
public function __construct($deltaSeconds = null)
4644
{
47-
if ($deltaSeconds) {
45+
if ($deltaSeconds !== null) {
4846
$this->setDeltaSeconds($deltaSeconds);
4947
}
5048
}
@@ -62,11 +60,11 @@ public function getFieldName()
6260
/**
6361
* Get header value (number of seconds)
6462
*
65-
* @return int
63+
* @return string
6664
*/
6765
public function getFieldValue()
6866
{
69-
return $this->getDeltaSeconds();
67+
return (string) $this->getDeltaSeconds();
7068
}
7169

7270
/**

src/Header/AuthenticationInfo.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ public static function fromString($headerLine)
3131
}
3232

3333
// @todo implementation details
34-
$header = new static($value);
35-
36-
return $header;
34+
return new static($value);
3735
}
3836

3937
public function __construct($value = null)
4038
{
41-
if ($value) {
39+
if ($value !== null) {
4240
HeaderValue::assertValid($value);
4341
$this->value = $value;
4442
}
@@ -51,7 +49,7 @@ public function getFieldName()
5149

5250
public function getFieldValue()
5351
{
54-
return $this->value;
52+
return (string) $this->value;
5553
}
5654

5755
public function toString()

src/Header/Authorization.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ public static function fromString($headerLine)
3131
}
3232

3333
// @todo implementation details
34-
$header = new static($value);
35-
36-
return $header;
34+
return new static($value);
3735
}
3836

3937
public function __construct($value = null)
4038
{
41-
if ($value) {
39+
if ($value !== null) {
4240
HeaderValue::assertValid($value);
4341
$this->value = $value;
4442
}
@@ -51,7 +49,7 @@ public function getFieldName()
5149

5250
public function getFieldValue()
5351
{
54-
return $this->value;
52+
return (string) $this->value;
5553
}
5654

5755
public function toString()

src/Header/ContentDisposition.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ public static function fromString($headerLine)
3131
}
3232

3333
// @todo implementation details
34-
$header = new static($value);
35-
36-
return $header;
34+
return new static($value);
3735
}
3836

3937
public function __construct($value = null)
4038
{
41-
if ($value) {
39+
if ($value !== null) {
4240
HeaderValue::assertValid($value);
4341
$this->value = $value;
4442
}
@@ -51,7 +49,7 @@ public function getFieldName()
5149

5250
public function getFieldValue()
5351
{
54-
return $this->value;
52+
return (string) $this->value;
5553
}
5654

5755
public function toString()

src/Header/ContentEncoding.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ public static function fromString($headerLine)
3030
}
3131

3232
// @todo implementation details
33-
$header = new static($value);
34-
35-
return $header;
33+
return new static($value);
3634
}
3735

3836
public function __construct($value = null)
3937
{
40-
if ($value) {
38+
if ($value !== null) {
4139
HeaderValue::assertValid($value);
4240
$this->value = $value;
4341
}
@@ -50,7 +48,7 @@ public function getFieldName()
5048

5149
public function getFieldValue()
5250
{
53-
return $this->value;
51+
return (string) $this->value;
5452
}
5553

5654
public function toString()

src/Header/ContentLanguage.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ public static function fromString($headerLine)
3131
}
3232

3333
// @todo implementation details
34-
$header = new static($value);
35-
36-
return $header;
34+
return new static($value);
3735
}
3836

3937
public function __construct($value = null)
4038
{
41-
if ($value) {
39+
if ($value !== null) {
4240
HeaderValue::assertValid($value);
4341
$this->value = $value;
4442
}
@@ -51,7 +49,7 @@ public function getFieldName()
5149

5250
public function getFieldValue()
5351
{
54-
return $this->value;
52+
return (string) $this->value;
5553
}
5654

5755
public function toString()

src/Header/ContentLength.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public static function fromString($headerLine)
3131
}
3232

3333
// @todo implementation details
34-
$header = new static($value);
35-
36-
return $header;
34+
return new static($value);
3735
}
3836

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

5250
public function getFieldValue()
5351
{
54-
return $this->value;
52+
return (string) $this->value;
5553
}
5654

5755
public function toString()

src/Header/ContentMD5.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ public static function fromString($headerLine)
2828
}
2929

3030
// @todo implementation details
31-
$header = new static($value);
32-
33-
return $header;
31+
return new static($value);
3432
}
3533

3634
public function __construct($value = null)
3735
{
38-
if ($value) {
36+
if ($value !== null) {
3937
HeaderValue::assertValid($value);
4038
$this->value = $value;
4139
}
@@ -48,7 +46,7 @@ public function getFieldName()
4846

4947
public function getFieldValue()
5048
{
51-
return $this->value;
49+
return (string) $this->value;
5250
}
5351

5452
public function toString()

src/Header/ContentRange.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ public static function fromString($headerLine)
3131
}
3232

3333
// @todo implementation details
34-
$header = new static($value);
35-
36-
return $header;
34+
return new static($value);
3735
}
3836

3937
public function __construct($value = null)
4038
{
41-
if ($value) {
39+
if ($value !== null) {
4240
HeaderValue::assertValid($value);
4341
$this->value = $value;
4442
}
@@ -51,7 +49,7 @@ public function getFieldName()
5149

5250
public function getFieldValue()
5351
{
54-
return $this->value;
52+
return (string) $this->value;
5553
}
5654

5755
public function toString()

0 commit comments

Comments
 (0)