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 @@ -1646,7 +1646,8 @@ public function getLanguages()
16461646
16471647 $ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
16481648 $ this ->languages = [];
1649- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1649+ foreach ($ languages as $ acceptHeaderItem ) {
1650+ $ lang = $ acceptHeaderItem ->getValue ();
16501651 if (str_contains ($ lang , '- ' )) {
16511652 $ codes = explode ('- ' , $ lang );
16521653 if ('i ' === $ codes [0 ]) {
@@ -1684,7 +1685,7 @@ public function getCharsets()
16841685 return $ this ->charsets ;
16851686 }
16861687
1687- return $ this ->charsets = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ());
1688+ return $ this ->charsets = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all () ));
16881689 }
16891690
16901691 /**
@@ -1698,7 +1699,7 @@ public function getEncodings()
16981699 return $ this ->encodings ;
16991700 }
17001701
1701- return $ this ->encodings = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ());
1702+ return $ this ->encodings = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all () ));
17021703 }
17031704
17041705 /**
@@ -1712,7 +1713,7 @@ public function getAcceptableContentTypes()
17121713 return $ this ->acceptableContentTypes ;
17131714 }
17141715
1715- return $ this ->acceptableContentTypes = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ());
1716+ return $ this ->acceptableContentTypes = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all () ));
17161717 }
17171718
17181719 /**
Original file line number Diff line number Diff line change @@ -1582,6 +1582,20 @@ public function testGetLanguages()
15821582 $ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
15831583 }
15841584
1585+ public function testGetAcceptHeadersReturnString ()
1586+ {
1587+ $ request = new Request ();
1588+ $ request ->headers ->set ('Accept ' , '123 ' );
1589+ $ request ->headers ->set ('Accept-Charset ' , '123 ' );
1590+ $ request ->headers ->set ('Accept-Encoding ' , '123 ' );
1591+ $ request ->headers ->set ('Accept-Language ' , '123 ' );
1592+
1593+ $ this ->assertSame (['123 ' ], $ request ->getAcceptableContentTypes ());
1594+ $ this ->assertSame (['123 ' ], $ request ->getCharsets ());
1595+ $ this ->assertSame (['123 ' ], $ request ->getEncodings ());
1596+ $ this ->assertSame (['123 ' ], $ request ->getLanguages ());
1597+ }
1598+
15851599 public function testGetRequestFormat ()
15861600 {
15871601 $ request = new Request ();
You can’t perform that action at this time.
0 commit comments