Skip to content

Commit 575f839

Browse files
committed
Add generic types to traversable implementations
1 parent 2f128ab commit 575f839

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

HeaderBag.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@
1515
* HeaderBag is a container for HTTP headers.
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
18+
*
19+
* @implements \IteratorAggregate<string, array<int, string|null>>
1820
*/
1921
class HeaderBag implements \IteratorAggregate, \Countable
2022
{
2123
protected const UPPER = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ';
2224
protected const LOWER = '-abcdefghijklmnopqrstuvwxyz';
2325

26+
/**
27+
* @var array<string, array<int, string|null>>
28+
*/
2429
protected $headers = [];
2530
protected $cacheControl = [];
2631

@@ -60,7 +65,7 @@ public function __toString()
6065
*
6166
* @param string|null $key The name of the headers to return or null to get them all
6267
*
63-
* @return array
68+
* @return array<string, array<int, string|null>>|array<int, string|null>
6469
*/
6570
public function all(string $key = null)
6671
{
@@ -74,7 +79,7 @@ public function all(string $key = null)
7479
/**
7580
* Returns the parameter keys.
7681
*
77-
* @return array
82+
* @return string[]
7883
*/
7984
public function keys()
8085
{
@@ -250,7 +255,7 @@ public function removeCacheControlDirective(string $key)
250255
/**
251256
* Returns an iterator for headers.
252257
*
253-
* @return \ArrayIterator
258+
* @return \ArrayIterator<string, array<int, string|null>>
254259
*/
255260
#[\ReturnTypeWillChange]
256261
public function getIterator()

ParameterBag.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* ParameterBag is a container for key/value pairs.
1818
*
1919
* @author Fabien Potencier <fabien@symfony.com>
20+
*
21+
* @implements \IteratorAggregate<string, mixed>
2022
*/
2123
class ParameterBag implements \IteratorAggregate, \Countable
2224
{
@@ -205,7 +207,7 @@ public function filter(string $key, $default = null, int $filter = \FILTER_DEFAU
205207
/**
206208
* Returns an iterator for parameters.
207209
*
208-
* @return \ArrayIterator
210+
* @return \ArrayIterator<string, mixed>
209211
*/
210212
#[\ReturnTypeWillChange]
211213
public function getIterator()

Session/Attribute/AttributeBag.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* This class relates to session attribute storage.
16+
*
17+
* @implements \IteratorAggregate<string, mixed>
1618
*/
1719
class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable
1820
{
@@ -129,7 +131,7 @@ public function clear()
129131
/**
130132
* Returns an iterator for attributes.
131133
*
132-
* @return \ArrayIterator
134+
* @return \ArrayIterator<string, mixed>
133135
*/
134136
#[\ReturnTypeWillChange]
135137
public function getIterator()

Session/Attribute/AttributeBagInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function set(string $name, $value);
4646
/**
4747
* Returns attributes.
4848
*
49-
* @return array
49+
* @return array<string, mixed>
5050
*/
5151
public function all();
5252

Session/Session.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class_exists(SessionBagProxy::class);
2626
/**
2727
* @author Fabien Potencier <fabien@symfony.com>
2828
* @author Drak <drak@zikula.org>
29+
*
30+
* @implements \IteratorAggregate<string, mixed>
2931
*/
3032
class Session implements SessionInterface, \IteratorAggregate, \Countable
3133
{
@@ -126,7 +128,7 @@ public function isStarted()
126128
/**
127129
* Returns an iterator for attributes.
128130
*
129-
* @return \ArrayIterator
131+
* @return \ArrayIterator<string, mixed>
130132
*/
131133
#[\ReturnTypeWillChange]
132134
public function getIterator()

0 commit comments

Comments
 (0)