@@ -17,7 +17,7 @@ class Size extends PrimitiveValue
17
17
/**
18
18
* vh/vw/vm(ax)/vmin/rem are absolute insofar as they don’t scale to the immediate parent (only the viewport)
19
19
*
20
- * @var array<int, string>
20
+ * @var list<non-empty- string>
21
21
*/
22
22
private const ABSOLUTE_SIZE_UNITS = [
23
23
'px ' ,
@@ -38,17 +38,17 @@ class Size extends PrimitiveValue
38
38
];
39
39
40
40
/**
41
- * @var array<int, string>
41
+ * @var list<non-empty- string>
42
42
*/
43
43
private const RELATIVE_SIZE_UNITS = ['% ' , 'em ' , 'ex ' , 'ch ' , 'fr ' ];
44
44
45
45
/**
46
- * @var array<int, string>
46
+ * @var list<non-empty- string>
47
47
*/
48
48
private const NON_SIZE_UNITS = ['deg ' , 'grad ' , 'rad ' , 's ' , 'ms ' , 'turn ' , 'Hz ' , 'kHz ' ];
49
49
50
50
/**
51
- * @var array<int, array<string, string>>|null
51
+ * @var array<int<1, max>, array<lowercase- string, non-empty- string>>|null
52
52
*/
53
53
private static $ SIZE_UNITS = null ;
54
54
@@ -69,11 +69,9 @@ class Size extends PrimitiveValue
69
69
70
70
/**
71
71
* @param float|int|string $size
72
- * @param string|null $unit
73
- * @param bool $isColorComponent
74
72
* @param int<0, max> $lineNumber
75
73
*/
76
- public function __construct ($ size , $ unit = null , $ isColorComponent = false , int $ lineNumber = 0 )
74
+ public function __construct ($ size , ? string $ unit = null , bool $ isColorComponent = false , int $ lineNumber = 0 )
77
75
{
78
76
parent ::__construct ($ lineNumber );
79
77
$ this ->size = (float ) $ size ;
@@ -82,14 +80,12 @@ public function __construct($size, $unit = null, $isColorComponent = false, int
82
80
}
83
81
84
82
/**
85
- * @param bool $isColorComponent
86
- *
87
83
* @throws UnexpectedEOFException
88
84
* @throws UnexpectedTokenException
89
85
*
90
86
* @internal since V8.8.0
91
87
*/
92
- public static function parse (ParserState $ parserState , $ isColorComponent = false ): Size
88
+ public static function parse (ParserState $ parserState , bool $ isColorComponent = false ): Size
93
89
{
94
90
$ size = '' ;
95
91
if ($ parserState ->comes ('- ' )) {
@@ -125,9 +121,9 @@ public static function parse(ParserState $parserState, $isColorComponent = false
125
121
}
126
122
127
123
/**
128
- * @return array<int, array<string, string>>
124
+ * @return array<int<1, max>, array<lowercase- string, non-empty- string>>
129
125
*/
130
- private static function getSizeUnits ()
126
+ private static function getSizeUnits (): array
131
127
{
132
128
if (!\is_array (self ::$ SIZE_UNITS )) {
133
129
self ::$ SIZE_UNITS = [];
@@ -146,18 +142,12 @@ private static function getSizeUnits()
146
142
return self ::$ SIZE_UNITS ;
147
143
}
148
144
149
- /**
150
- * @param string $unit
151
- */
152
- public function setUnit ($ unit ): void
145
+ public function setUnit (string $ unit ): void
153
146
{
154
147
$ this ->unit = $ unit ;
155
148
}
156
149
157
- /**
158
- * @return string|null
159
- */
160
- public function getUnit ()
150
+ public function getUnit (): ?string
161
151
{
162
152
return $ this ->unit ;
163
153
}
@@ -170,18 +160,12 @@ public function setSize($size): void
170
160
$ this ->size = (float ) $ size ;
171
161
}
172
162
173
- /**
174
- * @return float
175
- */
176
- public function getSize ()
163
+ public function getSize (): float
177
164
{
178
165
return $ this ->size ;
179
166
}
180
167
181
- /**
182
- * @return bool
183
- */
184
- public function isColorComponent ()
168
+ public function isColorComponent (): bool
185
169
{
186
170
return $ this ->isColorComponent ;
187
171
}
0 commit comments