14
14
* Class to manage the headers of translations.
15
15
*
16
16
* @phpstan-consistent-constructor
17
+ *
18
+ * @phpstan-type HeadersType array<string, string>
19
+ *
20
+ * @implements IteratorAggregate<string, string>
17
21
*/
18
22
class Headers implements JsonSerializable, Countable, IteratorAggregate
19
23
{
20
24
public const HEADER_LANGUAGE = 'Language ' ;
21
25
public const HEADER_PLURAL = 'Plural-Forms ' ;
22
26
public const HEADER_DOMAIN = 'X-Domain ' ;
23
27
28
+ /**
29
+ * @var HeadersType
30
+ */
24
31
protected $ headers = [];
25
32
33
+ /**
34
+ * @param array{headers: HeadersType} $state
35
+ */
26
36
public static function __set_state (array $ state ): Headers
27
37
{
28
38
return new static ($ state ['headers ' ]);
29
39
}
30
40
41
+ /**
42
+ * @param HeadersType $headers
43
+ */
31
44
public function __construct (array $ headers = [])
32
45
{
33
46
$ this ->headers = $ headers ;
@@ -115,7 +128,7 @@ public function setPluralForm(int $count, string $rule): self
115
128
/**
116
129
* Returns the parsed plural definition.
117
130
*
118
- * @return array|null [count, rule]
131
+ * @return array{int, string} |null [count, rule]
119
132
*/
120
133
public function getPluralForm (): ?array
121
134
{
@@ -130,6 +143,9 @@ public function getPluralForm(): ?array
130
143
return null ;
131
144
}
132
145
146
+ /**
147
+ * @return HeadersType
148
+ */
133
149
public function toArray (): array
134
150
{
135
151
return $ this ->headers ;
0 commit comments