@@ -303,9 +303,7 @@ private function renderAsHex(): string
303303 */
304304 private function shouldRenderInModernSyntax (): bool
305305 {
306- static $ colorFunctionsThatWithMixedValueTypesCannotBeRenderedInLegacySyntax = ['rgb ' , 'rgba ' ];
307- $ colorFunction = $ this ->getRealName ();
308- if (!\in_array ($ colorFunction , $ colorFunctionsThatWithMixedValueTypesCannotBeRenderedInLegacySyntax , true )) {
306+ if (!$ this ->colorFunctionMayHaveMixedValueTypes ($ this ->getRealName ())) {
309307 return false ;
310308 }
311309
@@ -317,7 +315,7 @@ private function shouldRenderInModernSyntax(): bool
317315 // So it is not necessary to check it. It's also always last, hence `break` rather than `continue`.
318316 break ;
319317 }
320- if (!$ value instanceof Size) {
318+ if (!( $ value instanceof Size) ) {
321319 // Unexpected, unknown, or modified via the API
322320 return false ;
323321 }
@@ -336,6 +334,19 @@ private function shouldRenderInModernSyntax(): bool
336334 return $ hasPercentage && $ hasNumber ;
337335 }
338336
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+
339350 /**
340351 * @return non-empty-string
341352 */
0 commit comments