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 @@ -1600,7 +1600,8 @@ public function getLanguages(): array
1600
1600
1601
1601
$ languages = AcceptHeader::fromString ($ this ->headers ->get ('Accept-Language ' ))->all ();
1602
1602
$ this ->languages = [];
1603
- foreach ($ languages as $ lang => $ acceptHeaderItem ) {
1603
+ foreach ($ languages as $ acceptHeaderItem ) {
1604
+ $ lang = $ acceptHeaderItem ->getValue ();
1604
1605
if (str_contains ($ lang , '- ' )) {
1605
1606
$ codes = explode ('- ' , $ lang );
1606
1607
if ('i ' === $ codes [0 ]) {
@@ -1638,7 +1639,7 @@ public function getCharsets(): array
1638
1639
return $ this ->charsets ;
1639
1640
}
1640
1641
1641
- return $ this ->charsets = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ());
1642
+ return $ this ->charsets = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all () ));
1642
1643
}
1643
1644
1644
1645
/**
@@ -1652,7 +1653,7 @@ public function getEncodings(): array
1652
1653
return $ this ->encodings ;
1653
1654
}
1654
1655
1655
- return $ this ->encodings = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ());
1656
+ return $ this ->encodings = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all () ));
1656
1657
}
1657
1658
1658
1659
/**
@@ -1666,7 +1667,7 @@ public function getAcceptableContentTypes(): array
1666
1667
return $ this ->acceptableContentTypes ;
1667
1668
}
1668
1669
1669
- return $ this ->acceptableContentTypes = array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ());
1670
+ return $ this ->acceptableContentTypes = array_map ( ' strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all () ));
1670
1671
}
1671
1672
1672
1673
/**
Original file line number Diff line number Diff line change @@ -1629,6 +1629,20 @@ public function testGetLanguages()
1629
1629
$ this ->assertEquals (['zh ' , 'cherokee ' ], $ request ->getLanguages ());
1630
1630
}
1631
1631
1632
+ public function testGetAcceptHeadersReturnString ()
1633
+ {
1634
+ $ request = new Request ();
1635
+ $ request ->headers ->set ('Accept ' , '123 ' );
1636
+ $ request ->headers ->set ('Accept-Charset ' , '123 ' );
1637
+ $ request ->headers ->set ('Accept-Encoding ' , '123 ' );
1638
+ $ request ->headers ->set ('Accept-Language ' , '123 ' );
1639
+
1640
+ $ this ->assertSame (['123 ' ], $ request ->getAcceptableContentTypes ());
1641
+ $ this ->assertSame (['123 ' ], $ request ->getCharsets ());
1642
+ $ this ->assertSame (['123 ' ], $ request ->getEncodings ());
1643
+ $ this ->assertSame (['123 ' ], $ request ->getLanguages ());
1644
+ }
1645
+
1632
1646
public function testGetRequestFormat ()
1633
1647
{
1634
1648
$ request = new Request ();
You can’t perform that action at this time.
0 commit comments