8000 minor #27087 [HttpFoundation] Rename HeaderUtils methods (c960657) · symfony/symfony@295eaed · GitHub
[go: up one dir, main page]

Skip to content

Commit 295eaed

Browse files
committed
minor #27087 [HttpFoundation] Rename HeaderUtils methods (c960657)
This PR was merged into the 4.1-dev branch. Discussion ---------- [HttpFoundation] Rename HeaderUtils methods | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27026 | License | MIT | Doc PR | Rename new HeaderUtils methods as discussed in #27026. Commits ------- 484d1fb [HttpFoundation] Rename HeaderUtils methods
2 parents 5a5b925 + 484d1fb commit 295eaed

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

src/Symfony/Component/HttpFoundation/AcceptHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function fromString($headerValue)
5656

5757
return new self(array_map(function ($subParts) use (&$index) {
5858
$part = array_shift($subParts);
59-
$attributes = HeaderUtils::combineParts($subParts);
59+
$attributes = HeaderUtils::combine($subParts);
6060

6161
$item = new AcceptHeaderItem($part[0], $attributes);
6262
$item->setIndex($index++);

src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function fromString($itemValue)
4343
$parts = HeaderUtils::split($itemValue, ';=');
4444

4545
$part = array_shift($parts);
46-
$attributes = HeaderUtils::combineParts($parts);
46+
$attributes = HeaderUtils::combine($parts);
4747

4848
return new self($part[0], $attributes);
4949
}
@@ -57,7 +57,7 @@ public function __toString()
5757
{
5858
$string = $this->value.($this->quality < 1 ? ';q='.$this->quality : '');
5959
if (count($this->attributes) > 0) {
60-
$string .= '; '.HeaderUtils::joinAssoc($this->attributes, ';');
60+
$string .= '; '.HeaderUtils::toString($this->attributes, ';');
6161
}
6262

6363
return $string;

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function prepare(Request $request)
219219
// Do X-Accel-Mapping substitutions.
220220
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
221221
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
222-
$mappings = HeaderUtils::combineParts($parts);
222+
$mappings = HeaderUtils::combine($parts);
223223
foreach ($mappings as $pathPrefix => $location) {
224224
if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) {
225225
$path = $location.substr($path, strlen($pathPrefix));

src/Symfony/Component/HttpFoundation/Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function fromString($cookie, $decode = false)
5757
$name = $decode ? urldecode($part[0]) : $part[0];
5858
$value = isset($part[1]) ? ($decode ? urldecode($part[1]) : $part[1]) : null;
5959

60-
$data = HeaderUtils::combineParts($parts) + $data;
60+
$data = HeaderUtils::combine($parts) + $data;
6161

6262
if (isset($data['max-age'])) {
6363
$data['expires'] = time() + (int) $data['max-age'];

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ protected function getCacheControlHeader()
296296
{
297297
ksort($this->cacheControl);
298298

299-
return HeaderUtils::joinAssoc($this->cacheControl, ',');
299+
return HeaderUtils::toString($this->cacheControl, ',');
300300
}
301301

302302
/**
@@ -310,6 +310,6 @@ protected function parseCacheControl($header)
310310
{
311311
$parts = HeaderUtils::split($header, ',=');
312312

313-
return HeaderUtils::combineParts($parts);
313+
return HeaderUtils::combine($parts);
314314
}
315315
}

src/Symfony/Component/HttpFoundation/HeaderUtils.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public static function split(string $header, string $separators): array
7575
*
7676
* Example:
7777
*
78-
* HeaderUtils::combineParts(array(array("foo", "abc"), array("bar")))
78+
* HeaderUtils::combine(array(array("foo", "abc"), array("bar")))
7979
* // => array("foo" => "abc", "bar" => true)
8080
*/
81-
public static function combineParts(array $parts): array
81+
public static function combine(array $parts): array
8282
{
8383
$assoc = array();
8484
foreach ($parts as $part) {
@@ -99,10 +99,10 @@ public static function combineParts(array $parts): array
9999
*
100100
* Example:
101101
*
102-
* HeaderUtils::joinAssoc(array("foo" => "abc", "bar" => true, "baz" => "a b c"), ",")
102+
* HeaderUtils::toString(array("foo" => "abc", "bar" => true, "baz" => "a b c"), ",")
103103
* // => 'foo=abc, bar, baz="a b c"'
104104
*/
105-
public static function joinAssoc(array $assoc, string $separator): string
105+
public static function toString(array $assoc, string $separator): string
106106
{
107107
$parts = array();
108108
foreach ($assoc as $name => $value) {

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,7 @@ private function getTrustedValues($type, $ip = null)
19491949
$forwardedValues = array();
19501950
$param = self::$forwardedParams[$type];
19511951
foreach ($parts as $subParts) {
1952-
$assoc = HeaderUtils::combineParts($subParts);
1952+
$assoc = HeaderUtils::combine($subParts);
19531953
if (isset($assoc[$param])) {
19541954
$forwardedValues[] = $assoc[$param];
19551955
}

src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public function makeDisposition($disposition, $filename, $filenameFallback = '')
295295
$params['filename*'] = "utf-8''".rawurlencode($filename);
296296
}
297297

298-
return $disposition.'; '.HeaderUtils::joinAssoc($params, ';');
298+
return $disposition.'; '.HeaderUtils::toString($params, ';');
299299
}
300300

301301
/**

src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ public function testSplit()
4545
$this->assertSame(array('foo', 'bar, baz\\'), HeaderUtils::split('foo, "bar, baz\\\\', ','));
4646
}
4747

48-
public function testCombineAssoc()
48+
public function testCombine()
4949
{
50-
$this->assertSame(array('foo' => '123'), HeaderUtils::combineParts(array(array('foo', '123'))));
51-
$this->assertSame(array('foo' => true), HeaderUtils::combineParts(array(array('foo'))));
52-
$this->assertSame(array('foo' => true), HeaderUtils::combineParts(array(array('Foo'))));
53-
$this->assertSame(array('foo' => '123', 'bar' => true), HeaderUtils::combineParts(array(array('foo', '123'), array('bar'))));
50+
$this->assertSame(array('foo' => '123'), HeaderUtils::combine(array(array('foo', '123'))));
51+
$this->assertSame(array('foo' => true), HeaderUtils::combine(array(array('foo'))));
52+
$this->assertSame(array('foo' => true), HeaderUtils::combine(array(array('Foo'))));
53+
$this->assertSame(array('foo' => '123', 'bar' => true), HeaderUtils::combine(array(array('foo', '123'), array('bar'))));
5454
}
5555

56-
public function testJoinAssoc()
56+
public function testToString()
5757
{
58-
$this->assertSame('foo', HeaderUtils::joinAssoc(array('foo' => true), ','));
59-
$this->assertSame('foo; bar', HeaderUtils::joinAssoc(array('foo' => true, 'bar' => true), ';'));
60-
$this->assertSame('foo=123', HeaderUtils::joinAssoc(array('foo' => '123'), ','));
61-
$this->assertSame('foo="1 2 3"', HeaderUtils::joinAssoc(array('foo' => '1 2 3'), ','));
62-
$this->assertSame('foo="1 2 3", bar', HeaderUtils::joinAssoc(array('foo' => '1 2 3', 'bar' => true), ','));
58+
$this->assertSame('foo', HeaderUtils::toString(array('foo' => true), ','));
59+
$this->assertSame('foo; bar', HeaderUtils::toString(array('foo' => true, 'bar' => true), ';'));
60+
$this->assertSame('foo=123', HeaderUtils::toString(array('foo' => '123'), ','));
61+
$this->assertSame('foo="1 2 3"', HeaderUtils::toString(array('foo' => '1 2 3'), ','));
62+
$this->assertSame('foo="1 2 3", bar', HeaderUtils::toString(array('foo' => '1 2 3', 'bar' => true), ','));
6363
}
6464

6565
public function testQuote()

0 commit comments

Comments
 (0)
0