You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@trigger_error(sprintf('%s::%s is deprecated since Symfony 4.4, use %s::getFirst() or %s::getAll() instead.', __CLASS__, __METHOD__, __CLASS__, __CLASS__), E_USER_DEPRECATED);
113
-
if (true === $first) {
114
-
return$this->getFirst($key, $default);
115
-
}
112
+
$all = $this->getValues($key, $default);
116
113
117
-
return$this->getAll($key, $default);
118
-
}
114
+
if (true === $first) {
119
115
120
-
publicfunctiongetFirst($key, $default = null)
121
-
{
122
-
$all = $this->getAll($key, $default);
116
+
if (\count($all)) {
117
+
returnisset($all[0]) ? $all[0] : $default;
118
+
}
123
119
124
-
if (\count($all)) {
125
-
returnisset($all[0]) ? $all[0] : null;
120
+
return$default;
126
121
}
127
122
128
-
return$default;
123
+
@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::gets() instead to get an array of values.', __METHOD__, __CLASS__), E_USER_DEPRECATED);
$this->assertEquals(['default'], $bag->getValues('none', 'default'), '->get unknown values returns default as array');
100
98
101
99
$bag->set('foo', 'bor', false);
102
100
$this->assertEquals('bar', $bag->get('foo'), '->get return first value');
103
-
$this->assertEquals($bag->getAll('foo', 'nope'), $bag->get('foo', 'nope', false), '->get return all values as array');
104
101
105
-
$this->assertEquals(['bar', 'bor'], $bag->get('foo', 'nope', false), '->get return all values as array');
102
+
$this->assertEquals(['bar', 'bor'], $bag->getValues('foo', 'nope'), '->get return all values as array');
103
+
}
104
+
105
+
/**
106
+
* @group legacy
107
+
* @expectedDeprecation Passing $first as a third argument is deprecated since Symfony 4.4 and will be removed in Symfony 5.0. Symfony\Component\HttpFoundation\HeaderBag::get will return the first header value, use Symfony\Component\HttpFoundation\HeaderBag::gets() instead to get an array of values.
0 commit comments