Skip to content

Commit

Permalink
MDL-53513 libraries: update lessphp to version 1.7.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Mar 21, 2016
1 parent fed66ad commit b0d985e
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 48 deletions.
9 changes: 4 additions & 5 deletions lib/lessphp/Cache.php
Expand Up @@ -83,13 +83,12 @@ public static function Get( $less_files, $parser_options = array(), $modify_vars
$hash = md5(json_encode($less_files));
$list_file = Less_Cache::$cache_dir . Less_Cache::$prefix . $hash . '.list';


// check cached content
if( !isset($parser_options['use_cache']) || $parser_options['use_cache'] === true ){
if( file_exists($list_file) ){

self::ListFiles($list_file, $list, $cached_name);
$compiled_name = self::CompiledName($list);
$compiled_name = self::CompiledName($list, $hash);

// if $cached_name is the same as the $compiled name, don't regenerate
if( !$cached_name || $cached_name === $compiled_name ){
Expand All @@ -109,7 +108,7 @@ public static function Get( $less_files, $parser_options = array(), $modify_vars
return false;
}

$compiled_name = self::CompiledName( $less_files );
$compiled_name = self::CompiledName( $less_files, $hash );
$output_file = self::OutputFile($compiled_name, $parser_options );


Expand Down Expand Up @@ -194,15 +193,15 @@ private static function OutputFile( $compiled_name, $parser_options ){
}


private static function CompiledName( $files ){
private static function CompiledName( $files, $extrahash ){

//save the file list
$temp = array(Less_Version::cache_version);
foreach($files as $file){
$temp[] = filemtime($file)."\t".filesize($file)."\t".$file;
}

return Less_Cache::$prefix.sha1(json_encode($temp)).'.css';
return Less_Cache::$prefix.sha1(json_encode($temp).$extrahash).'.css';
}


Expand Down
2 changes: 1 addition & 1 deletion lib/lessphp/Exception/Chunk.php
Expand Up @@ -120,7 +120,7 @@ protected function Chunks(){
}
}
if ($matched) { continue; }
return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex);
return $this->fail("unmatched `" . chr($cc) . "`", $currentChunkStartIndex);

// /, check for comment
case 47:
Expand Down
38 changes: 19 additions & 19 deletions lib/lessphp/Functions.php
Expand Up @@ -739,7 +739,7 @@ public function getunit($n){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return new Less_Tree_Anonymous($color->toARGB());
Expand Down Expand Up @@ -1034,10 +1034,10 @@ public function colorBlend( $mode, $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?)' : '') );
throw new Less_Exception_Compiler('The first argument to multiply 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 multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 );
Expand All @@ -1049,10 +1049,10 @@ private function colorBlendMultiply($cb, $cs){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to screen 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 screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 );
Expand All @@ -1064,10 +1064,10 @@ private function colorBlendScreen( $cb, $cs){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to overlay 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 overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 );
Expand All @@ -1082,10 +1082,10 @@ private function colorBlendOverlay($cb, $cs ){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to softlight 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 softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 );
Expand All @@ -1104,10 +1104,10 @@ private function colorBlendSoftlight($cb, $cs ){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to hardlight 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 hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 );
Expand All @@ -1119,10 +1119,10 @@ private function colorBlendHardlight( $cb, $cs ){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to difference 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 difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 );
Expand All @@ -1134,10 +1134,10 @@ private function colorBlendDifference( $cb, $cs ){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to exclusion 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 exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 );
Expand All @@ -1149,10 +1149,10 @@ private function colorBlendExclusion( $cb, $cs ){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to average 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 average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 );
Expand All @@ -1165,10 +1165,10 @@ public function colorBlendAverage($cb, $cs ){

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?)' : '') );
throw new Less_Exception_Compiler('The first argument to negation 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 negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
}

return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 );
Expand Down
Empty file modified lib/lessphp/Less.php.combine 100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions lib/lessphp/Parser.php
Expand Up @@ -20,7 +20,7 @@ class Less_Parser{
'strictUnits' => false, // whether units need to evaluate correctly
'strictMath' => false, // whether math has to be within parenthesis
'relativeUrls' => true, // option - whether to adjust URL's to be relative
'urlArgs' => array(), // whether to add args into url tokens
'urlArgs' => '', // whether to add args into url tokens
'numPrecision' => 8,

'import_dirs' => array(),
Expand All @@ -35,6 +35,8 @@ class Less_Parser{
'sourceMapWriteTo' => null,
'sourceMapURL' => null,

'indentation' => ' ',

'plugins' => array(),

);
Expand Down Expand Up @@ -87,7 +89,7 @@ public function __construct( $env = null ){
// 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')) {
if (ini_get('mbstring.func_overload')) {
$this->mb_internal_encoding = ini_get('mbstring.internal_encoding');
@ini_set('mbstring.internal_encoding', 'ascii');
}
Expand Down Expand Up @@ -220,7 +222,7 @@ public function getCss(){
@ini_set('precision',$precision);
setlocale(LC_NUMERIC, $locale);

// If you previously defined $this->mb_internal_encoding
// 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);
Expand Down Expand Up @@ -1989,7 +1991,7 @@ private function parseImportOptions(){
}

private function parseImportOption(){
$opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/');
$opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference|optional)/');
if( $opt ){
return $opt[1];
}
Expand Down Expand Up @@ -2623,5 +2625,3 @@ public function CacheEnabled(){
}

}


6 changes: 3 additions & 3 deletions lib/lessphp/Tree.php
Expand Up @@ -49,8 +49,8 @@ public static function outputRuleset( $output, $rules ){


// Non-compressed
$tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 );
$tabRuleStr = $tabSetStr.' ';
$tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel-1 );
$tabRuleStr = $tabSetStr.Less_Parser::$options['indentation'];

$output->add( " {" );
for($i = 0; $i < $ruleCnt; $i++ ){
Expand Down Expand Up @@ -87,4 +87,4 @@ public static function __set_state($args){
return $obj;
}

}
}
2 changes: 1 addition & 1 deletion lib/lessphp/Tree/Dimension.php
Expand Up @@ -98,7 +98,7 @@ public function operate( $op, $other){
$other = $other->convertTo( $this->unit->usedUnits());

if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){
throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'.");
throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '" . $unit->toString() . "' and " . $other->unit->toString() . "'.");
}

$value = Less_Functions::operate( $op, $this->value, $other->value);
Expand Down
6 changes: 5 additions & 1 deletion lib/lessphp/Tree/Import.php
Expand Up @@ -182,6 +182,11 @@ public function compile( $env ){
return array( $contents );
}

// optional (need to be before "CSS" to support optional CSS imports. CSS should be checked only if empty($this->currentFileInfo))
if( isset($this->options['optional']) && $this->options['optional'] && !file_exists($full_path) && (!$evald->css || !empty($this->currentFileInfo))) {
return array();
}


// css ?
if( $evald->css ){
Expand Down Expand Up @@ -304,4 +309,3 @@ private function Skip($path, $env){

}
}

8 changes: 4 additions & 4 deletions lib/lessphp/Tree/Mixin/Call.php
Expand Up @@ -107,7 +107,7 @@ public function compile($env){
} else {
$defaultResult = $defTrue;
if( ($count[$defTrue] + $count[$defFalse]) > 1 ){
throw new Exception( 'Ambiguous use of `default()` found when matching for `'. $this->format($args) + '`' );
throw new Exception( 'Ambiguous use of `default()` found when matching for `' . $this->format($args) . '`' );
}
}

Expand Down Expand Up @@ -160,12 +160,12 @@ private function Format($args){
foreach($args as $a){
$argValue = '';
if( $a['name'] ){
$argValue += $a['name']+':';
$argValue .= $a['name'] . ':';
}
if( is_object($a['value']) ){
$argValue += $a['value']->toCSS();
$argValue .= $a['value']->toCSS();
}else{
$argValue += '???';
$argValue .= '???';
}
$message[] = $argValue;
}
Expand Down
10 changes: 10 additions & 0 deletions lib/lessphp/Tree/NameValue.php
Expand Up @@ -17,6 +17,7 @@ class Less_Tree_NameValue extends Less_Tree{
public $index;
public $currentFileInfo;
public $type = 'NameValue';
public $important = '';

public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){
$this->name = $name;
Expand All @@ -31,11 +32,20 @@ public function genCSS( $output ){
$this->name
. Less_Environment::$_outputMap[': ']
. $this->value
. $this->important
. (((Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";")
, $this->currentFileInfo, $this->index);
}

public function compile ($env){
return $this;
}

public function makeImportant(){
$new = new Less_Tree_NameValue($this->name, $this->value, $this->index, $this->currentFileInfo);
$new->important = ' !important';
return $new;
}


}
6 changes: 3 additions & 3 deletions lib/lessphp/Tree/Ruleset.php
Expand Up @@ -264,7 +264,7 @@ function makeImportant(){

$important_rules = array();
foreach($this->rules as $rule){
if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){
if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset || $rule instanceof Less_Tree_NameValue ){
$important_rules[] = $rule->makeImportant();
}else{
$important_rules[] = $rule;
Expand Down Expand Up @@ -365,8 +365,8 @@ public function genCSS( $output ){
$tabRuleStr = $tabSetStr = '';
if( !Less_Parser::$options['compress'] ){
if( Less_Environment::$tabLevel ){
$tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel );
$tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 );
$tabRuleStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel );
$tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel-1 );
}else{
$tabSetStr = $tabRuleStr = "\n";
}
Expand Down
6 changes: 3 additions & 3 deletions lib/lessphp/Version.php
Expand Up @@ -8,8 +8,8 @@
*/
class Less_Version{

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
const version = '1.7.0.10'; // The current build number of less.php
const less_version = '1.7.0'; // The less.js version that this build should be compatible with
const cache_version = '170'; // The parser cache version

}
2 changes: 1 addition & 1 deletion lib/lessphp/Visitor/processExtends.php
Expand Up @@ -112,7 +112,7 @@ private function doExtendChaining( $extendsList, $extendsListTarget, $iterationC
$selectorTwo = "{unable to calculate}";
}

throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")");
throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:" . $selectorOne . ":extend(" . $selectorTwo . ")");
}

// now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e...
Expand Down
2 changes: 1 addition & 1 deletion lib/thirdpartylibs.xml
Expand Up @@ -32,7 +32,7 @@
<location>lessphp</location>
<name>less.php</name>
<license>Apache</license>
<version>1.7.0.9</version>
<version>1.7.0.10</version>
<licenseversion>2.0</licenseversion>
</library>
<library>
Expand Down

0 comments on commit b0d985e

Please sign in to comment.