MDL-53513 libraries: update lessphp to version 1.7.0.10

This commit is contained in:
Simey Lameze 2016-03-18 15:41:22 +08:00
parent fed66ad9e2
commit b0d985e81f
14 changed files with 61 additions and 48 deletions

View File

@ -83,13 +83,12 @@ class Less_Cache{
$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 ){
@ -109,7 +108,7 @@ class Less_Cache{
return false;
}
$compiled_name = self::CompiledName( $less_files );
$compiled_name = self::CompiledName( $less_files, $hash );
$output_file = self::OutputFile($compiled_name, $parser_options );
@ -194,7 +193,7 @@ class Less_Cache{
}
private static function CompiledName( $files ){
private static function CompiledName( $files, $extrahash ){
//save the file list
$temp = array(Less_Version::cache_version);
@ -202,7 +201,7 @@ class Less_Cache{
$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';
}

View File

@ -120,7 +120,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser{
}
}
if ($matched) { continue; }
return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex);
return $this->fail("unmatched `" . chr($cc) . "`", $currentChunkStartIndex);
// /, check for comment
case 47:

View File

@ -739,7 +739,7 @@ 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?)' : '') );
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());
@ -1034,10 +1034,10 @@ class Less_Functions{
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 );
@ -1049,10 +1049,10 @@ class Less_Functions{
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 );
@ -1064,10 +1064,10 @@ class Less_Functions{
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 );
@ -1082,10 +1082,10 @@ class Less_Functions{
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 );
@ -1104,10 +1104,10 @@ class Less_Functions{
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 );
@ -1119,10 +1119,10 @@ class Less_Functions{
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 );
@ -1134,10 +1134,10 @@ class Less_Functions{
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 );
@ -1149,10 +1149,10 @@ class Less_Functions{
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 );
@ -1165,10 +1165,10 @@ class Less_Functions{
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 );

0
lib/lessphp/Less.php.combine Normal file → Executable file
View File

View File

@ -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(),
@ -35,6 +35,8 @@ class Less_Parser{
'sourceMapWriteTo' => null,
'sourceMapURL' => null,
'indentation' => ' ',
'plugins' => array(),
);
@ -87,7 +89,7 @@ class Less_Parser{
// 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');
}
@ -220,7 +222,7 @@ class Less_Parser{
@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);
@ -1989,7 +1991,7 @@ class Less_Parser{
}
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];
}
@ -2623,5 +2625,3 @@ class Less_Parser{
}
}

View File

@ -49,8 +49,8 @@ class Less_Tree{
// 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++ ){
@ -87,4 +87,4 @@ class Less_Tree{
return $obj;
}
}
}

View File

@ -98,7 +98,7 @@ class Less_Tree_Dimension extends Less_Tree{
$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);

View File

@ -182,6 +182,11 @@ class Less_Tree_Import extends Less_Tree{
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 ){
@ -304,4 +309,3 @@ class Less_Tree_Import extends Less_Tree{
}
}

View File

@ -107,7 +107,7 @@ class Less_Tree_Mixin_Call extends Less_Tree{
} 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) . '`' );
}
}
@ -160,12 +160,12 @@ class Less_Tree_Mixin_Call extends Less_Tree{
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;
}

View File

@ -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;
@ -31,6 +32,7 @@ class Less_Tree_NameValue extends Less_Tree{
$this->name
. Less_Environment::$_outputMap[': ']
. $this->value
. $this->important
. (((Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";")
, $this->currentFileInfo, $this->index);
}
@ -38,4 +40,12 @@ class Less_Tree_NameValue extends Less_Tree{
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;
}
}

View File

@ -264,7 +264,7 @@ class Less_Tree_Ruleset extends Less_Tree{
$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;
@ -365,8 +365,8 @@ class Less_Tree_Ruleset extends Less_Tree{
$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";
}

View File

@ -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
}

View File

@ -112,7 +112,7 @@ class Less_Visitor_processExtends extends Less_Visitor{
$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...

View File

@ -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>