diff --git a/lib/lessphp/Cache.php b/lib/lessphp/Cache.php
index e4023ef57c2..8c8be39530e 100644
--- a/lib/lessphp/Cache.php
+++ b/lib/lessphp/Cache.php
@@ -91,7 +91,7 @@ class Less_Cache{
self::ListFiles($list_file, $list, $cached_name);
$compiled_name = self::CompiledName($list);
- // if $cached_name != $compiled_name, we know we need to recompile
+ // if $cached_name is the same as the $compiled name, don't regenerate
if( !$cached_name || $cached_name === $compiled_name ){
$output_file = self::OutputFile($compiled_name, $parser_options );
@@ -252,7 +252,7 @@ class Less_Cache{
continue;
}
- $full_path = Less_Cache::$cache_dir.'/'.$file;
+ $full_path = Less_Cache::$cache_dir . $file;
// make sure the file still exists
// css files may have already been deleted
@@ -280,7 +280,7 @@ class Less_Cache{
if( $type === 'list' ){
self::ListFiles($full_path, $list, $css_file_name);
if( $css_file_name ){
- $css_file = Less_Cache::$cache_dir.'/'.$css_file_name;
+ $css_file = Less_Cache::$cache_dir . $css_file_name;
if( file_exists($css_file) ){
unlink($css_file);
}
@@ -313,4 +313,4 @@ class Less_Cache{
}
-}
\ No newline at end of file
+}
diff --git a/lib/lessphp/Exception/Parser.php b/lib/lessphp/Exception/Parser.php
index 69abd151f0b..d6a419d29bf 100644
--- a/lib/lessphp/Exception/Parser.php
+++ b/lib/lessphp/Exception/Parser.php
@@ -54,7 +54,7 @@ class Less_Exception_Parser extends Exception{
protected function getInput(){
- if( !$this->input && $this->currentFile && $this->currentFile['filename'] ){
+ if( !$this->input && $this->currentFile && $this->currentFile['filename'] && file_exists($this->currentFile['filename']) ){
$this->input = file_get_contents( $this->currentFile['filename'] );
}
}
diff --git a/lib/lessphp/Functions.php b/lib/lessphp/Functions.php
index e1c68d8119f..419bee32ff5 100644
--- a/lib/lessphp/Functions.php
+++ b/lib/lessphp/Functions.php
@@ -17,11 +17,10 @@ class Less_Functions{
$this->currentFileInfo = $currentFileInfo;
}
-
/**
* @param string $op
*/
- public static function operate( $op, $a, $b ){
+ public static function operate( $op, $a, $b ){
switch ($op) {
case '+': return $a + $b;
case '-': return $a - $b;
@@ -47,7 +46,7 @@ class Less_Functions{
return $value;
}
- public static function number($n){
+ public static function number($n){
if ($n instanceof Less_Tree_Dimension) {
return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value);
@@ -58,7 +57,7 @@ class Less_Functions{
}
}
- public static function scaled($n, $size = 255 ){
+ public static function scaled($n, $size = 255 ){
if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){
return (float)$n->value * $size / 100;
} else {
@@ -66,11 +65,14 @@ class Less_Functions{
}
}
- public function rgb ($r, $g, $b){
+ public function rgb ($r = null, $g = null, $b = null){
+ if (is_null($r) || is_null($g) || is_null($b)) {
+ throw new Less_Exception_Compiler("rgb expects three parameters");
+ }
return $this->rgba($r, $g, $b, 1.0);
}
- public function rgba($r, $g, $b, $a){
+ public function rgba($r = null, $g = null, $b = null, $a = null){
$rgb = array($r, $g, $b);
$rgb = array_map(array('Less_Functions','scaled'),$rgb);
@@ -144,59 +146,107 @@ class Less_Functions{
$a);
}
- public function hue($color){
+ public function hue($color = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to hue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$c = $color->toHSL();
return new Less_Tree_Dimension(Less_Parser::round($c['h']));
}
- public function saturation($color){
+ public function saturation($color = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to saturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$c = $color->toHSL();
return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%');
}
- public function lightness($color){
+ public function lightness($color = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to lightness must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$c = $color->toHSL();
return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%');
}
- public function hsvhue( $color ){
+ public function hsvhue( $color = null ){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to hsvhue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsv = $color->toHSV();
return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) );
}
- public function hsvsaturation( $color ){
+ public function hsvsaturation( $color = null ){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to hsvsaturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsv = $color->toHSV();
return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' );
}
- public function hsvvalue( $color ){
+ public function hsvvalue( $color = null ){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to hsvvalue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsv = $color->toHSV();
return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' );
}
- public function red($color) {
+ public function red($color = null) {
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to red must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return new Less_Tree_Dimension( $color->rgb[0] );
}
- public function green($color) {
+ public function green($color = null) {
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to green must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return new Less_Tree_Dimension( $color->rgb[1] );
}
- public function blue($color) {
+ public function blue($color = null) {
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to blue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return new Less_Tree_Dimension( $color->rgb[2] );
}
- public function alpha($color){
+ public function alpha($color = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to alpha must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$c = $color->toHSL();
return new Less_Tree_Dimension($c['a']);
}
- public function luma ($color) {
+ public function luma ($color = null) {
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to luma must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%');
}
- public function luminance( $color ){
+ public function luminance( $color = null ){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to luminance must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$luminance =
(0.2126 * $color->rgb[0] / 255)
+ (0.7152 * $color->rgb[1] / 255)
@@ -205,12 +255,20 @@ class Less_Functions{
return new Less_Tree_Dimension(Less_Parser::round( $luminance * $color->alpha * 100), '%');
}
- public function saturate($color, $amount = null){
+ public function saturate($color = null, $amount = null){
// filter: saturate(3.2);
// should be kept as is, so check for color
- if( !property_exists($color,'rgb') ){
+ if ($color instanceof Less_Tree_Dimension) {
return null;
}
+
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to saturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to saturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hsl['s'] += $amount->value / 100;
@@ -222,7 +280,14 @@ class Less_Functions{
/**
* @param Less_Tree_Dimension $amount
*/
- public function desaturate($color, $amount){
+ public function desaturate($color = null, $amount = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to desaturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hsl['s'] -= $amount->value / 100;
@@ -233,7 +298,14 @@ class Less_Functions{
- public function lighten($color, $amount){
+ public function lighten($color = null, $amount=null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to lighten must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to lighten must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hsl['l'] += $amount->value / 100;
@@ -242,34 +314,57 @@ class Less_Functions{
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
}
- public function darken($color, $amount){
-
- if( $color instanceof Less_Tree_Color ){
- $hsl = $color->toHSL();
- $hsl['l'] -= $amount->value / 100;
- $hsl['l'] = self::clamp($hsl['l']);
-
- return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ public function darken($color = null, $amount = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to darken must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to darken must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}
- Less_Functions::Expected('color',$color);
+ $hsl = $color->toHSL();
+ $hsl['l'] -= $amount->value / 100;
+ $hsl['l'] = self::clamp($hsl['l']);
+
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
}
- public function fadein($color, $amount){
+ public function fadein($color = null, $amount = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to fadein must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to fadein must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hsl['a'] += $amount->value / 100;
$hsl['a'] = self::clamp($hsl['a']);
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
}
- public function fadeout($color, $amount){
+ public function fadeout($color = null, $amount = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to fadeout must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hsl['a'] -= $amount->value / 100;
$hsl['a'] = self::clamp($hsl['a']);
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
}
- public function fade($color, $amount){
+ public function fade($color = null, $amount = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to fade must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to fade must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hsl['a'] = $amount->value / 100;
@@ -279,7 +374,14 @@ class Less_Functions{
- public function spin($color, $amount){
+ public function spin($color = null, $amount = null){
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to spin must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$amount instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The second argument to spin must be a number' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
$hsl = $color->toHSL();
$hue = fmod($hsl['h'] + $amount->value, 360);
@@ -296,10 +398,19 @@ class Less_Functions{
/**
* @param Less_Tree_Color $color1
*/
- public function mix($color1, $color2, $weight = null){
+ public function mix($color1 = null, $color2 = null, $weight = null){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to mix must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to mix must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
if (!$weight) {
$weight = new Less_Tree_Dimension('50', '%');
}
+ if (!$weight instanceof Less_Tree_Dimension) {
+ throw new Less_Exception_Compiler('The third argument to contrast must be a percentage' . ($weight instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
$p = $weight->value / 100.0;
$w = $p * 2 - 1;
@@ -320,14 +431,14 @@ class Less_Functions{
}
public function greyscale($color){
- return $this->desaturate($color, new Less_Tree_Dimension(100));
+ return $this->desaturate($color, new Less_Tree_Dimension(100,'%'));
}
public function contrast( $color, $dark = null, $light = null, $threshold = null){
// filter: contrast(3.2);
// should be kept as is, so check for color
- if( !property_exists($color,'rgb') ){
+ if (!$color instanceof Less_Tree_Color) {
return null;
}
if( !$light ){
@@ -336,6 +447,14 @@ class Less_Functions{
if( !$dark ){
$dark = $this->rgba(0, 0, 0, 1.0);
}
+
+ if (!$dark instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to contrast must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$light instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The third argument to contrast must be a color' . ($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
//Figure out which is actually light and dark!
if( $dark->luma() > $light->luma() ){
$t = $light;
@@ -430,7 +549,7 @@ class Less_Functions{
return new Less_Tree_Quoted( $string->quote , $result, $string->escaped);
}
- public function unit( $val, $unit = null) {
+ public function unit( $val, $unit = null) {
if( !($val instanceof Less_Tree_Dimension) ){
throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') );
}
@@ -445,7 +564,7 @@ class Less_Functions{
$unit = "";
}
return new Less_Tree_Dimension($val->value, $unit );
- }
+ }
public function convert($val, $unit){
return $val->convertTo($unit->value);
@@ -585,7 +704,7 @@ class Less_Functions{
if( $order[$j]->unit->toString() === "" && $unitClone ){
$temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone);
- $referenceUnified = $temp->unifiy();
+ $referenceUnified = $temp->unify();
}else{
$referenceUnified = $order[$j]->unify();
}
@@ -619,6 +738,10 @@ class Less_Functions{
}
public function argb($color) {
+ if (!$color instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return new Less_Tree_Anonymous($color->toARGB());
}
@@ -875,21 +998,6 @@ class Less_Functions{
}
- /**
- * @param string $type
- */
- private static function Expected( $type, $arg ){
-
- $debug = debug_backtrace();
- array_shift($debug);
- $last = array_shift($debug);
- $last = array_intersect_key($last,array('function'=>'','class'=>'','line'=>''));
-
- $message = 'Object of type '.get_class($arg).' passed to darken function. Expecting `'.$type.'`. '.$arg->toCSS().'. '.print_r($last,true);
- throw new Less_Exception_Compiler($message);
-
- }
-
/**
* Php version of javascript's `encodeURIComponent` function
*
@@ -924,7 +1032,14 @@ class Less_Functions{
return new Less_Tree_Color($r, $ar);
}
- public function multiply($color1, $color2 ){
+ public function multiply($color1 = null, $color2 = null ){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 );
}
@@ -932,7 +1047,14 @@ class Less_Functions{
return $cb * $cs;
}
- public function screen($color1, $color2 ){
+ public function screen($color1 = null, $color2 = null ){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 );
}
@@ -940,7 +1062,14 @@ class Less_Functions{
return $cb + $cs - $cb * $cs;
}
- public function overlay($color1, $color2){
+ public function overlay($color1 = null, $color2 = null){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 );
}
@@ -951,7 +1080,14 @@ class Less_Functions{
: $this->colorBlendScreen($cb - 1, $cs);
}
- public function softlight($color1, $color2){
+ public function softlight($color1 = null, $color2 = null){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 );
}
@@ -966,7 +1102,14 @@ class Less_Functions{
return $cb - (1 - 2 * $cs) * $e * ($d - $cb);
}
- public function hardlight($color1, $color2){
+ public function hardlight($color1 = null, $color2 = null){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 );
}
@@ -974,7 +1117,14 @@ class Less_Functions{
return $this->colorBlendOverlay($cs, $cb);
}
- public function difference($color1, $color2) {
+ public function difference($color1 = null, $color2 = null) {
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 );
}
@@ -982,7 +1132,14 @@ class Less_Functions{
return abs($cb - $cs);
}
- public function exclusion( $color1, $color2 ){
+ public function exclusion( $color1 = null, $color2 = null ){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 );
}
@@ -990,7 +1147,14 @@ class Less_Functions{
return $cb + $cs - 2 * $cb * $cs;
}
- public function average($color1, $color2){
+ public function average($color1 = null, $color2 = null){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 );
}
@@ -999,7 +1163,14 @@ class Less_Functions{
return ($cb + $cs) / 2;
}
- public function negation($color1, $color2 ){
+ public function negation($color1 = null, $color2 = null ){
+ if (!$color1 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+ if (!$color2 instanceof Less_Tree_Color) {
+ throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
+ }
+
return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 );
}
diff --git a/lib/lessphp/LICENSE b/lib/lessphp/LICENSE
new file mode 100644
index 00000000000..82216a5da45
--- /dev/null
+++ b/lib/lessphp/LICENSE
@@ -0,0 +1,178 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
diff --git a/lib/lessphp/Parser.php b/lib/lessphp/Parser.php
index 6c02bed8635..86d455f1dda 100644
--- a/lib/lessphp/Parser.php
+++ b/lib/lessphp/Parser.php
@@ -47,13 +47,14 @@ class Less_Parser{
private $pos; // current index in `input`
private $saveStack = array(); // holds state for backtracking
private $furthest;
+ private $mb_internal_encoding = ''; // for remember exists value of mbstring.internal_encoding
/**
* @var Less_Environment
*/
private $env;
- private $rules = array();
+ protected $rules = array();
private static $imports = array();
@@ -83,6 +84,14 @@ class Less_Parser{
$this->Reset( $env );
}
+ // mbstring.func_overload > 1 bugfix
+ // The encoding value must be set for each source file,
+ // therefore, to conserve resources and improve the speed of this design is taken here
+ if (ini_get('mbstring.func_overload')) {
+ $this->mb_internal_encoding = ini_get('mbstring.internal_encoding');
+ @ini_set('mbstring.internal_encoding', 'ascii');
+ }
+
}
@@ -204,17 +213,26 @@ class Less_Parser{
}
} catch (Exception $exc) {
- // Intentional fall-through so we can reset environment
- }
+ // Intentional fall-through so we can reset environment
+ }
//reset php settings
@ini_set('precision',$precision);
setlocale(LC_NUMERIC, $locale);
+ // If you previously defined $this->mb_internal_encoding
+ // is required to return the encoding as it was before
+ if ($this->mb_internal_encoding != '') {
+ @ini_set("mbstring.internal_encoding", $this->mb_internal_encoding);
+ $this->mb_internal_encoding = '';
+ }
+
// Rethrow exception after we handled resetting the environment
if (!empty($exc)) {
- throw $exc;
- }
+ throw $exc;
+ }
+
+
return $css;
}
@@ -285,7 +303,7 @@ class Less_Parser{
$filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less';
}else{
$file_uri = self::WinPath($file_uri);
- $filename = basename($file_uri);
+ $filename = $file_uri;
$uri_root = dirname($file_uri);
}
@@ -466,17 +484,7 @@ class Less_Parser{
* @param string $file_path
*/
private function _parse( $file_path = null ){
- if (ini_get("mbstring.func_overload")) {
- $mb_internal_encoding = ini_get("mbstring.internal_encoding");
- @ini_set("mbstring.internal_encoding", "ascii");
- }
-
$this->rules = array_merge($this->rules, $this->GetRules( $file_path ));
-
- //reset php settings
- if (isset($mb_internal_encoding)) {
- @ini_set("mbstring.internal_encoding", $mb_internal_encoding);
- }
}
diff --git a/lib/lessphp/SourceMap/Generator.php b/lib/lessphp/SourceMap/Generator.php
index ac5f2c92776..cc9e65f369d 100644
--- a/lib/lessphp/SourceMap/Generator.php
+++ b/lib/lessphp/SourceMap/Generator.php
@@ -91,13 +91,9 @@ class Less_SourceMap_Generator extends Less_Configurable {
$this->encoder = new Less_SourceMap_Base64VLQ();
$this->SetOptions($options);
-
-
- // fix windows paths
- if( !empty($this->options['sourceMapRootpath']) ){
- $this->options['sourceMapRootpath'] = str_replace('\\', '/', $this->options['sourceMapRootpath']);
- $this->options['sourceMapRootpath'] = rtrim($this->options['sourceMapRootpath'],'/').'/';
- }
+
+ $this->options['sourceMapRootpath'] = $this->fixWindowsPath($this->options['sourceMapRootpath'], true);
+ $this->options['sourceMapBasepath'] = $this->fixWindowsPath($this->options['sourceMapBasepath'], true);
}
/**
@@ -167,7 +163,8 @@ class Less_SourceMap_Generator extends Less_Configurable {
*/
protected function normalizeFilename($filename){
- $filename = str_replace('\\', '/', $filename);
+ $filename = $this->fixWindowsPath($filename);
+
$rootpath = $this->getOption('sourceMapRootpath');
$basePath = $this->getOption('sourceMapBasepath');
@@ -350,4 +347,19 @@ class Less_SourceMap_Generator extends Less_Configurable {
return $this->source_keys[$filename];
}
+ /**
+ * fix windows paths
+ * @param string $path
+ * @return string
+ */
+ public function fixWindowsPath($path, $addEndSlash = false){
+ $slash = ($addEndSlash) ? '/' : '';
+ if( !empty($path) ){
+ $path = str_replace('\\', '/', $path);
+ $path = rtrim($path,'/') . $slash;
+ }
+
+ return $path;
+ }
+
}
\ No newline at end of file
diff --git a/lib/lessphp/Tree/Import.php b/lib/lessphp/Tree/Import.php
index 1752744e9ce..e327b756364 100644
--- a/lib/lessphp/Tree/Import.php
+++ b/lib/lessphp/Tree/Import.php
@@ -232,6 +232,14 @@ class Less_Tree_Import extends Less_Tree{
return array( $full_path, $uri );
}
}elseif( !empty($rootpath) ){
+
+
+ if( $rooturi ){
+ if( strpos($evald_path,$rooturi) === 0 ){
+ $evald_path = substr( $evald_path, strlen($rooturi) );
+ }
+ }
+
$path = rtrim($rootpath,'/\\').'/'.ltrim($evald_path,'/\\');
if( file_exists($path) ){
diff --git a/lib/lessphp/Version.php b/lib/lessphp/Version.php
index 1e95433382e..704ec6e07b3 100644
--- a/lib/lessphp/Version.php
+++ b/lib/lessphp/Version.php
@@ -8,8 +8,8 @@
*/
class Less_Version{
- const version = '1.7.0.3'; // The current build number of less.php
+ const version = '1.7.0.9'; // The current build number of less.php
const less_version = '1.7'; // The less.js version that this build should be compatible with
const cache_version = '170'; // The parser cache version
-}
\ No newline at end of file
+}
diff --git a/lib/lessphp/moodle_readme.txt b/lib/lessphp/moodle_readme.txt
index fac01409a44..3e748dc63ab 100644
--- a/lib/lessphp/moodle_readme.txt
+++ b/lib/lessphp/moodle_readme.txt
@@ -8,5 +8,7 @@ All the files from the folder lib/Less are copied in
this directory. Only exception made for the directory
'.easymin' which is not included.
+Also copy the license file from the project root.
+
Licensed under the Apache license 2.0.
diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml
index d560b630485..7fe18de6b42 100644
--- a/lib/thirdpartylibs.xml
+++ b/lib/thirdpartylibs.xml
@@ -32,7 +32,7 @@
lessphp
less.php
Apache
- 1.7.0.3
+ 1.7.0.9
2.0
diff --git a/lib/upgrade.txt b/lib/upgrade.txt
index 5d25e3f6da9..2fd5c600643 100644
--- a/lib/upgrade.txt
+++ b/lib/upgrade.txt
@@ -3,6 +3,7 @@ information provided here is intended especially for developers.
=== 3.0 ===
+* Less.php upgraded to 1.7.0.9
* External functions x_is_allowed_from_ajax() methods have been deprecated. Define 'ajax' => true in db/services.php instead.
* External functions can be called without a session if they define 'loginrequired' => true in db/services.php.
* All plugins are required to declare their frankenstyle component name via