[HttpFoundation] Fixes to new HeaderUtils class

This commit is contained in:
Christian Schmidt 2018-04-23 16:48:54 +02:00 committed by Fabien Potencier
parent 9ae116f9e5
commit d7c3c79042
2 changed files with 6 additions and 6 deletions

View File

@ -43,7 +43,7 @@ class AcceptHeaderItem
$parts = HeaderUtils::split($itemValue, ';=');
$part = array_shift($parts);
$attributes = HeaderUtils::combineParts($parts, 1);
$attributes = HeaderUtils::combineParts($parts);
return new self($part[0], $attributes);
}

View File

@ -31,7 +31,7 @@ class HeaderUtils
* Example:
*
* HeaderUtils::split("da, en-gb;q=0.8", ",;")
* // => array(array("da"), array("en-gb"), array("q", "0.8"))
* // => array(array('da'), array('en-gb', 'q=0.8'))
*
* @param string $header HTTP header value
* @param string $separators List of characters to split on, ordered by
@ -42,7 +42,7 @@ class HeaderUtils
*/
public static function split(string $header, string $separators): array
{
$quotedSeparators = preg_quote($separators);
$quotedSeparators = preg_quote($separators, '/');
preg_match_all('
/
@ -71,7 +71,7 @@ class HeaderUtils
* Each of the nested arrays should have one or two elements. The first
* value will be used as the keys in the associative array, and the second
* will be used as the values, or true if the nested array only contains one
* element.
* element. Array keys are lowercased.
*
* Example:
*
@ -94,13 +94,13 @@ class HeaderUtils
* Joins an associative array into a string for use in an HTTP header.
*
* The key and value of each entry are joined with "=", and all entries
* is joined with the specified separator and an additional space (for
* are joined with the specified separator and an additional space (for
* readability). Values are quoted if necessary.
*
* Example:
*
* HeaderUtils::joinAssoc(array("foo" => "abc", "bar" => true, "baz" => "a b c"), ",")
* // => 'foo=bar, baz, baz="a b c"'
* // => 'foo=abc, bar, baz="a b c"'
*/
public static function joinAssoc(array $assoc, string $separator): string
{