Skip to content

Commit a91a558

Browse files
committed
:octocat: string type cast for trim()
1 parent d65736b commit a91a558

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/HeaderUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function normalize(iterable $headers):array{
103103
public static function trimValues(iterable $values):iterable{
104104

105105
foreach($values as &$value){
106-
$value = trim($value, " \t");
106+
$value = trim((string)($value ?? ''), " \t");
107107
}
108108

109109
return $values;

tests/HeaderUtilTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,8 @@ public function testNormalizeHeaderName(string $name, string $expected):void{
113113
$this::assertSame($expected, HeaderUtil::normalizeHeaderName($name));
114114
}
115115

116+
public function testTrimValues():void{
117+
$this::assertSame(['69', '420'], HeaderUtil::trimValues([69, ' 420 ']));
118+
}
119+
116120
}

0 commit comments

Comments
 (0)