Fix #1927 string * float error in leafo/lessphp

- dev-master 태그로 업데이트
- PHP 8.0 이상 버전에서 오류를 일으키는 {0} 문법 4군데 재수정
This commit is contained in:
Kijin Sung 2022-07-03 00:00:52 +09:00
parent e258cf7525
commit 1f9056fc08
31 changed files with 4558 additions and 4326 deletions

View file

@ -28,7 +28,7 @@
"guzzlehttp/guzzle": "6.5.*",
"hautelook/phpass": "1.1.*",
"jbbcode/jbbcode": "1.4.*",
"leafo/lessphp": "0.5.*",
"leafo/lessphp": "dev-master",
"league/html-to-markdown": "4.*",
"matthiasmullie/minify": "1.3.*",
"matthiasmullie/path-converter": "1.*",

32
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "24cc938f5e56d40d6c7d2e484b77c5ad",
"content-hash": "35b577c08cb08cdd0fc2ed06977a8617",
"packages": [
{
"name": "abraham/twitteroauth",
@ -818,24 +818,28 @@
},
{
"name": "leafo/lessphp",
"version": "v0.5.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/leafo/lessphp.git",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283"
"reference": "1fdc40e77824a692d7f4811ba86ed89669a66135"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/1fdc40e77824a692d7f4811ba86ed89669a66135",
"reference": "1fdc40e77824a692d7f4811ba86ed89669a66135",
"shasum": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
"require-dev": {
"phpunit/phpunit": "^5.7.27",
"squizlabs/php_codesniffer": "3.3.2"
},
"default-branch": true,
"bin": [
"plessc",
"lessify"
],
"type": "library",
"autoload": {
"classmap": [
"lessc.inc.php"
@ -857,9 +861,9 @@
"homepage": "http://leafo.net/lessphp/",
"support": {
"issues": "https://github.com/leafo/lessphp/issues",
"source": "https://github.com/leafo/lessphp/tree/v0.5.0"
"source": "https://github.com/leafo/lessphp/tree/master"
},
"time": "2014-11-24T18:39:20+00:00"
"time": "2018-10-16T19:24:03+00:00"
},
{
"name": "league/html-to-markdown",
@ -2014,7 +2018,9 @@
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"leafo/lessphp": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

1
vendor/bin/lessify vendored Symbolic link
View file

@ -0,0 +1 @@
../leafo/lessphp/lessify

1
vendor/bin/plessc vendored Symbolic link
View file

@ -0,0 +1 @@
../leafo/lessphp/plessc

View file

@ -29,7 +29,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'd4ffe761c58924530ae083ba84e2daf5b709c2a6',
'reference' => 'e258cf75257ea48ab849d13f6e7b22a137abf489',
'name' => 'rhymix/rhymix',
),
'versions' =>
@ -144,12 +144,13 @@ private static $installed = array (
),
'leafo/lessphp' =>
array (
'pretty_version' => 'v0.5.0',
'version' => '0.5.0.0',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '9999999-dev',
),
'reference' => '0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283',
'reference' => '1fdc40e77824a692d7f4811ba86ed89669a66135',
),
'league/html-to-markdown' =>
array (
@ -228,7 +229,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'd4ffe761c58924530ae083ba84e2daf5b709c2a6',
'reference' => 'e258cf75257ea48ab849d13f6e7b22a137abf489',
),
'rmccue/requests' =>
array (

View file

@ -16,6 +16,6 @@ return array(
'def43f6c87e4f8dfd0c9e1b1bab14fe8' => $vendorDir . '/symfony/polyfill-iconv/bootstrap.php',
'8170285c807a9f24f165f37b15bc9a36' => $vendorDir . '/defuse/php-encryption/Crypto.php',
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
);

View file

@ -22,6 +22,8 @@ class ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de', 'loadClassLoader'));

View file

@ -17,8 +17,8 @@ class ComposerStaticInit1e37ff09eb6590c7436f139ffd9070de
'def43f6c87e4f8dfd0c9e1b1bab14fe8' => __DIR__ . '/..' . '/symfony/polyfill-iconv/bootstrap.php',
'8170285c807a9f24f165f37b15bc9a36' => __DIR__ . '/..' . '/defuse/php-encryption/Crypto.php',
'2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
);
public static $prefixLengthsPsr4 = array (

View file

@ -836,27 +836,31 @@
},
{
"name": "leafo/lessphp",
"version": "v0.5.0",
"version_normalized": "0.5.0.0",
"version": "dev-master",
"version_normalized": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/leafo/lessphp.git",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283"
"reference": "1fdc40e77824a692d7f4811ba86ed89669a66135"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/1fdc40e77824a692d7f4811ba86ed89669a66135",
"reference": "1fdc40e77824a692d7f4811ba86ed89669a66135",
"shasum": ""
},
"time": "2014-11-24T18:39:20+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
"require-dev": {
"phpunit/phpunit": "^5.7.27",
"squizlabs/php_codesniffer": "3.3.2"
},
"installation-source": "dist",
"time": "2018-10-16T19:24:03+00:00",
"default-branch": true,
"bin": [
"plessc",
"lessify"
],
"type": "library",
"installation-source": "source",
"autoload": {
"classmap": [
"lessc.inc.php"
@ -876,6 +880,10 @@
],
"description": "lessphp is a compiler for LESS written in PHP.",
"homepage": "http://leafo.net/lessphp/",
"support": {
"issues": "https://github.com/leafo/lessphp/issues",
"source": "https://github.com/leafo/lessphp/tree/master"
},
"install-path": "../leafo/lessphp"
},
{

View file

@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => 'd4ffe761c58924530ae083ba84e2daf5b709c2a6',
'reference' => 'e258cf75257ea48ab849d13f6e7b22a137abf489',
'name' => 'rhymix/rhymix',
),
'versions' =>
@ -121,12 +121,13 @@
),
'leafo/lessphp' =>
array (
'pretty_version' => 'v0.5.0',
'version' => '0.5.0.0',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '9999999-dev',
),
'reference' => '0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283',
'reference' => '1fdc40e77824a692d7f4811ba86ed89669a66135',
),
'league/html-to-markdown' =>
array (
@ -205,7 +206,7 @@
'aliases' =>
array (
),
'reference' => 'd4ffe761c58924530ae083ba84e2daf5b709c2a6',
'reference' => 'e258cf75257ea48ab849d13f6e7b22a137abf489',
),
'rmccue/requests' =>
array (

26
vendor/composer/platform_check.php vendored Normal file
View file

@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 70300)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.3.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

