@@ -303,9 +303,7 @@ private function renderAsHex(): string
303
303
*/
304
304
private function shouldRenderInModernSyntax (): bool
305
305
{
306
- static $ colorFunctionsThatWithMixedValueTypesCannotBeRenderedInLegacySyntax = ['rgb ' , 'rgba ' ];
307
- $ colorFunction = $ this ->getRealName ();
308
- if (!\in_array ($ colorFunction , $ colorFunctionsThatWithMixedValueTypesCannotBeRenderedInLegacySyntax , true )) {
306
+ if (!$ this ->colorFunctionMayHaveMixedValueTypes ($ this ->getRealName ())) {
309
307
return false ;
310
308
}
311
309
@@ -317,7 +315,7 @@ private function shouldRenderInModernSyntax(): bool
317
315
// So it is not necessary to check it. It's also always last, hence `break` rather than `continue`.
318
316
break ;
319
317
}
320
- if (!$ value instanceof Size) {
318
+ if (!( $ value instanceof Size) ) {
321
319
// Unexpected, unknown, or modified via the API
322
320
return false ;
323
321
}
@@ -336,6 +334,19 @@ private function shouldRenderInModernSyntax(): bool
336
334
return $ hasPercentage && $ hasNumber ;
337
335
}
338
336
337
+ /**
338
+ * Some color functions, such as `rgb`,
339
+ * may have a mixture of `percentage`, `number`, or possibly other types in their arguments.
340
+ *
341
+ * Note that this excludes the alpha component, which is treated separately.
342
+ */
343
+ private function colorFunctionMayHaveMixedValueTypes (string $ function ): bool
344
+ {
345
+ $ functionsThatMayHaveMixedValueTypes = ['rgb ' , 'rgba ' ];
346
+
347
+ return \in_array ($ function , $ functionsThatMayHaveMixedValueTypes , true );
348
+ }
349
+
339
350
/**
340
351
* @return non-empty-string
341
352
*/
0 commit comments