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 @@ -1577,7 +1577,8 @@ public function getLanguages(): array
15771577
15781578 $ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
15791579 $ this ->languages = [];
1580- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1580+ foreach ($ languages as $ acceptHeaderItem ) {
1581+ $ lang = $ acceptHeaderItem ->getValue ();
15811582 if (str_contains ($ lang , '- ' )) {
15821583 $ codes = explode ('- ' , $ lang );
15831584 if ('i ' === $ codes [0 ]) {
@@ -1613,7 +1614,7 @@ public function getCharsets(): array
16131614 return $ this ->charsets ;
16141615 }
16151616
1616- return $ this ->charsets = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ());
1617+ return $ this ->charsets = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all () ));
16171618 }
16181619
16191620 /**
@@ -1625,7 +1626,7 @@ public function getEncodings(): array
16251626 return $ this ->encodings ;
16261627 }
16271628
1628- return $ this ->encodings = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ());
1629+ return $ this ->encodings = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all () ));
16291630 }
16301631
16311632 /**
@@ -1637,7 +1638,7 @@ public function getAcceptableContentTypes(): array
16371638 return $ this ->acceptableContentTypes ;
16381639 }
16391640
1640- return $ this ->acceptableContentTypes = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ());
1641+ return $ this ->acceptableContentTypes = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all () ));
16411642 }
16421643
16431644 /**
Original file line number Diff line number Diff line change @@ -1607,6 +1607,20 @@ public function testGetLanguages()
16071607 $ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
16081608 }
16091609
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+
16101624 public function testGetRequestFormat ()
16111625 {
16121626 $ request = new Request ();
You can’t perform that action at this time.
0 commit comments