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

Commit 94f1ac7

Browse files
committed
Merge branch 'hotfix/204' into develop
Forward port #204
2 parents 550b717 + c171d4d commit 94f1ac7

39 files changed

+271
-182
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ All notable changes to this project will be documented in this file, in reverse
4444

4545
### Fixed
4646

47-
- Nothing.
47+
- [#204](https://github.com/zendframework/zend-http/pull/204) fixes numerous header classes to cast field value to string (since `HeaderInterface::getFieldValue()` specifies a return value of a string).
4848

4949
## 2.11.0 - 2019-12-03
5050

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()

src/Header/ContentTransferEncoding.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(strtolower($value));
35-
36-
return $header;
34+
return new static(strtolower($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/ContentType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function fromString($headerLine)
6969

7070
public function __construct($value = null, $mediaType = null)
7171
{
72-
if ($value) {
72+
if ($value !== null) {
7373
HeaderValue::assertValid($value);
7474
$this->value = $value;
7575
}
@@ -146,7 +146,7 @@ public function getFieldName()
146146
public function getFieldValue()
147147
{
148148
if (null !== $this->value) {
149-
return $this->value;
149+
return (string) $this->value;
150150
}
151151
return $this->assembleValue();
152152
}
@@ -172,7 +172,7 @@ public function setMediaType($mediaType)
172172
*/
173173
public function getMediaType()
174174
{
175-
return $this->mediaType;
175+
return (string) $this->mediaType;
176176
}
177177

178178
/**

src/Header/Etag.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/Expect.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/From.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()

0 commit comments

Comments
 (0)