Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmullie committed Mar 13, 2024
1 parent 6accc57 commit 531fdee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ protected function move(ConverterInterface $converter, $content)
/**
* Shorthand HEX color codes.
* #FF0000FF -> #f00 -> red
* #FF00FF00 -> transparent
* #FF00FF00 -> transparent.
*
* @param string $content The CSS content to shorten the HEX color codes for
*
Expand All @@ -504,13 +504,13 @@ protected function shortenHexColors($content)

$colors = array(
// make these more readable
'#00f' => 'blue',
'#00f' => 'blue',
'#dc143c' => 'crimson',
'#0ff' => 'cyan',
'#0ff' => 'cyan',
'#8b0000' => 'darkred',
'#696969' => 'dimgray',
'#ff69b4' => 'hotpink',
'#0f0' => 'lime',
'#0f0' => 'lime',
'#fdf5e6' => 'oldlace',
'#87ceeb' => 'skyblue',
'#d8bfd8' => 'thistle',
Expand All @@ -536,7 +536,7 @@ protected function shortenHexColors($content)
'#ffc0cb' => 'pink',
'#dda0dd' => 'plum',
'#800080' => 'purple',
'#f00' => 'red',
'#f00' => 'red',
'#fa8072' => 'salmon',
'#a0522d' => 'sienna',
'#c0c0c0' => 'silver',
Expand All @@ -547,13 +547,13 @@ protected function shortenHexColors($content)
'#ee82ee' => 'violet',
'#f5deb3' => 'wheat',
// or the other way around
'black' => '#000',
'black' => '#000',
'fuchsia' => '#f0f',
'magenta' => '#f0f',
'white' => '#fff',
'yellow' => '#ff0',
'white' => '#fff',
'yellow' => '#ff0',
// and also `transparent`
'transparent' => '#fff0'
'transparent' => '#fff0',
);

return preg_replace_callback(
Expand Down Expand Up @@ -587,12 +587,12 @@ protected function convertLegacyColors($content)
$content = preg_replace('/(rgb|hsl)a?\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)/i', '$1($2 $3 $4)', $content);

// convert `rgb` to `hex`
$dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])';// [000-255] THX @ https://www.regular-expressions.info/numericranges.html
$dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])'; // [000-255] THX @ https://www.regular-expressions.info/numericranges.html

return preg_replace_callback(
"/rgb\($dec $dec $dec\)/i",
function ($match)
{
return sprintf('#%02x%02x%02x', $match[1],$match[2],$match[3]);
function ($match) {
return sprintf('#%02x%02x%02x', $match[1], $match[2], $match[3]);
},
$content
);
Expand Down Expand Up @@ -620,10 +620,10 @@ protected function cleanupModernColors($content)
$tag = '(rgb|hsl|hwb|(?:(?:ok)?(?:lch|lab)))';

// remove alpha channel if it's pointless ..
$content = preg_replace('/'.$tag.'\(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:[\.\d]*|00%)?\)/i', '$1($2 $3 $4)', $content);
$content = preg_replace('/' . $tag . '\(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:[\.\d]*|00%)?\)/i', '$1($2 $3 $4)', $content);

// replace `transparent` with shortcut ..
$content = preg_replace('/'.$tag.'\([^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\)/i', '#fff0', $content);
$content = preg_replace('/' . $tag . '\([^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\)/i', '#fff0', $content);

return $content;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ protected function canImportFile($path)
return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
}
// catch openbasedir exceptions which are not caught by @ on is_file()
catch(\Exception $e) {
catch (\Exception $e) {
return false;
}
}
Expand Down

0 comments on commit 531fdee

Please sign in to comment.