File tree 2 files changed +19
-4
lines changed
2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -1646,7 +1646,8 @@ public function getLanguages()
1646
1646
1647
1647
$ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
1648
1648
$ this ->languages = [];
1649
- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1649
+ foreach ($ languages as $ acceptHeaderItem ) {
1650
+ $ lang = $ acceptHeaderItem ->getValue ();
1650
1651
if (str_contains ($ lang , '- ' )) {
1651
1652
$ codes = explode ('- ' , $ lang );
1652
1653
if ('i ' === $ codes [0 ]) {
@@ -1684,7 +1685,7 @@ public function getCharsets()
1684
1685
return $ this ->charsets ;
1685
1686
}
1686
1687
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 () ));
1688
1689
}
1689
1690
1690
1691
/**
@@ -1698,7 +1699,7 @@ public function getEncodings()
1698
1699
return $ this ->encodings ;
1699
1700
}
1700
1701
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 () ));
1702
1703
}
1703
1704
1704
1705
/**
@@ -1712,7 +1713,7 @@ public function getAcceptableContentTypes()
1712
1713
return $ this ->acceptableContentTypes ;
1713
1714
}
1714
1715
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 () ));
1716
1717
}
1717
1718
1718
1719
/**
Original file line number Diff line number Diff line change @@ -1582,6 +1582,20 @@ public function testGetLanguages()
1582
1582
$ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
1583
1583
}
1584
1584
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
+
1585
1599
public function testGetRequestFormat ()
1586
1600
{
1587
1601
$ request = new Request ();
You can’t perform that action at this time.
0 commit comments