Skip to content

Commit 7814474

Browse files
committed
Changes suggested in code review.
1 parent 415212a commit 7814474

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

config/php-cs-fixer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,8 @@
9696
// string notation
9797
'single_quote' => true,
9898
'string_implicit_backslashes' => ['single_quoted' => 'escape'],
99+
100+
// whitespace
101+
'statement_indentation' => false,
99102
]
100103
);

src/Value/Color.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
7676
// So, attempt to parse with the `a`, and allow for it not being there.
7777
switch ($sColorMode) {
7878
case 'rgb':
79+
$colorModeForParsing = 'rgba';
80+
$mayHaveOptionalAlpha = true;
81+
break;
7982
case 'hsl':
80-
$colorModeForParsing = $sColorMode . 'a';
83+
$colorModeForParsing = 'hsla';
8184
$mayHaveOptionalAlpha = true;
8285
break;
86+
// These two cases are handled identically.
8387
case 'rgba':
8488
case 'hsla':
8589
$colorModeForParsing = $sColorMode;
@@ -88,7 +92,6 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
8892
default:
8993
$colorModeForParsing = $sColorMode;
9094
$mayHaveOptionalAlpha = false;
91-
break;
9295
}
9396

9497
$bContainsVar = false;
@@ -105,7 +108,7 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
105108
// This must be done first, to consume comments as well, so that the `comes` test will work.
106109
$oParserState->consumeWhiteSpace();
107110

108-
// With a var argument, the function can have fewer arguments.
111+
// With a `var` argument, the function can have fewer arguments.
109112
// And as of CSS Color Module Level 4, the alpha argument is optional.
110113
$canCloseNow =
111114
$bContainsVar ||

0 commit comments

Comments
 (0)