40
vendor/leafo/lessphp/.phpcs.xml vendored Normal file
View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset>
<rule ref="PSR2">
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody" />
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpaceBeforeCloseBrace" />
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakNotNewLine" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
<exclude name="PSR2.Methods.FunctionCallSignature.CloseBracketLine" />
<exclude name="PSR2.Methods.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PSR2.Methods.FunctionCallSignature.Indent" />
<exclude name="PSR2.Methods.FunctionCallSignature.MultipleArguments" />
<exclude name="PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket" />
<exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterDefault" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore" />
</rule>
<file>.</file>
<arg name="encoding" value="UTF-8"/>
<arg name="extensions" value="php"/>
<exclude-pattern>vendor</exclude-pattern>
</ruleset>

View file

@ -1,17 +1,17 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
- 7.0
- 7.1
- 7.2
- 7.3
before_script:
- composer self-update
- composer install --no-interaction --prefer-source --dev
sudo: false
install:
- travis_retry composer install --no-interaction --prefer-source
script:
- phpunit tests
matrix:
fast_finish: true
- composer test

View file

@ -1,4 +1,4 @@
For ease of distribution, lessphp 0.4.0 is under a dual license.
For ease of distribution, lessphp is under a dual license.
You are free to pick which one suits your needs.
@ -9,7 +9,7 @@ MIT LICENSE
Copyright (c) 2013 Leaf Corcoran, http://leafo.net/lessphp
Copyright (c) 2014 Leaf Corcoran, http://leafo.net/lessphp
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View file

@ -34,7 +34,7 @@ result or write it to the path specified by an optional second argument.
echo $less->compileFile("input.less");
```
The `compileChecked` method is like `compileFile`, but it only compiles if the output
The `checkedCompile` method is like `compileFile`, but it only compiles if the output
file doesn't exist or it's older than the input file:
```php

View file

@ -14,12 +14,22 @@
"homepage": "http://leafo.net"
}
],
"bin": [
"plessc",
"lessify"
],
"autoload": {
"classmap": ["lessc.inc.php"]
},
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
"require-dev": {
"phpunit/phpunit": "^5.7.27",
"squizlabs/php_codesniffer": "3.3.2"
},
"scripts": {
"test": [
"phpunit",
"phpcs -p -s"
],
"fix": "phpcbf"
}
}

View file

