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 @@ -1689,7 +1689,8 @@ public function getLanguages()
1689
1689
1690
1690
$ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
1691
1691
$ this ->languages = [];
1692
- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1692
+ foreach ($ languages as $ acceptHeaderItem ) {
1693
+ $ lang = $ acceptHeaderItem ->getValue ();
1693
1694
if (str_contains ($ lang , '- ' )) {
1694
1695
$ codes = explode ('- ' , $ lang );
1695
1696
if ('i ' === $ codes [0 ]) {
@@ -1727,7 +1728,7 @@ public function getCharsets()
1727
1728
return $ this ->charsets ;
1728
1729
}
1729
1730
1730
- return $ this ->charsets = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ());
1731
+ return $ this ->charsets = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all () ));
1731
1732
}
1732
1733
1733
1734
/**
@@ -1741,7 +1742,7 @@ public function getEncodings()
1741
1742
return $ this ->encodings ;
1742
1743
}
1743
1744
1744
- return $ this ->encodings = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ());
1745
+ return $ this ->encodings = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all () ));
1745
1746
}
1746
1747
1747
1748
/**
@@ -1755,7 +1756,7 @@ public function getAcceptableContentTypes()
1755
1756
return $ this ->acceptableContentTypes ;
1756
1757
}
1757
1758
1758
- return $ this ->acceptableContentTypes = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ());
1759
+ return $ this ->acceptableContentTypes = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all () ));
1759
1760
}
1760
1761
1761
1762
/**
Original file line number Diff line number Diff line change @@ -1610,6 +1610,20 @@ public function testGetLanguages()
1610
1610
$ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
1611
1611
}
1612
1612
1613
+ public function testGetAcceptHeadersReturnString ()
1614
+ {
1615
+ $ request = new Request ();
1616
+ $ request ->headers ->set ('Accept ' , '123 ' );
1617
+ $ request ->headers ->set ('Accept-Charset ' , '123 ' );
1618
+ $ request ->headers ->set ('Accept-Encoding ' , '123 ' );
1619
+ $ request ->headers ->set ('Accept-Language ' , '123 ' );
1620
+
1621
+ $ this ->assertSame (['123 ' ], $ request ->getAcceptableContentTypes ());
1622
+ $ this ->assertSame (['123 ' ], $ request ->getCharsets ());
1623
+ $ this ->assertSame (['123 ' ], $ request ->getEncodings ());
1624
+ $ this ->assertSame (['123 ' ], $ request ->getLanguages ());
1625
+ }
1626
+
1613
1627
public function testGetRequestFormat ()
1614
1628
{
1615
1629
$ request = new Request ();
You can’t perform that action at this time.
0 commit comments