File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -1575,7 +1575,8 @@ public function getLanguages(): array
1575
1575
1576
1576
$ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
1577
1577
$ this ->languages = [];
1578
- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1578
+ foreach ($ languages as $ acceptHeaderItem ) {
1579
+ $ lang = $ acceptHeaderItem ->getValue ();
1579
1580
if (str_contains ($ lang , '- ' )) {
1580
1581
$ codes = explode ('- ' , $ lang );
1581
1582
if ('i ' === $ codes [0 ]) {
@@ -1611,7 +1612,7 @@ public function getCharsets(): array
1611
1612
return $ this ->charsets ;
1612
1613
}
1613
1614
1614
- return $ this ->charsets = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ());
1615
+ return $ this ->charsets = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all () ));
1615
1616
}
1616
1617
1617
1618
/**
@@ -1623,7 +1624,7 @@ public function getEncodings(): array
1623
1624
return $ this ->encodings ;
1624
1625
}
1625
1626
1626
- return $ this ->encodings = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ());
1627
+ return $ this ->encodings = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all () ));
1627
1628
}
1628
1629
1629
1630
/**
@@ -1635,7 +1636,7 @@ public function getAcceptableContentTypes(): array
1635
1636
return $ this ->acceptableContentTypes ;
1636
1637
}
1637
1638
1638
- return $ this ->acceptableContentTypes = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ());
1639
+ return $ this ->acceptableContentTypes = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all () ));
1639
1640
}
1640
1641
1641
1642
/**
Original file line number Diff line number Diff line change @@ -1607,6 +1607,20 @@ public function testGetLanguages()
1607
1607
$ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
1608
1608
}
1609
1609
1610
+ public function testGetAcceptHeadersReturnString ()
1611
+ {
1612
+ $ request = new Request ();
1613
+ $ request ->headers ->set ('Accept ' , '123 ' );
1614
+ $ request ->headers ->set ('Accept-Charset ' , '123 ' );
1615
+ $ request ->headers ->set ('Accept-Encoding ' , '123 ' );
1616
+ $ request ->headers ->set ('Accept-Language ' , '123 ' );
1617
+
1618
+ $ this ->assertSame (['123 ' ], $ request ->getAcceptableContentTypes ());
1619
+ $ this ->assertSame (['123 ' ], $ request ->getCharsets ());
1620
+ $ this ->assertSame (['123 ' ], $ request ->getEncodings ());
1621
+ $ this ->assertSame (['123 ' ], $ request ->getLanguages ());
1622
+ }
1623
+
1610
1624
public function testGetRequestFormat ()
1611
1625
{
1612
1626
$ request = new Request ();
You can’t perform that action at this time.
0 commit comments