Skip to content

Commit d47783a

Browse files
committed
fi
1 parent 5b2744e commit d47783a

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,18 @@ public function add(array $headers)
109109
*/
110110
public function get($key, $default = null)
111111
{
112-
$all = $this->getValues($key, $default);
112+
$all = $this->getValues($key);
113113

114-
if (\count(func_get_args()) === 3 && false === func_get_arg(2)) {
115-
@trigger_error(sprintf('Passing $first as a third argument is deprecated since Symfony 4.4 and will be removed in Symfony 5.0. %s will return the first header value, use %s::getValues() instead to get an array of values.', __METHOD__, __CLASS__), E_USER_DEPRECATED);
114+
if (3 === \count(\func_get_args()) && false === func_get_arg(2)) {
115+
@trigger_error(sprintf('Passing $first as a third argument is deprecated since Symfony 4.4 and will be removed in Symfony 5.0. %s will return the first header value, use %s::getValues() instead to get an array of values.', __METHOD__, __CLASS__), E_USER_DEPRECATED);
116116

117117
return $all;
118118
}
119-
if (\count($all)) {
120-
return isset($all[0]) ? $all[0] : $default;
121-
}
122-
123-
return $default;
124-
125-
119+
if (\count($all)) {
120+
return isset($all[0]) ? $all[0] : $default;
121+
}
126122

123+
return $default;
127124
}
128125

129126
/**
@@ -135,7 +132,7 @@ public function getValues(string $key): array
135132
$headers = $this->all();
136133

137134
if (!\array_key_exists($key, $headers)) {
138-
return [];
135+
return [];
139136
}
140137

141138
return $headers[$key];
@@ -195,7 +192,7 @@ public function has($key)
195192
*/
196193
public function contains($key, $value)
197194
{
198-
return \in_array($value, $this->getValues($key, null));
195+
return \in_array($value, $this->getValues($key));
199196
}
200197

201198
/**

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ public function hasVary(): bool
10241024
*/
10251025
public function getVary(): array
10261026
{
1027-
if (!$vary = $this->headers->getValues('Vary', null)) {
1027+
if (!$vary = $this->headers->getValues('Vary')) {
10281028
return [];
10291029
}
10301030

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ public function testGet()
8888
$bag = new HeaderBag(['foo' => 'bar', 'fuzz' => 'bizz']);
8989
$this->assertEquals('bar', $bag->get('foo'), '->get return current value');
9090
$this->assertEquals('bar', $bag->get('FoO'), '->get key in case insensitive');
91-
$this->assertEquals(['bar'], $bag->getValues('foo', 'nope'), '->get return the value as array');
91+
$this->assertEquals(['bar'], $bag->getValues('foo'), '->get return the value as array');
9292

9393
// defaults
9494
$this->assertNull($bag->get('none'), '->get unknown values returns null');
9595
$this->assertEquals('default', $bag->get('none', 'default'), '->get unknown values returns default');
9696

97-
$this->assertEquals(['default'], $bag->getValues('none', 'default'), '->get unknown values returns default as array');
97+
$this->assertEquals([''], $bag->getValues('none', 'default'), '->get unknown values returns an empty array');
9898

9999
$bag->set('foo', 'bor', false);
100100
$this->assertEquals('bar', $bag->get('foo'), '->get return first value');
101101

102-
$this->assertEquals(['bar', 'bor'], $bag->getValues('foo', 'nope'), '->get return all values as array');
102+
$this->assertEquals(['bar', 'bor'], $bag->getValues('foo'), '->get return all values as array');
103103
}
104104

105105
/**
@@ -110,15 +110,15 @@ public function testGetIsEqualToNewMethod()
110110
{
111111
$bag = new HeaderBag(['foo' => 'bar', 'fuzz' => 'bizz']);
112112
$this->assertEquals($bag->get('none', 'default'), $bag->get('none', 'default'), '->get unknown values returns default as array');
113-
$this->assertEquals($bag->getValues('none', 'default'), $bag->get('none', 'default', false), '->get unknown values returns default as array');
113+
$this->assertEquals($bag->getValues('none'), $bag->get('none', [], false), '->get unknown values returns default as array');
114114
}
115115

116116
public function testSetAssociativeArray()
117117
{
118118
$bag = new HeaderBag();
119119
$bag->set('foo', ['bad-assoc-index' => 'value']);
120120
$this->assertSame('value', $bag->get('foo'));
121-
$this->assertEquals(['value'], $bag->getValues('foo', 'nope'), 'assoc indices of multi-valued headers are ignored');
121+
$this->assertEquals(['value'], $bag->getValues('foo'), 'assoc indices of multi-valued headers are ignored');
122122
}
123123

124124
public function testContains()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ public function testCacheControlHeader()
8989

9090
$bag = new ResponseHeaderBag();
9191
$bag->set('Cache-Control', ['public', 'must-revalidate']);
92-
$this->assertCount(1, $bag->getValues('Cache-Control', null));
92+
$this->assertCount(1, $bag->getValues('Cache-Control'));
9393
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
9494

9595
$bag = new ResponseHeaderBag();
9696
$bag->set('Cache-Control', 'public');
9797
$bag->set('Cache-Control', 'must-revalidate', false);
98-
$this->assertCount(1, $bag->getValues('Cache-Control', null));
98+
$this->assertCount(1, $bag->getValues('Cache-Control'));
9999
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
100100
}
101101

@@ -166,7 +166,7 @@ public function testCookiesWithSameNames()
166166
'foo=bar; path=/path/bar; domain=foo.bar; httponly; samesite=lax',
167167
'foo=bar; path=/path/bar; domain=bar.foo; httponly; samesite=lax',
168168
'foo=bar; path=/; httponly; samesite=lax',
169-
], $bag->getValues('set-cookie', null));
169+
], $bag->getValues('set-cookie'));
170170

171171
$this->assertSetCookieHeader('foo=bar; path=/path/foo; domain=foo.bar; httponly; samesite=lax', $bag);
172172
$this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=foo.bar; httponly; samesite=lax', $bag);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy