diff --git a/lib/Less/Functions.php b/lib/Less/Functions.php index 6dfa7626..56e62e28 100644 --- a/lib/Less/Functions.php +++ b/lib/Less/Functions.php @@ -67,9 +67,21 @@ public static function scaled( $n, $size = 255 ) { } public function rgb( $r = null, $g = null, $b = null ) { - if ( $r === null || $g === null || $b === null ) { - throw new Less_Exception_Compiler( "rgb expects three parameters" ); + $components = func_get_args(); + + if (count( $components ) != 3) + { + return null; + } + + foreach ( $components AS $component ) + { + if ( !$component instanceof Less_Tree_Dimension ) + { + return null; + } } + return $this->rgba( $r, $g, $b, 1.0 ); } @@ -81,28 +93,23 @@ public function rgba( $r = null, $g = null, $b = null, $a = null ) { return new Less_Tree_Color( $rgb, $a ); } - public function hsl( $h, $s, $l ) { - if (self::isLessHsl( $h, $s, $l )) { - return $this->hsla( $h, $s, $l, 1.0 ); - } - - return 'hsl(' . $h . ')'; - } + public function hsl( $h, $s = null, $l = null ) { + $components = func_get_args(); - protected function isLessHsl( $h, $s, $l ) { - $hsl = func_get_args(); - - if (count( $hsl ) != 3) { - return false; + if (count( $components ) != 3) + { + return null; } - foreach ( $hsl AS $arg ) { - if ( !$arg instanceof Less_Tree_Dimension ) { - return false; + foreach ( $components AS $component ) + { + if ( !$component instanceof Less_Tree_Dimension ) + { + return null; } } - return true; + return $this->hsla( $h, $s, $l, 1.0 ); } public function hsla( $h, $s, $l, $a ) {