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 @@ -1689,7 +1689,8 @@ public function getLanguages()
16891689
16901690 $ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
16911691 $ this ->languages = [];
1692- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1692+ foreach ($ languages as $ acceptHeaderItem ) {
1693+ $ lang = $ acceptHeaderItem ->getValue ();
16931694 if (str_contains ($ lang , '- ' )) {
16941695 $ codes = explode ('- ' , $ lang );
16951696 if ('i ' === $ codes [0 ]) {
@@ -1727,7 +1728,7 @@ public function getCharsets()
17271728 return $ this ->charsets ;
17281729 }
17291730
1730- return $ this ->charsets = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ());
1731+ return $ this ->charsets = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all () ));
17311732 }
17321733
17331734 /**
@@ -1741,7 +1742,7 @@ public function getEncodings()
17411742 return $ this ->encodings ;
17421743 }
17431744
1744- return $ this ->encodings = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ());
1745+ return $ this ->encodings = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all () ));
17451746 }
17461747
17471748 /**
@@ -1755,7 +1756,7 @@ public function getAcceptableContentTypes()
17551756 return $ this ->acceptableContentTypes ;
17561757 }
17571758
1758- return $ this ->acceptableContentTypes = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ());
1759+ return $ this ->acceptableContentTypes = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all () ));
17591760 }
17601761
17611762 /**
Original file line number Diff line number Diff line change @@ -1610,6 +1610,20 @@ public function testGetLanguages()
16101610 $ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
16111611 }
16121612
1613+ public function testGetAcceptHeadersReturnString ()
1614+ {
1615+ $ request = new Request ();
1616+ $ request ->headers ->set ('Accept ' , '123 ' );
1617+ $ request ->headers ->set ('Accept-Charset ' , '123 ' );
1618+ $ request ->headers ->set ('Accept-Encoding ' , '123 ' );
1619+ $ request ->headers ->set ('Accept-Language ' , '123 ' );
1620+
1621+ $ this ->assertSame (['123 ' ], $ request ->getAcceptableContentTypes ());
1622+ $ this ->assertSame (['123 ' ], $ request ->getCharsets ());
1623+ $ this ->assertSame (['123 ' ], $ request ->getEncodings ());
1624+ $ this ->assertSame (['123 ' ], $ request ->getLanguages ());
1625+ }
1626+
16131627 public function testGetRequestFormat ()
16141628 {
16151629 $ request = new Request ();
You can’t perform that action at this time.
0 commit comments