@@ -17,7 +17,7 @@ class Size extends PrimitiveValue
1717 /**
1818 * vh/vw/vm(ax)/vmin/rem are absolute insofar as they don’t scale to the immediate parent (only the viewport)
1919 *
20- * @var array<int, string>
20+ * @var list<non-empty- string>
2121 */
2222 private const ABSOLUTE_SIZE_UNITS = [
2323 'px ' ,
@@ -38,17 +38,17 @@ class Size extends PrimitiveValue
3838 ];
3939
4040 /**
41- * @var array<int, string>
41+ * @var list<non-empty- string>
4242 */
4343 private const RELATIVE_SIZE_UNITS = ['% ' , 'em ' , 'ex ' , 'ch ' , 'fr ' ];
4444
4545 /**
46- * @var array<int, string>
46+ * @var list<non-empty- string>
4747 */
4848 private const NON_SIZE_UNITS = ['deg ' , 'grad ' , 'rad ' , 's ' , 'ms ' , 'turn ' , 'Hz ' , 'kHz ' ];
4949
5050 /**
51- * @var array<int, array<string, string>>|null
51+ * @var array<int<1, max>, array<lowercase- string, non-empty- string>>|null
5252 */
5353 private static $ SIZE_UNITS = null ;
5454
@@ -69,11 +69,9 @@ class Size extends PrimitiveValue
6969
7070 /**
7171 * @param float|int|string $size
72- * @param string|null $unit
73- * @param bool $isColorComponent
7472 * @param int<0, max> $lineNumber
7573 */
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 )
7775 {
7876 parent ::__construct ($ lineNumber );
7977 $ this ->size = (float ) $ size ;
@@ -82,14 +80,12 @@ public function __construct($size, $unit = null, $isColorComponent = false, int
8280 }
8381
8482 /**
85- * @param bool $isColorComponent
86- *
8783 * @throws UnexpectedEOFException
8884 * @throws UnexpectedTokenException
8985 *
9086 * @internal since V8.8.0
9187 */
92- public static function parse (ParserState $ parserState , $ isColorComponent = false ): Size
88+ public static function parse (ParserState $ parserState , bool $ isColorComponent = false ): Size
9389 {
9490 $ size = '' ;
9591 if ($ parserState ->comes ('- ' )) {
@@ -125,9 +121,9 @@ public static function parse(ParserState $parserState, $isColorComponent = false
125121 }
126122
127123 /**
128- * @return array<int, array<string, string>>
124+ * @return array<int<1, max>, array<lowercase- string, non-empty- string>>
129125 */
130- private static function getSizeUnits ()
126+ private static function getSizeUnits (): array
131127 {
132128 if (!\is_array (self ::$ SIZE_UNITS )) {
133129 self ::$ SIZE_UNITS = [];
@@ -146,18 +142,12 @@ private static function getSizeUnits()
146142 return self ::$ SIZE_UNITS ;
147143 }
148144
149- /**
150- * @param string $unit
151- */
152- public function setUnit ($ unit ): void
145+ public function setUnit (string $ unit ): void
153146 {
154147 $ this ->unit = $ unit ;
155148 }
156149
157- /**
158- * @return string|null
159- */
160- public function getUnit ()
150+ public function getUnit (): ?string
161151 {
162152 return $ this ->unit ;
163153 }
@@ -170,18 +160,12 @@ public function setSize($size): void
170160 $ this ->size = (float ) $ size ;
171161 }
172162
173- /**
174- * @return float
175- */
176- public function getSize ()
163+ public function getSize (): float
177164 {
178165 return $ this ->size ;
179166 }
180167
181- /**
182- * @return bool
183- */
184- public function isColorComponent ()
168+ public function isColorComponent (): bool
185169 {
186170 return $ this ->isColorComponent ;
187171 }
0 commit comments