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
1577
1577
1578
1578
$ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
1579
1579
$ this ->languages = [];
1580
- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1580
+ foreach ($ languages as $ acceptHeaderItem ) {
1581
+ $ lang = $ acceptHeaderItem ->getValue ();
1581
1582
if (str_contains ($ lang , '- ' )) {
1582
1583
$ codes = explode ('- ' , $ lang );
1583
1584
if ('i ' === $ codes [0 ]) {
@@ -1613,7 +1614,7 @@ public function getCharsets(): array
1613
1614
return $ this ->charsets ;
1614
1615
}
1615
1616
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 () ));
1617
1618
}
1618
1619
1619
1620
/**
@@ -1625,7 +1626,7 @@ public function getEncodings(): array
1625
1626
return $ this ->encodings ;
1626
1627
}
1627
1628
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 () ));
1629
1630
}
1630
1631
1631
1632
/**
@@ -1637,7 +1638,7 @@ public function getAcceptableContentTypes(): array
1637
1638
return $ this ->acceptableContentTypes ;
1638
1639
}
1639
1640
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 () ));
1641
1642
}
1642
1643
1643
1644
/**
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