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
15751575
15761576 $ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
15771577 $ this ->languages = [];
1578- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1578+ foreach ($ languages as $ acceptHeaderItem ) {
1579+ $ lang = $ acceptHeaderItem ->getValue ();
15791580 if (str_contains ($ lang , '- ' )) {
15801581 $ codes = explode ('- ' , $ lang );
15811582 if ('i ' === $ codes [0 ]) {
@@ -1611,7 +1612,7 @@ public function getCharsets(): array
16111612 return $ this ->charsets ;
16121613 }
16131614
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 () ));
16151616 }
16161617
16171618 /**
@@ -1623,7 +1624,7 @@ public function getEncodings(): array
16231624 return $ this ->encodings ;
16241625 }
16251626
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 () ));
16271628 }
16281629
16291630 /**
@@ -1635,7 +1636,7 @@ public function getAcceptableContentTypes(): array
16351636 return $ this ->acceptableContentTypes ;
16361637 }
16371638
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 () ));
16391640 }
16401641
16411642 /**
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