@ -1023,7 +1023,7 @@ result or write it to the path specified by an optional second argument.
echo $less->compileFile("input.less");
```
The `compileChecked` method is like `compileFile`, but it only compiles if the output
The `checkedCompile` method is like `compileFile`, but it only compiles if the output
file doesn't exist or it's older than the input file:
```php
@ -1239,7 +1239,7 @@ One for PHP and one for LESS.
```php
$less->setVariables(array(
"url" => "'http://example.com.com/'"
"url" => "'http://example.com'"
));
echo $less->compile("body { background: url("@{url}/bg.png"); }");

View file

@ -81,12 +81,12 @@ class lessc {
return is_file($name);
}
static public function compressList($items, $delim) {
public static function compressList($items, $delim) {
if (!isset($items[1]) && isset($items[0])) return $items[0];
else return array('list', $delim, $items);
}
static public function preg_quote($what) {
public static function preg_quote($what) {
return preg_quote($what, '/');
}
@ -294,7 +294,7 @@ class lessc {
$unique = array();
$comments = array();
foreach($lines as $line) {
foreach ($lines as $line) {
if (strpos($line, '/*') === 0) {
$comments[] = $line;
continue;
@ -390,8 +390,8 @@ class lessc {
protected function multiplyMedia($env, $childQueries = null) {
if (is_null($env) ||
!empty($env->block->type) && $env->block->type != "media")
{
!empty($env->block->type) && $env->block->type != "media"
) {
return $childQueries;
}
@ -570,7 +570,7 @@ class lessc {
return true; // not having enough is handled above
} else {
$numMatched = $i + 1;
// greater than becuase default values always match
// greater than because default values always match
return $numMatched >= count($orderedArgs);
}
}
@ -746,8 +746,8 @@ class lessc {
if ($suffix !== null &&
$subProp[0] == "assign" &&
is_string($subProp[1]) &&
$subProp[1][0] != $this->vPrefix)
{
$subProp[1][0] != $this->vPrefix
) {
$subProp[2] = array(
'list', ' ',
array($subProp[2], array('keyword', $suffix))
@ -774,7 +774,7 @@ class lessc {
case "comment":
$out->lines[] = $prop[1];
break;
case "import";
case "import":
list(, $importPath, $importId) = $prop;
$importPath = $this->reduce($importPath);
@ -971,12 +971,16 @@ class lessc {
protected function lib_rgbahex($color) {
$color = $this->coerceColor($color);
if (is_null($color))
if (is_null($color)) {
$this->throwError("color expected for rgbahex");
}
return sprintf("#%02x%02x%02x%02x",
isset($color[4]) ? $color[4]*255 : 255,
$color[1],$color[2], $color[3]);
isset($color[4]) ? $color[4] * 255 : 255,
$color[1],
$color[2],
$color[3]
);
}
protected function lib_argb($color){
@ -995,20 +999,20 @@ class lessc {
$fullpath = $this->findImport($url);
if($fullpath && ($fsize = filesize($fullpath)) !== false) {
if ($fullpath && ($fsize = filesize($fullpath)) !== false) {
// IE8 can't handle data uris larger than 32KB
if($fsize/1024 < 32) {
if(is_null($mime)) {
if(class_exists('finfo')) { // php 5.3+
if ($fsize/1024 < 32) {
if (is_null($mime)) {
if (class_exists('finfo')) { // php 5.3+
$finfo = new finfo(FILEINFO_MIME);
$mime = explode('; ', $finfo->file($fullpath));
$mime = $mime[0];
} elseif(function_exists('mime_content_type')) { // PHP 5.2
} elseif (function_exists('mime_content_type')) { // PHP 5.2
$mime = mime_content_type($fullpath);
}
}
if(!is_null($mime)) // fallback if the mime type is still unknown
if (!is_null($mime)) // fallback if the mime type is still unknown
$url = sprintf('data:%s;base64,%s', $mime, base64_encode(file_get_contents($fullpath)));
}
}
@ -1074,7 +1078,7 @@ class lessc {
}
protected function lib_round($arg) {
if($arg[0] != "list") {
if ($arg[0] != "list") {
$value = $this->assertNumber($arg);
return array("number", round($value), $arg[2]);
} else {
@ -1147,7 +1151,9 @@ class lessc {
$hsl = $this->toHSL($color);
$hsl[1] = $hsl[1] + $delta % 360;
if ($hsl[1] < 0) $hsl[1] += 360;
if ($hsl[1] < 0) {
$hsl[1] += 360;
}
return $this->toRGB($hsl);
}
@ -1199,6 +1205,50 @@ class lessc {
return array("number", $num*100, "%");
}
/**
* Mix color with white in variable proportion.
*
* It is the same as calling `mix(#ffffff, @color, @weight)`.
*
* tint(@color, [@weight: 50%]);
*
* http://lesscss.org/functions/#color-operations-tint
*
* @return array Color
*/
protected function lib_tint($args) {
$white = ['color', 255, 255, 255];
if ($args[0] == 'color') {
return $this->lib_mix([ 'list', ',', [$white, $args] ]);
} elseif ($args[0] == "list" && count($args[2]) == 2) {
return $this->lib_mix([ $args[0], $args[1], [$white, $args[2][0], $args[2][1]] ]);
} else {
$this->throwError("tint expects (color, weight)");
}
}
/**
* Mix color with black in variable proportion.
*
* It is the same as calling `mix(#000000, @color, @weight)`
*
* shade(@color, [@weight: 50%]);
*
* http://lesscss.org/functions/#color-operations-shade
*
* @return array Color
*/
protected function lib_shade($args) {
$black = ['color', 0, 0, 0];
if ($args[0] == 'color') {
return $this->lib_mix([ 'list', ',', [$black, $args] ]);
} elseif ($args[0] == "list" && count($args[2]) == 2) {
return $this->lib_mix([ $args[0], $args[1], [$black, $args[2][0], $args[2][1]] ]);
} else {
$this->throwError("shade expects (color, weight)");
}
}
// mixes two colors by weight
// mix(@color1, @color2, [@weight: 50%]);
// http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
@ -1258,22 +1308,35 @@ class lessc {
$lightColor = $this->coerceColor($lightColor);
//Figure out which is actually light and dark!
if ( $this->lib_luma($darkColor) > $this->lib_luma($lightColor) ) {
if ( $this->toLuma($darkColor) > $this->toLuma($lightColor) ) {
$t = $lightColor;
$lightColor = $darkColor;
$darkColor = $t;
}
$inputColor_alpha = $this->lib_alpha($inputColor);
if ( ( $this->lib_luma($inputColor) * $inputColor_alpha) < $threshold) {
if ( ( $this->toLuma($inputColor) * $inputColor_alpha) < $threshold) {
return $lightColor;
}
return $darkColor;
}
private function toLuma($color) {
list(, $r, $g, $b) = $this->coerceColor($color);
$r = $r / 255;
$g = $g / 255;
$b = $b / 255;
$r = ($r <= 0.03928) ? $r / 12.92 : pow((($r + 0.055) / 1.055), 2.4);
$g = ($g <= 0.03928) ? $g / 12.92 : pow((($g + 0.055) / 1.055), 2.4);
$b = ($b <= 0.03928) ? $b / 12.92 : pow((($b + 0.055) / 1.055), 2.4);
return (0.2126 * $r) + (0.7152 * $g) + (0.0722 * $b);
}
protected function lib_luma($color) {
$color = $this->coerceColor($color);
return (0.2126 * $color[0] / 255) + (0.7152 * $color[1] / 255) + (0.0722 * $color[2] / 255);
return array("number", round($this->toLuma($color) * 100, 8), "%");
}
@ -1308,7 +1371,9 @@ class lessc {
}
protected function toHSL($color) {
if ($color[0] == 'hsl') return $color;
if ($color[0] === 'hsl') {
return $color;
}
$r = $color[1] / 255;
$g = $color[2] / 255;
@ -1321,34 +1386,50 @@ class lessc {
if ($min == $max) {
$S = $H = 0;
} else {
if ($L < 0.5)
$S = ($max - $min)/($max + $min);
else
$S = ($max - $min)/(2.0 - $max - $min);
if ($r == $max) $H = ($g - $b)/($max - $min);
elseif ($g == $max) $H = 2.0 + ($b - $r)/($max - $min);
elseif ($b == $max) $H = 4.0 + ($r - $g)/($max - $min);
if ($L < 0.5) {
$S = ($max - $min) / ($max + $min);
} else {
$S = ($max - $min) / (2.0 - $max - $min);
}
if ($r == $max) {
$H = ($g - $b) / ($max - $min);
} elseif ($g == $max) {
$H = 2.0 + ($b - $r) / ($max - $min);
} elseif ($b == $max) {
$H = 4.0 + ($r - $g) / ($max - $min);
}
}
$out = array('hsl',
($H < 0 ? $H + 6 : $H)*60,
$S*100,
$L*100,
$S * 100,
$L * 100,
);
if (count($color) > 4) $out[] = $color[4]; // copy alpha
if (count($color) > 4) {
// copy alpha
$out[] = $color[4];
}
return $out;
}
protected function toRGB_helper($comp, $temp1, $temp2) {
if ($comp < 0) $comp += 1.0;
elseif ($comp > 1) $comp -= 1.0;
if ($comp < 0) {
$comp += 1.0;
} elseif ($comp > 1) {
$comp -= 1.0;
}
if (6 * $comp < 1) return $temp1 + ($temp2 - $temp1) * 6 * $comp;
if (2 * $comp < 1) return $temp2;
if (3 * $comp < 2) return $temp1 + ($temp2 - $temp1)*((2/3) - $comp) * 6;
if (6 * $comp < 1) {
return $temp1 + ($temp2 - $temp1) * 6 * $comp;
}
if (2 * $comp < 1) {
return $temp2;
}
if (3 * $comp < 2) {
return $temp1 + ($temp2 - $temp1)*((2/3) - $comp) * 6;
}
return $temp1;
}
@ -1358,7 +1439,9 @@ class lessc {
* Expects H to be in range of 0 to 360, S and L in 0 to 100
*/
protected function toRGB($color) {
if ($color[0] == 'color') return $color;
if ($color[0] === 'color') {
return $color;
}
$H = $color[1] / 360;
$S = $color[2] / 100;
@ -1368,7 +1451,7 @@ class lessc {
$r = $g = $b = $L;
} else {
$temp2 = $L < 0.5 ?
$L*(1.0 + $S) :
$L * (1.0 + $S) :
$L + $S - $L * $S;
$temp1 = 2.0 * $L - $temp2;
@ -1380,7 +1463,10 @@ class lessc {
// $out = array('color', round($r*255), round($g*255), round($b*255));
$out = array('color', $r*255, $g*255, $b*255);
if (count($color) > 4) $out[] = $color[4]; // copy alpha
if (count($color) > 4) {
// copy alpha
$out[] = $color[4];
}
return $out;
}
@ -1394,7 +1480,10 @@ class lessc {
*/
protected function funcToColor($func) {
$fname = $func[1];
if ($func[2][0] != 'list') return false; // need a list of arguments
if ($func[2][0] != 'list') {
// need a list of arguments
return false;
}
$rawComponents = $func[2][2];
if ($fname == 'hsl' || $fname == 'hsla') {
@ -1404,15 +1493,21 @@ class lessc {
$val = $this->reduce($c);
$val = isset($val[1]) ? floatval($val[1]) : 0;
if ($i == 0) $clamp = 360;
elseif ($i < 3) $clamp = 100;
else $clamp = 1;
if ($i == 0) {
$clamp = 360;
} elseif ($i < 3) {
$clamp = 100;
} else {
$clamp = 1;
}
$hsl[] = $this->clamp($val, $clamp);
$i++;
}
while (count($hsl) < 4) $hsl[] = 0;
while (count($hsl) < 4) {
$hsl[] = 0;
}
return $this->toRGB($hsl);
} elseif ($fname == 'rgb' || $fname == 'rgba') {
@ -1436,7 +1531,9 @@ class lessc {
$i++;
}
while (count($components) < 3) $components[] = 0;
while (count($components) < 3) {
$components[] = 0;
}
array_unshift($components, 'color');
return $this->fixColor($components);
}
@ -1517,8 +1614,11 @@ class lessc {
}
// convert to a typed value if the result is a php primitive
if (is_numeric($ret)) $ret = array('number', $ret, "");
elseif (!is_array($ret)) $ret = array('keyword', $ret);
if (is_numeric($ret)) {
$ret = array('number', $ret, "");
} elseif (!is_array($ret)) {
$ret = array('keyword', $ret);
}
return $ret;
}
@ -1560,7 +1660,7 @@ class lessc {
// coerce a value for use in color operation
protected function coerceColor($value) {
switch($value[0]) {
switch ($value[0]) {
case 'color': return $value;
case 'raw_color':
$c = array("color", 0, 0, 0);
@ -1581,9 +1681,9 @@ class lessc {
if (isset(self::$cssColors[$name])) {
$rgba = explode(',', self::$cssColors[$name]);
if(isset($rgba[3]))
if (isset($rgba[3])) {
return array('color', $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
}
return array('color', $rgba[0], $rgba[1], $rgba[2]);
}
return null;
@ -1610,8 +1710,7 @@ class lessc {
}
public function toBool($a) {
if ($a) return self::$TRUE;
else return self::$FALSE;
return $a ? self::$TRUE : self::$FALSE;
}
// evaluate an expression
@ -1654,8 +1753,12 @@ class lessc {
// make the expression look it did before being parsed
$paddedOp = $op;
if ($whiteBefore) $paddedOp = " " . $paddedOp;
if ($whiteAfter) $paddedOp .= " ";
if ($whiteBefore) {
$paddedOp = " " . $paddedOp;
}
if ($whiteAfter) {
$paddedOp .= " ";
}
return array("string", "", array($left, $paddedOp, $right));
}
@ -1719,7 +1822,9 @@ class lessc {
$out[] = $lval % $rval;
break;
case '/':
if ($rval == 0) $this->throwError("evaluate error: can't divide by zero");
if ($rval == 0) {
$this->throwError("evaluate error: can't divide by zero");
}
$out[] = $lval / $rval;
break;
default:
@ -1729,7 +1834,7 @@ class lessc {
return $this->fixColor($out);
}
function lib_red($color){
public function lib_red($color){
$color = $this->coerceColor($color);
if (is_null($color)) {
$this->throwError('color expected for red()');
@ -1738,7 +1843,7 @@ class lessc {
return $color[1];
}
function lib_green($color){
public function lib_green($color){
$color = $this->coerceColor($color);
if (is_null($color)) {
$this->throwError('color expected for green()');
@ -1747,7 +1852,7 @@ class lessc {
return $color[2];
}
function lib_blue($color){
public function lib_blue($color){
$color = $this->coerceColor($color);
if (is_null($color)) {
$this->throwError('color expected for blue()');
@ -1841,12 +1946,13 @@ class lessc {
return array('list', ' ', $current->arguments);
}
if (isset($current->store[$name]))
if (isset($current->store[$name])) {
return $current->store[$name];
else {
$current = isset($current->storeParent) ?
$current->storeParent : $current->parent;
}
$current = isset($current->storeParent) ?
$current->storeParent :
$current->parent;
}
$this->throwError("variable $name is undefined");
@ -1857,7 +1963,9 @@ class lessc {
$this->pushEnv();
$parser = new lessc_parser($this, __METHOD__);
foreach ($args as $name => $strValue) {
if ($name[0] != '@') $name = '@'.$name;
if ($name[0] !== '@') {
$name = '@' . $name;
}
$parser->count = 0;
$parser->buffer = (string)$strValue;
if (!$parser->propertyValue($value)) {
@ -1965,15 +2073,15 @@ class lessc {
if (is_string($in)) {
$root = $in;
} elseif (is_array($in) and isset($in['root'])) {
if ($force or ! isset($in['files'])) {
} elseif (is_array($in) && isset($in['root'])) {
if ($force || !isset($in['files'])) {
// If we are forcing a recompile or if for some reason the
// structure does not contain any file information we should
// specify the root to trigger a rebuild.
$root = $in['root'];
} elseif (isset($in['files']) and is_array($in['files'])) {
foreach ($in['files'] as $fname => $ftime ) {
if (!file_exists($fname) or filemtime($fname) > $ftime) {
} elseif (isset($in['files']) && is_array($in['files'])) {
foreach ($in['files'] as $fname => $ftime) {
if (!file_exists($fname) || filemtime($fname) > $ftime) {
// One of the files we knew about previously has changed
// so we should look at our incoming root again.
$root = $in['root'];
@ -2416,8 +2524,8 @@ class lessc_parser {
// setting a property
if ($this->keyword($key) && $this->assign() &&
$this->propertyValue($value, $key) && $this->end())
{
$this->propertyValue($value, $key) && $this->end()
) {
$this->append(array('assign', $key, $value), $s);
return true;
} else {
@ -2432,8 +2540,8 @@ class lessc_parser {
// media
if ($this->literal('@media')) {
if (($this->mediaQueryList($mediaQueries) || true)
&& $this->literal('{'))
{
&& $this->literal('{')
) {
$media = $this->pushSpecialBlock("media");
$media->queries = is_null($mediaQueries) ? array() : $mediaQueries;
return true;
@ -2446,8 +2554,8 @@ class lessc_parser {
if ($this->literal("@", false) && $this->keyword($dirName)) {
if ($this->isDirective($dirName, $this->blockDirectives)) {
if (($this->openString("{", $dirValue, null, array(";")) || true) &&
$this->literal("{"))
{
$this->literal("{")
) {
$dir = $this->pushSpecialBlock("directive");
$dir->name = $dirName;
if (isset($dirValue)) $dir->value = $dirValue;
@ -2466,8 +2574,8 @@ class lessc_parser {
// setting a variable
if ($this->variable($var) && $this->assign() &&
$this->propertyValue($value) && $this->end())
{
$this->propertyValue($value) && $this->end()
) {
$this->append(array('assign', $var, $value), $s);
return true;
} else {
@ -2482,8 +2590,8 @@ class lessc_parser {
// opening parametric mixin
if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) &&
($this->guards($guards) || true) &&
$this->literal('{'))
{
$this->literal('{')
) {
$block = $this->pushBlock($this->fixTags(array($tag)));
$block->args = $args;
$block->isVararg = $isVararg;
@ -2543,8 +2651,8 @@ class lessc_parser {
// mixin
if ($this->mixinTags($tags) &&
($this->argumentDef($argv, $isVararg) || true) &&
($this->keyword($suffix) || true) && $this->end())
{
($this->keyword($suffix) || true) && $this->end()
) {
$tags = $this->fixTags($tags);
$this->append(array('mixin', $tags, $argv, $suffix), $s);
return true;
@ -2699,8 +2807,8 @@ class lessc_parser {
$inParens = $this->inParens;
if ($this->literal("(") &&
($this->inParens = true) && $this->expression($exp) &&
$this->literal(")"))
{
$this->literal(")")
) {
$out = $exp;
$this->inParens = $inParens;
return true;
@ -2722,8 +2830,8 @@ class lessc_parser {
if ($this->literal("-", false) &&
(($this->variable($inner) && $inner = array("variable", $inner)) ||
$this->unit($inner) ||
$this->parenValue($inner)))
{
$this->parenValue($inner))
) {
$value = array("unary", "-", $inner);
return true;
} else {
@ -2828,8 +2936,8 @@ class lessc_parser {
if ($this->literal("(") &&
$this->keyword($feature) &&
($this->literal(":") && $this->expression($value) || true) &&
$this->literal(")"))
{
$this->literal(")")
) {
$out = array("mediaExp", $feature);
if ($value) $out[] = $value;
return true;
@ -2968,8 +3076,8 @@ class lessc_parser {
$s = $this->seek();
if ($this->literal("@{") &&
$this->openString("}", $interp, null, array("'", '"', ";")) &&
$this->literal("}", false))
{
$this->literal("}", false)
) {
$out = array("interpolate", $interp);
$this->eatWhiteDefault = $oldWhite;
if ($this->eatWhiteDefault) $this->whitespace();
@ -3016,7 +3124,9 @@ class lessc_parser {
// delimiter.
protected function argumentDef(&$args, &$isVararg) {
$s = $this->seek();
if (!$this->literal('(')) return false;
if (!$this->literal('(')) {
return false;
}
$values = array();
$delim = ",";
@ -3045,7 +3155,9 @@ class lessc_parser {
}
$values[] = $arg;
if ($isVararg) break;
if ($isVararg) {
break;
}
continue;
} else {
$values[] = array("lit", $value);
@ -3063,7 +3175,7 @@ class lessc_parser {
if (isset($values[1])) { // 2 items
$newList = array();
foreach ($values as $i => $arg) {
switch($arg[0]) {
switch ($arg[0]) {
case "arg":
if ($i) {
$this->throwError("Cannot mix ; and , as delimiter types");
@ -3134,7 +3246,9 @@ class lessc_parser {
$this->literal(">");
}
if (count($tags) == 0) return false;
if (!$tags) {
return false;
}
return true;
}
@ -3211,11 +3325,11 @@ class lessc_parser {
// a space separated list of selectors
protected function tag(&$tag, $simple = false) {
if ($simple)
if ($simple) {
$chars = '^@,:;{}\][>\(\) "\'';
else
} else {
$chars = '^@,;{}["\'';
}
$s = $this->seek();
$hasExpression = false;
@ -3320,8 +3434,8 @@ class lessc_parser {
protected function variable(&$name) {
$s = $this->seek();
if ($this->literal($this->lessc->vPrefix, false) &&
($this->variable($sub) || $this->keyword($name)))
{
($this->variable($sub) || $this->keyword($name))
) {
if (!empty($sub)) {
$name = array('variable', $sub);
} else {
@ -3764,5 +3878,3 @@ class lessc_formatter_lessjs extends lessc_formatter_classic {
public $assignSeparator = ": ";
public $selectorSeparator = ",";
}

4
vendor/leafo/lessphp/lessify vendored Normal file → Executable file
View file

@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/env php
<?php
if (php_sapi_name() != "cli") {
@ -19,5 +19,3 @@ try {
} catch (exception $e) {
exit("Fatal error: ".$e->getMessage()."\n");
}

View file

@ -21,25 +21,27 @@ require "lessc.inc.php";
//
class easyparse {
var $buffer;
var $count;
public $buffer;
public $count;
function __construct($str) {
public function __construct($str) {
$this->count = 0;
$this->buffer = trim($str);
}
function seek($where = null) {
if ($where === null) return $this->count;
else $this->count = $where;
public function seek($where = null) {
if ($where === null) {
return $this->count;
}
$this->count = $where;
return true;
}
function preg_quote($what) {
public function preg_quote($what) {
return preg_quote($what, '/');
}
function match($regex, &$out, $eatWhitespace = true) {
public function match($regex, &$out, $eatWhitespace = true) {
$r = '/'.$regex.($eatWhitespace ? '\s*' : '').'/Ais';
if (preg_match($r, $this->buffer, $out, null, $this->count)) {
$this->count += strlen($out[0]);
@ -48,17 +50,17 @@ class easyparse {
return false;
}
function literal($what, $eatWhitespace = true) {
public function literal($what, $eatWhitespace = true) {
// this is here mainly prevent notice from { } string accessor
if ($this->count >= strlen($this->buffer)) return false;
// shortcut on single letter
if (!$eatWhitespace and strlen($what) == 1) {
if (!$eatWhitespace and strlen($what) === 1) {
if ($this->buffer{$this->count} == $what) {
$this->count++;
return true;
}
else return false;
return false;
}
return $this->match($this->preg_quote($what), $m, $eatWhitespace);
@ -70,55 +72,57 @@ class tagparse extends easyparse {
static private $combinators = null;
static private $match_opts = null;
function parse() {
public function parse() {
if (empty(self::$combinators)) {
self::$combinators = '('.implode('|', array_map(array($this, 'preg_quote'),
self::$combinators = '(' . implode('|', array_map(array($this, 'preg_quote'),
array('+', '>', '~'))).')';
self::$match_opts = '('.implode('|', array_map(array($this, 'preg_quote'),
array('=', '~=', '|=', '$=', '*='))).')';
self::$match_opts = '(' . implode('|', array_map(array($this, 'preg_quote'),
array('=', '~=', '|=', '$=', '*='))) . ')';
}
// crush whitespace
$this->buffer = preg_replace('/\s+/', ' ', $this->buffer).' ';
$this->buffer = preg_replace('/\s+/', ' ', $this->buffer) . ' ';
$tags = array();
while ($this->tag($t)) $tags[] = $t;
while ($this->tag($t)) {
$tags[] = $t;
}
return $tags;
}
static function compileString($string) {
public static function compileString($string) {
list(, $delim, $str) = $string;
$str = str_replace($delim, "\\".$delim, $str);
$str = str_replace($delim, "\\" . $delim, $str);
$str = str_replace("\n", "\\\n", $str);
return $delim.$str.$delim;
return $delim . $str . $delim;
}
static function compilePaths($paths) {
public static function compilePaths($paths) {
return implode(', ', array_map(array('self', 'compilePath'), $paths));
}
// array of tags
static function compilePath($path) {
public static function compilePath($path) {
return implode(' ', array_map(array('self', 'compileTag'), $path));
}
static function compileTag($tag) {
public static function compileTag($tag) {
ob_start();
if (isset($tag['comb'])) echo $tag['comb']." ";
if (isset($tag['comb'])) echo $tag['comb'] . " ";
if (isset($tag['front'])) echo $tag['front'];
if (isset($tag['attr'])) {
echo '['.$tag['attr'];
echo '[' . $tag['attr'];
if (isset($tag['op'])) {
echo $tag['op'].$tag['op_value'];
echo $tag['op'] . $tag['op_value'];
}
echo ']';
}
return ob_get_clean();
}
function string(&$out) {
public function string(&$out) {
$s = $this->seek();
if ($this->literal('"')) {
@ -179,7 +183,7 @@ class tagparse extends easyparse {
return false;
}
function tag(&$out) {
public function tag(&$out) {
$s = $this->seek();
$tag = array();
if ($this->combinator($op)) $tag['comb'] = $op;
@ -219,7 +223,7 @@ class tagparse extends easyparse {
return false;
}
function ident(&$out) {
public function ident(&$out) {
// [-]?{nmstart}{nmchar}*
// nmstart: [_a-z]|{nonascii}|{escape}
// nmchar: [_a-z0-9-]|{nonascii}|{escape}
@ -230,7 +234,7 @@ class tagparse extends easyparse {
return false;
}
function value(&$out) {
public function value(&$out) {
if ($this->string($str)) {
$out = $this->compileString($str);
return true;
@ -242,7 +246,7 @@ class tagparse extends easyparse {
}
function combinator(&$op) {
public function combinator(&$op) {
if ($this->match(self::$combinators, $m)) {
$op = $m[1];
return true;
@ -252,42 +256,42 @@ class tagparse extends easyparse {
}
class nodecounter {
var $count = 0;
var $children = array();
public $count = 0;
public $children = array();
var $name;
var $child_blocks;
var $the_block;
public $name;
public $child_blocks;
public $the_block;
function __construct($name) {
public function __construct($name) {
$this->name = $name;
}
function dump($stack = null) {
public function dump($stack = null) {
if (is_null($stack)) $stack = array();
$stack[] = $this->getName();
echo implode(' -> ', $stack)." ($this->count)\n";
echo implode(' -> ', $stack) . " ($this->count)\n";
foreach ($this->children as $child) {
$child->dump($stack);
}
}
static function compileProperties($c, $block) {
foreach($block as $name => $value) {
public static function compileProperties($c, $block) {
foreach ($block as $name => $value) {
if ($c->isProperty($name, $value)) {
echo $c->compileProperty($name, $value)."\n";
echo $c->compileProperty($name, $value) . "\n";
}
}
}
function compile($c, $path = null) {
public function compile($c, $path = null) {
if (is_null($path)) $path = array();
$path[] = $this->name;
$isVisible = !is_null($this->the_block) || !is_null($this->child_blocks);
if ($isVisible) {
echo $c->indent(implode(' ', $path).' {');
echo $c->indent(implode(' ', $path) . ' {');
$c->indentLevel++;
$path = array();
@ -307,7 +311,7 @@ class nodecounter {
}
// compile child nodes
foreach($this->children as $node) {
foreach ($this->children as $node) {
$node->compile($c, $path);
}
@ -318,12 +322,12 @@ class nodecounter {
}
function getName() {
public function getName() {
if (is_null($this->name)) return "[root]";
else return $this->name;
}
function getNode($name) {
public function getNode($name) {
if (!isset($this->children[$name])) {
$this->children[$name] = new nodecounter($name);
}
@ -331,7 +335,7 @@ class nodecounter {
return $this->children[$name];
}
function findNode($path) {
public function findNode($path) {
$current = $this;
for ($i = 0; $i < count($path); $i++) {
$t = tagparse::compileTag($path[$i]);
@ -341,7 +345,7 @@ class nodecounter {
return $current;
}
function addBlock($path, $block) {
public function addBlock($path, $block) {
$node = $this->findNode($path);
if (!is_null($node->the_block)) throw new exception("can this happen?");
@ -349,7 +353,7 @@ class nodecounter {
$node->the_block = $block;
}
function addToNode($path, $block) {
public function addToNode($path, $block) {
$node = $this->findNode($path);
$node->child_blocks[] = $block;
}

0
vendor/leafo/lessphp/package.sh vendored Normal file → Executable file
View file

8
vendor/leafo/lessphp/phpunit.xml.dist vendored Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
<testsuite>
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>

2
vendor/leafo/lessphp/plessc vendored Normal file → Executable file
View file

@ -246,5 +246,3 @@ try {
err($fa.$ex->getMessage());
exit(1);
}
?>

View file

@ -2,7 +2,7 @@
require_once __DIR__ . "/../lessc.inc.php";
class ApiTest extends PHPUnit_Framework_TestCase {
class ApiTest extends PHPUnit\Framework\TestCase {
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array(__DIR__ . "/inputs/test-imports");

View file

@ -1,7 +1,7 @@
<?php
require_once __DIR__ . "/../lessc.inc.php";
class ErrorHandlingTest extends PHPUnit_Framework_TestCase {
class ErrorHandlingTest extends PHPUnit\Framework\TestCase {
public function setUp() {
$this->less = new lessc();
}

View file

@ -12,7 +12,7 @@ function _quote($str) {
return preg_quote($str, "/");
}
class InputTest extends PHPUnit_Framework_TestCase {
class InputTest extends PHPUnit\Framework\TestCase {
protected static $importDirs = array("inputs/test-imports");
protected static $testDirs = array(
@ -49,8 +49,10 @@ class InputTest extends PHPUnit_Framework_TestCase {
}
public function fileNameProvider() {
return array_map(function($a) { return array($a); },
self::findInputNames());
return array_map(
function($a) { return array($a); },
self::findInputNames()
);
}
// only run when env is set
@ -59,7 +61,7 @@ class InputTest extends PHPUnit_Framework_TestCase {
file_put_contents(self::outputNameFor($inFname), $css);
}
static public function findInputNames($pattern="*.less") {
public static function findInputNames($pattern="*.less") {
$files = array();
foreach (self::$testDirs as $inputDir => $outputDir) {
$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
@ -68,7 +70,7 @@ class InputTest extends PHPUnit_Framework_TestCase {
return array_filter($files, "is_file");
}
static public function outputNameFor($input) {
public static function outputNameFor($input) {
$front = _quote(__DIR__ . "/");
$out = preg_replace("/^$front/", "", $input);
@ -86,4 +88,3 @@ class InputTest extends PHPUnit_Framework_TestCase {
return __DIR__ . "/" . $out;
}
}

View file

@ -1,4 +1,4 @@
lessphp uses [phpunit](https://github.com/sebastianbergmann/phpunit/) for its tests
lessphp uses [PHPUnit](https://github.com/sebastianbergmann/phpunit/) for its tests
* `InputTest.php` iterates through all the less files in `inputs/`, compiles
them, then compares the result with the respective file in `outputs/`.

0
vendor/leafo/lessphp/tests/bootstrap.sh vendored Normal file → Executable file
View file

View file

@ -37,6 +37,11 @@ body {
two1: fadeout(#029f23, 10%);
two2: fadein(#029f23, -10%);
tint1: tint(#e0e0e0);
tint2: tint(#e0e0e0, 40%);
shade1: shade(#e0e0e0);
shade2: shade(#e0e0e0, 40%);
three1: fadein(rgba(1,2,3, 0.5), 10%);
three2: fadeout(rgba(1,2,3, 0.5), -10%);
@ -95,6 +100,10 @@ fade {
color2: contrast(#fff, red, blue);
}
.luma {
color: luma(rgb(100, 200, 30));
}
.percent {
per: percentage(0.5);
}

View file

@ -26,6 +26,10 @@ body {
one2: #abcdef;
two1: rgba(2,159,35,0.9);
two2: rgba(2,159,35,0.9);
tint1: #f0f0f0;
tint2: #ececec;
shade1: #707070;
shade2: #868686;
three1: rgba(1,2,3,0.6);
three2: rgba(1,2,3,0.6);
four1: rgba(1,2,3,0);
@ -65,6 +69,9 @@ fade {
color1: #ff0000;
color2: #0000ff;
}
.luma {
color: 44.11161568%;
}
.percent {
per: 50%;
}

View file

@ -1,7 +1,7 @@
<?php
error_reporting(E_ALL);
require realpath(dirname(__FILE__)).'/../lessc.inc.php';
require realpath(dirname(__FILE__)) . '/../lessc.inc.php';
// sorts the selectors in stylesheet in order to normalize it for comparison
@ -15,7 +15,7 @@ class lesscNormalized extends lessc {
public $numberPrecision = 3;
public function compileValue($value) {
if ($value[0] == "raw_color") {
if ($value[0] === "raw_color") {
$value = $this->coerceColor($value);
}
@ -24,7 +24,7 @@ class lesscNormalized extends lessc {
}
class SortingFormatter extends lessc_formatter_lessjs {
function sortKey($block) {
public function sortKey($block) {
if (!isset($block->sortKey)) {
sort($block->selectors, SORT_STRING);
$block->sortKey = implode(",", $block->selectors);
@ -33,7 +33,7 @@ class SortingFormatter extends lessc_formatter_lessjs {
return $block->sortKey;
}
function sortBlock($block) {
public function sortBlock($block) {
usort($block->children, function($a, $b) {
$sort = strcmp($this->sortKey($a), $this->sortKey($b));
if ($sort == 0) {
@ -44,7 +44,7 @@ class SortingFormatter extends lessc_formatter_lessjs {
}
function block($block) {
public function block($block) {
$this->sortBlock($block);
return parent::block($block);
}
@ -54,4 +54,3 @@ class SortingFormatter extends lessc_formatter_lessjs {
$less = new lesscNormalized();
$less->setFormatter(new SortingFormatter);
echo $less->parse(file_get_contents($fname));