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

@ -4,8 +4,8 @@
"description": "lessphp is a compiler for LESS written in PHP.",
"homepage": "http://leafo.net/lessphp/",
"license": [
"MIT",
"GPL-3.0"
"MIT",
"GPL-3.0"
],
"authors": [
{
@ -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"); }");

File diff suppressed because it is too large Load diff

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

@ -1,23 +1,21 @@
#!/usr/bin/php
#!/usr/bin/env php
<?php
if (php_sapi_name() != "cli") {
err($fa.$argv[0]." must be run in the command line.");
exit(1);
err($fa.$argv[0]." must be run in the command line.");
exit(1);
}
$exe = array_shift($argv); // remove filename
if (!$fname = array_shift($argv)) {
exit("Usage: ".$exe." input-file\n");
exit("Usage: ".$exe." input-file\n");
}
require "lessify.inc.php";
try {
$parser = new lessify($fname);
echo $parser->parse();
try {
$parser = new lessify($fname);
echo $parser->parse();
} catch (exception $e) {
exit("Fatal error: ".$e->getMessage()."\n");
exit("Fatal error: ".$e->getMessage()."\n");
}

View file

@ -21,427 +21,431 @@ require "lessc.inc.php";
//
class easyparse {
var $buffer;
var $count;
public $buffer;
public $count;
function __construct($str) {
$this->count = 0;
$this->buffer = trim($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;
return true;
}
public function seek($where = null) {
if ($where === null) {
return $this->count;
}
$this->count = $where;
return true;
}
function preg_quote($what) {
return preg_quote($what, '/');
}
public function preg_quote($what) {
return preg_quote($what, '/');
}
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]);
return true;
}
return false;
}
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]);
return true;
}
return false;
}
function literal($what, $eatWhitespace = true) {
// this is here mainly prevent notice from { } string accessor
if ($this->count >= strlen($this->buffer)) return false;
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 ($this->buffer{$this->count} == $what) {
$this->count++;
return true;
}
else return false;
}
// shortcut on single letter
if (!$eatWhitespace and strlen($what) === 1) {
if ($this->buffer{$this->count} == $what) {
$this->count++;
return true;
}
return false;
}
return $this->match($this->preg_quote($what), $m, $eatWhitespace);
}
return $this->match($this->preg_quote($what), $m, $eatWhitespace);
}
}
class tagparse extends easyparse {
static private $combinators = null;
static private $match_opts = null;
static private $combinators = null;
static private $match_opts = null;
function parse() {
if (empty(self::$combinators)) {
self::$combinators = '('.implode('|', array_map(array($this, 'preg_quote'),
array('+', '>', '~'))).')';
self::$match_opts = '('.implode('|', array_map(array($this, 'preg_quote'),
array('=', '~=', '|=', '$=', '*='))).')';
}
public function parse() {
if (empty(self::$combinators)) {
self::$combinators = '(' . 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).' ';
// crush whitespace
$this->buffer = preg_replace('/\s+/', ' ', $this->buffer) . ' ';
$tags = array();
while ($this->tag($t)) $tags[] = $t;
$tags = array();
while ($this->tag($t)) {
$tags[] = $t;
}
return $tags;
}
return $tags;
}
static function compileString($string) {
list(, $delim, $str) = $string;
$str = str_replace($delim, "\\".$delim, $str);
$str = str_replace("\n", "\\\n", $str);
return $delim.$str.$delim;
}
public static function compileString($string) {
list(, $delim, $str) = $string;
$str = str_replace($delim, "\\" . $delim, $str);
$str = str_replace("\n", "\\\n", $str);
return $delim . $str . $delim;
}
static function compilePaths($paths) {
return implode(', ', array_map(array('self', 'compilePath'), $paths));
}
public static function compilePaths($paths) {
return implode(', ', array_map(array('self', 'compilePath'), $paths));
}
// array of tags
static function compilePath($path) {
return implode(' ', array_map(array('self', 'compileTag'), $path));
}
// array of tags
public static function compilePath($path) {
return implode(' ', array_map(array('self', 'compileTag'), $path));
}
static function compileTag($tag) {
ob_start();
if (isset($tag['comb'])) echo $tag['comb']." ";
if (isset($tag['front'])) echo $tag['front'];
if (isset($tag['attr'])) {
echo '['.$tag['attr'];
if (isset($tag['op'])) {
echo $tag['op'].$tag['op_value'];
}
echo ']';
}
return ob_get_clean();
}
public static function compileTag($tag) {
ob_start();
if (isset($tag['comb'])) echo $tag['comb'] . " ";
if (isset($tag['front'])) echo $tag['front'];
if (isset($tag['attr'])) {
echo '[' . $tag['attr'];
if (isset($tag['op'])) {
echo $tag['op'] . $tag['op_value'];
}
echo ']';
}
return ob_get_clean();
}
function string(&$out) {
$s = $this->seek();
public function string(&$out) {
$s = $this->seek();
if ($this->literal('"')) {
$delim = '"';
} elseif ($this->literal("'")) {
$delim = "'";
} else {
return false;
}
if ($this->literal('"')) {
$delim = '"';
} elseif ($this->literal("'")) {
$delim = "'";
} else {
return false;
}
while (true) {
// step through letters looking for either end or escape
$buff = "";
$escapeNext = false;
$finished = false;
for ($i = $this->count; $i < strlen($this->buffer); $i++) {
$char = $this->buffer[$i];
switch ($char) {
case $delim:
if ($escapeNext) {
$buff .= $char;
$escapeNext = false;
break;
}
$finished = true;
break 2;
case "\\":
if ($escapeNext) {
$buff .= $char;
$escapeNext = false;
} else {
$escapeNext = true;
}
break;
case "\n":
if (!$escapeNext) {
break 3;
}
while (true) {
// step through letters looking for either end or escape
$buff = "";
$escapeNext = false;
$finished = false;
for ($i = $this->count; $i < strlen($this->buffer); $i++) {
$char = $this->buffer[$i];
switch ($char) {
case $delim:
if ($escapeNext) {
$buff .= $char;
$escapeNext = false;
break;
}
$finished = true;
break 2;
case "\\":
if ($escapeNext) {
$buff .= $char;
$escapeNext = false;
} else {
$escapeNext = true;
}
break;
case "\n":
if (!$escapeNext) {
break 3;
}
$buff .= $char;
$escapeNext = false;
break;
default:
if ($escapeNext) {
$buff .= "\\";
$escapeNext = false;
}
$buff .= $char;
}
}
if (!$finished) break;
$out = array('string', $delim, $buff);
$this->seek($i+1);
return true;
}
$buff .= $char;
$escapeNext = false;
break;
default:
if ($escapeNext) {
$buff .= "\\";
$escapeNext = false;
}
$buff .= $char;
}
}
if (!$finished) break;
$out = array('string', $delim, $buff);
$this->seek($i+1);
return true;
}
$this->seek($s);
return false;
}
$this->seek($s);
return false;
}
function tag(&$out) {
$s = $this->seek();
$tag = array();
if ($this->combinator($op)) $tag['comb'] = $op;
public function tag(&$out) {
$s = $this->seek();
$tag = array();
if ($this->combinator($op)) $tag['comb'] = $op;
if (!$this->match('(.*?)( |$|\[|'.self::$combinators.')', $match)) {
$this->seek($s);
return false;
}
if (!$this->match('(.*?)( |$|\[|'.self::$combinators.')', $match)) {
$this->seek($s);
return false;
}
if (!empty($match[3])) {
// give back combinator
$this->count-=strlen($match[3]);
}
if (!empty($match[3])) {
// give back combinator
$this->count-=strlen($match[3]);
}
if (!empty($match[1])) $tag['front'] = $match[1];
if (!empty($match[1])) $tag['front'] = $match[1];
if ($match[2] == '[') {
if ($this->ident($i)) {
$tag['attr'] = $i;
if ($match[2] == '[') {
if ($this->ident($i)) {
$tag['attr'] = $i;
if ($this->match(self::$match_opts, $m) && $this->value($v)) {
$tag['op'] = $m[1];
$tag['op_value'] = $v;
}
if ($this->match(self::$match_opts, $m) && $this->value($v)) {
$tag['op'] = $m[1];
$tag['op_value'] = $v;
}
if ($this->literal(']')) {
$out = $tag;
return true;
}
}
} elseif (isset($tag['front'])) {
$out = $tag;
return true;
}
if ($this->literal(']')) {
$out = $tag;
return true;
}
}
} elseif (isset($tag['front'])) {
$out = $tag;
return true;
}
$this->seek($s);
return false;
}
$this->seek($s);
return false;
}
function ident(&$out) {
// [-]?{nmstart}{nmchar}*
// nmstart: [_a-z]|{nonascii}|{escape}
// nmchar: [_a-z0-9-]|{nonascii}|{escape}
if ($this->match('(-?[_a-z][_\w]*)', $m)) {
$out = $m[1];
return true;
}
return false;
}
public function ident(&$out) {
// [-]?{nmstart}{nmchar}*
// nmstart: [_a-z]|{nonascii}|{escape}
// nmchar: [_a-z0-9-]|{nonascii}|{escape}
if ($this->match('(-?[_a-z][_\w]*)', $m)) {
$out = $m[1];
return true;
}
return false;
}
function value(&$out) {
if ($this->string($str)) {
$out = $this->compileString($str);
return true;
} elseif ($this->ident($id)) {
$out = $id;
return true;
}
return false;
}
public function value(&$out) {
if ($this->string($str)) {
$out = $this->compileString($str);
return true;
} elseif ($this->ident($id)) {
$out = $id;
return true;
}
return false;
}
function combinator(&$op) {
if ($this->match(self::$combinators, $m)) {
$op = $m[1];
return true;
}
return false;
}
public function combinator(&$op) {
if ($this->match(self::$combinators, $m)) {
$op = $m[1];
return true;
}
return false;
}
}
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) {
$this->name = $name;
}
public function __construct($name) {
$this->name = $name;
}
function dump($stack = null) {
if (is_null($stack)) $stack = array();
$stack[] = $this->getName();
echo implode(' -> ', $stack)." ($this->count)\n";
foreach ($this->children as $child) {
$child->dump($stack);
}
}
public function dump($stack = null) {
if (is_null($stack)) $stack = array();
$stack[] = $this->getName();
echo implode(' -> ', $stack) . " ($this->count)\n";
foreach ($this->children as $child) {
$child->dump($stack);
}
}
static function compileProperties($c, $block) {
foreach($block as $name => $value) {
if ($c->isProperty($name, $value)) {
echo $c->compileProperty($name, $value)."\n";
}
}
}
public static function compileProperties($c, $block) {
foreach ($block as $name => $value) {
if ($c->isProperty($name, $value)) {
echo $c->compileProperty($name, $value) . "\n";
}
}
}
function compile($c, $path = null) {
if (is_null($path)) $path = array();
$path[] = $this->name;
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);
$isVisible = !is_null($this->the_block) || !is_null($this->child_blocks);
if ($isVisible) {
echo $c->indent(implode(' ', $path).' {');
$c->indentLevel++;
$path = array();
if ($isVisible) {
echo $c->indent(implode(' ', $path) . ' {');
$c->indentLevel++;
$path = array();
if ($this->the_block) {
$this->compileProperties($c, $this->the_block);
}
if ($this->the_block) {
$this->compileProperties($c, $this->the_block);
}
if ($this->child_blocks) {
foreach ($this->child_blocks as $block) {
echo $c->indent(tagparse::compilePaths($block['__tags']).' {');
$c->indentLevel++;
$this->compileProperties($c, $block);
$c->indentLevel--;
echo $c->indent('}');
}
}
}
if ($this->child_blocks) {
foreach ($this->child_blocks as $block) {
echo $c->indent(tagparse::compilePaths($block['__tags']).' {');
$c->indentLevel++;
$this->compileProperties($c, $block);
$c->indentLevel--;
echo $c->indent('}');
}
}
}
// compile child nodes
foreach($this->children as $node) {
$node->compile($c, $path);
}
// compile child nodes
foreach ($this->children as $node) {
$node->compile($c, $path);
}
if ($isVisible) {
$c->indentLevel--;
echo $c->indent('}');
}
if ($isVisible) {
$c->indentLevel--;
echo $c->indent('}');
}
}
}
function getName() {
if (is_null($this->name)) return "[root]";
else return $this->name;
}
public function getName() {
if (is_null($this->name)) return "[root]";
else return $this->name;
}
function getNode($name) {
if (!isset($this->children[$name])) {
$this->children[$name] = new nodecounter($name);
}
public function getNode($name) {
if (!isset($this->children[$name])) {
$this->children[$name] = new nodecounter($name);
}
return $this->children[$name];
}
return $this->children[$name];
}
function findNode($path) {
$current = $this;
for ($i = 0; $i < count($path); $i++) {
$t = tagparse::compileTag($path[$i]);
$current = $current->getNode($t);
}
public function findNode($path) {
$current = $this;
for ($i = 0; $i < count($path); $i++) {
$t = tagparse::compileTag($path[$i]);
$current = $current->getNode($t);
}
return $current;
}
return $current;
}
function addBlock($path, $block) {
$node = $this->findNode($path);
if (!is_null($node->the_block)) throw new exception("can this happen?");
public function addBlock($path, $block) {
$node = $this->findNode($path);
if (!is_null($node->the_block)) throw new exception("can this happen?");
unset($block['__tags']);
$node->the_block = $block;
}
unset($block['__tags']);
$node->the_block = $block;
}
function addToNode($path, $block) {
$node = $this->findNode($path);
$node->child_blocks[] = $block;
}
public function addToNode($path, $block) {
$node = $this->findNode($path);
$node->child_blocks[] = $block;
}
}
/**
* create a less file from a css file by combining blocks where appropriate
*/
class lessify extends lessc {
public function dump() {
print_r($this->env);
}
public function dump() {
print_r($this->env);
}
public function parse($str = null) {
$this->prepareParser($str ? $str : $this->buffer);
while (false !== $this->parseChunk());
public function parse($str = null) {
$this->prepareParser($str ? $str : $this->buffer);
while (false !== $this->parseChunk());
$root = new nodecounter(null);
$root = new nodecounter(null);
// attempt to preserve some of the block order
$order = array();
// attempt to preserve some of the block order
$order = array();
$visitedTags = array();
foreach (end($this->env) as $name => $block) {
if (!$this->isBlock($name, $block)) continue;
if (isset($visitedTags[$name])) continue;
$visitedTags = array();
foreach (end($this->env) as $name => $block) {
if (!$this->isBlock($name, $block)) continue;
if (isset($visitedTags[$name])) continue;
foreach ($block['__tags'] as $t) {
$visitedTags[$t] = true;
}
foreach ($block['__tags'] as $t) {
$visitedTags[$t] = true;
}
// skip those with more than 1
if (count($block['__tags']) == 1) {
$p = new tagparse(end($block['__tags']));
$path = $p->parse();
$root->addBlock($path, $block);
$order[] = array('compressed', $path, $block);
continue;
} else {
$common = null;
$paths = array();
foreach ($block['__tags'] as $rawtag) {
$p = new tagparse($rawtag);
$paths[] = $path = $p->parse();
if (is_null($common)) $common = $path;
else {
$new_common = array();
foreach ($path as $tag) {
$head = array_shift($common);
if ($tag == $head) {
$new_common[] = $head;
} else break;
}
$common = $new_common;
if (empty($common)) {
// nothing in common
break;
}
}
}
// skip those with more than 1
if (count($block['__tags']) == 1) {
$p = new tagparse(end($block['__tags']));
$path = $p->parse();
$root->addBlock($path, $block);
$order[] = array('compressed', $path, $block);
continue;
} else {
$common = null;
$paths = array();
foreach ($block['__tags'] as $rawtag) {
$p = new tagparse($rawtag);
$paths[] = $path = $p->parse();
if (is_null($common)) $common = $path;
else {
$new_common = array();
foreach ($path as $tag) {
$head = array_shift($common);
if ($tag == $head) {
$new_common[] = $head;
} else break;
}
$common = $new_common;
if (empty($common)) {
// nothing in common
break;
}
}
}
if (!empty($common)) {
$new_paths = array();
foreach ($paths as $p) $new_paths[] = array_slice($p, count($common));
$block['__tags'] = $new_paths;
$root->addToNode($common, $block);
$order[] = array('compressed', $common, $block);
continue;
}
if (!empty($common)) {
$new_paths = array();
foreach ($paths as $p) $new_paths[] = array_slice($p, count($common));
$block['__tags'] = $new_paths;
$root->addToNode($common, $block);
$order[] = array('compressed', $common, $block);
continue;
}
}
}
$order[] = array('none', $block['__tags'], $block);
}
$order[] = array('none', $block['__tags'], $block);
}
$compressed = $root->children;
foreach ($order as $item) {
list($type, $tags, $block) = $item;
if ($type == 'compressed') {
$top = tagparse::compileTag(reset($tags));
if (isset($compressed[$top])) {
$compressed[$top]->compile($this);
unset($compressed[$top]);
}
} else {
echo $this->indent(implode(', ', $tags).' {');
$this->indentLevel++;
nodecounter::compileProperties($this, $block);
$this->indentLevel--;
echo $this->indent('}');
}
}
}
$compressed = $root->children;
foreach ($order as $item) {
list($type, $tags, $block) = $item;
if ($type == 'compressed') {
$top = tagparse::compileTag(reset($tags));
if (isset($compressed[$top])) {
$compressed[$top]->compile($this);
unset($compressed[$top]);
}
} else {
echo $this->indent(implode(', ', $tags).' {');
$this->indentLevel++;
nodecounter::compileProperties($this, $block);
$this->indentLevel--;
echo $this->indent('}');
}
}
}
}

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,14 +2,14 @@
require_once __DIR__ . "/../lessc.inc.php";
class ApiTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array(__DIR__ . "/inputs/test-imports");
}
class ApiTest extends PHPUnit\Framework\TestCase {
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array(__DIR__ . "/inputs/test-imports");
}
public function testPreserveComments() {
$input = <<<EOD
public function testPreserveComments() {
$input = <<<EOD
// what is going on?
/** what the heck **/
@ -42,7 +42,7 @@ Here is a block comment
EOD;
$outputWithComments = <<<EOD
$outputWithComments = <<<EOD
/** what the heck **/
/**
@ -69,7 +69,7 @@ div /*yeah*/ {
}
EOD;
$outputWithoutComments = <<<EOD
$outputWithoutComments = <<<EOD
div {
border: 1px solid red;
color: url('http://mage-page.com');
@ -82,71 +82,71 @@ div {
}
EOD;
$this->assertEquals($this->compile($input), trim($outputWithoutComments));
$this->less->setPreserveComments(true);
$this->assertEquals($this->compile($input), trim($outputWithComments));
}
$this->assertEquals($this->compile($input), trim($outputWithoutComments));
$this->less->setPreserveComments(true);
$this->assertEquals($this->compile($input), trim($outputWithComments));
}
public function testOldInterface() {
$this->less = new lessc(__DIR__ . "/inputs/hi.less");
$out = $this->less->parse(array("hello" => "10px"));
$this->assertEquals(trim($out), trim('
public function testOldInterface() {
$this->less = new lessc(__DIR__ . "/inputs/hi.less");
$out = $this->less->parse(array("hello" => "10px"));
$this->assertEquals(trim($out), trim('
div:before {
content: "hi!";
}'));
}
}
public function testInjectVars() {
$out = $this->less->parse(".magic { color: @color; width: @base - 200; }",
array(
'color' => 'red',
'base' => '960px'
));
public function testInjectVars() {
$out = $this->less->parse(".magic { color: @color; width: @base - 200; }",
array(
'color' => 'red',
'base' => '960px'
));
$this->assertEquals(trim($out), trim("
$this->assertEquals(trim($out), trim("
.magic {
color: red;
width: 760px;
}"));
}
}
public function testDisableImport() {
$this->less->importDisabled = true;
$this->assertEquals(
"/* import disabled */",
$this->compile("@import 'file3';"));
}
public function testDisableImport() {
$this->less->importDisabled = true;
$this->assertEquals(
"/* import disabled */",
$this->compile("@import 'file3';"));
}
public function testUserFunction() {
$this->less->registerFunction("add-two", function($list) {
list($a, $b) = $list[2];
return $a[1] + $b[1];
});
public function testUserFunction() {
$this->less->registerFunction("add-two", function($list) {
list($a, $b) = $list[2];
return $a[1] + $b[1];
});
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: 30;");
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: 30;");
return $this->less;
}
return $this->less;
}
/**
* @depends testUserFunction
*/
public function testUnregisterFunction($less) {
$less->unregisterFunction("add-two");
/**
* @depends testUserFunction
*/
public function testUnregisterFunction($less) {
$less->unregisterFunction("add-two");
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: add-two(10,20);");
}
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: add-two(10,20);");
}
public function testFormatters() {
$src = "
public function testFormatters() {
$src = "
div, pre {
color: blue;
span, .big, hello.world {
@ -155,14 +155,14 @@ div:before {
}
}";
$this->less->setFormatter("compressed");
$this->assertEquals(
$this->compile($src), "div,pre{color:blue;}div span,div .big,div hello.world,pre span,pre .big,pre hello.world{height:20px;color:#fff;}");
$this->less->setFormatter("compressed");
$this->assertEquals(
$this->compile($src), "div,pre{color:blue;}div span,div .big,div hello.world,pre span,pre .big,pre hello.world{height:20px;color:#fff;}");
// TODO: fix the output order of tags
$this->less->setFormatter("lessjs");
$this->assertEquals(
$this->compile($src),
// TODO: fix the output order of tags
$this->less->setFormatter("lessjs");
$this->assertEquals(
$this->compile($src),
"div,
pre {
color: blue;
@ -177,9 +177,9 @@ pre hello.world {
color: #ffffff;
}");
$this->less->setFormatter("classic");
$this->assertEquals(
$this->compile($src),
$this->less->setFormatter("classic");
$this->assertEquals(
$this->compile($src),
trim("div, pre { color:blue; }
div span, div .big, div hello.world, pre span, pre .big, pre hello.world {
height:20px;
@ -187,10 +187,10 @@ div span, div .big, div hello.world, pre span, pre .big, pre hello.world {
}
"));
}
}
public function compile($str) {
return trim($this->less->parse($str));
}
public function compile($str) {
return trim($this->less->parse($str));
}
}

View file

@ -1,81 +1,81 @@
<?php
require_once __DIR__ . "/../lessc.inc.php";
class ErrorHandlingTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->less = new lessc();
}
class ErrorHandlingTest extends PHPUnit\Framework\TestCase {
public function setUp() {
$this->less = new lessc();
}
public function compile() {
$source = join("\n", func_get_args());
return $this->less->compile($source);
}
public function compile() {
$source = join("\n", func_get_args());
return $this->less->compile($source);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .parametric-mixin is undefined
*/
public function testRequiredParametersMissing() {
$this->compile(
'.parametric-mixin (@a, @b) { a: @a; b: @b; }',
'.selector { .parametric-mixin(12px); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .parametric-mixin is undefined
*/
public function testRequiredParametersMissing() {
$this->compile(
'.parametric-mixin (@a, @b) { a: @a; b: @b; }',
'.selector { .parametric-mixin(12px); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .parametric-mixin is undefined
*/
public function testTooManyParameters() {
$this->compile(
'.parametric-mixin (@a, @b) { a: @a; b: @b; }',
'.selector { .parametric-mixin(12px, 13px, 14px); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .parametric-mixin is undefined
*/
public function testTooManyParameters() {
$this->compile(
'.parametric-mixin (@a, @b) { a: @a; b: @b; }',
'.selector { .parametric-mixin(12px, 13px, 14px); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage unrecognised input
*/
public function testRequiredArgumentsMissing() {
$this->compile('.selector { rule: e(); }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage unrecognised input
*/
public function testRequiredArgumentsMissing() {
$this->compile('.selector { rule: e(); }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage variable @missing is undefined
*/
public function testVariableMissing() {
$this->compile('.selector { rule: @missing; }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage variable @missing is undefined
*/
public function testVariableMissing() {
$this->compile('.selector { rule: @missing; }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage .missing-mixin is undefined
*/
public function testMixinMissing() {
$this->compile('.selector { .missing-mixin; }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage .missing-mixin is undefined
*/
public function testMixinMissing() {
$this->compile('.selector { .missing-mixin; }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage .flipped is undefined
*/
public function testGuardUnmatchedValue() {
$this->compile(
'.flipped(@x) when (@x =< 10) { rule: value; }',
'.selector { .flipped(12); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .flipped is undefined
*/
public function testGuardUnmatchedValue() {
$this->compile(
'.flipped(@x) when (@x =< 10) { rule: value; }',
'.selector { .flipped(12); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .colors-only is undefined
*/
public function testGuardUnmatchedType() {
$this->compile(
'.colors-only(@x) when (iscolor(@x)) { rule: value; }',
'.selector { .colors-only("string value"); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .colors-only is undefined
*/
public function testGuardUnmatchedType() {
$this->compile(
'.colors-only(@x) when (iscolor(@x)) { rule: value; }',
'.selector { .colors-only("string value"); }'
);
}
}

View file

@ -5,85 +5,86 @@ require_once __DIR__ . "/../lessc.inc.php";
// Runs all the tests in inputs/ and compares their output to ouputs/
function _dump($value) {
fwrite(STDOUT, print_r($value, true));
fwrite(STDOUT, print_r($value, true));
}
function _quote($str) {
return preg_quote($str, "/");
return preg_quote($str, "/");
}
class InputTest extends PHPUnit_Framework_TestCase {
protected static $importDirs = array("inputs/test-imports");
class InputTest extends PHPUnit\Framework\TestCase {
protected static $importDirs = array("inputs/test-imports");
protected static $testDirs = array(
"inputs" => "outputs",
"inputs_lessjs" => "outputs_lessjs",
);
protected static $testDirs = array(
"inputs" => "outputs",
"inputs_lessjs" => "outputs_lessjs",
);
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array_map(function($path) {
return __DIR__ . "/" . $path;
}, self::$importDirs);
}
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array_map(function($path) {
return __DIR__ . "/" . $path;
}, self::$importDirs);
}
/**
* @dataProvider fileNameProvider
*/
public function testInputFile($inFname) {
if ($pattern = getenv("BUILD")) {
return $this->buildInput($inFname);
}
/**
* @dataProvider fileNameProvider
*/
public function testInputFile($inFname) {
if ($pattern = getenv("BUILD")) {
return $this->buildInput($inFname);
}
$outFname = self::outputNameFor($inFname);
$outFname = self::outputNameFor($inFname);
if (!is_readable($outFname)) {
$this->fail("$outFname is missing, ".
"consider building tests with BUILD=true");
}
if (!is_readable($outFname)) {
$this->fail("$outFname is missing, ".
"consider building tests with BUILD=true");
}
$input = file_get_contents($inFname);
$output = file_get_contents($outFname);
$input = file_get_contents($inFname);
$output = file_get_contents($outFname);
$this->assertEquals($output, $this->less->parse($input));
}
$this->assertEquals($output, $this->less->parse($input));
}
public function fileNameProvider() {
return array_map(function($a) { return array($a); },
self::findInputNames());
}
public function fileNameProvider() {
return array_map(
function($a) { return array($a); },
self::findInputNames()
);
}
// only run when env is set
public function buildInput($inFname) {
$css = $this->less->parse(file_get_contents($inFname));
file_put_contents(self::outputNameFor($inFname), $css);
}
// only run when env is set
public function buildInput($inFname) {
$css = $this->less->parse(file_get_contents($inFname));
file_put_contents(self::outputNameFor($inFname), $css);
}
static public function findInputNames($pattern="*.less") {
$files = array();
foreach (self::$testDirs as $inputDir => $outputDir) {
$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
}
public static function findInputNames($pattern="*.less") {
$files = array();
foreach (self::$testDirs as $inputDir => $outputDir) {
$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
}
return array_filter($files, "is_file");
}
return array_filter($files, "is_file");
}
static public function outputNameFor($input) {
$front = _quote(__DIR__ . "/");
$out = preg_replace("/^$front/", "", $input);
public static function outputNameFor($input) {
$front = _quote(__DIR__ . "/");
$out = preg_replace("/^$front/", "", $input);
foreach (self::$testDirs as $inputDir => $outputDir) {
$in = _quote($inputDir . "/");
$rewritten = preg_replace("/$in/", $outputDir . "/", $out);
if ($rewritten != $out) {
$out = $rewritten;
break;
}
}
foreach (self::$testDirs as $inputDir => $outputDir) {
$in = _quote($inputDir . "/");
$rewritten = preg_replace("/$in/", $outputDir . "/", $out);
if ($rewritten != $out) {
$out = $rewritten;
break;
}
}
$out = preg_replace("/.less$/", ".css", $out);
$out = preg_replace("/.less$/", ".css", $out);
return __DIR__ . "/" . $out;
}
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,57 +1,56 @@
<?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
$exe = array_shift($argv); // remove filename
if (!$fname = array_shift($argv)) {
$fname = "php://stdin";
$fname = "php://stdin";
}
class lesscNormalized extends lessc {
public $numberPrecision = 3;
public $numberPrecision = 3;
public function compileValue($value) {
if ($value[0] == "raw_color") {
$value = $this->coerceColor($value);
}
public function compileValue($value) {
if ($value[0] === "raw_color") {
$value = $this->coerceColor($value);
}
return parent::compileValue($value);
}
return parent::compileValue($value);
}
}
class SortingFormatter extends lessc_formatter_lessjs {
function sortKey($block) {
if (!isset($block->sortKey)) {
sort($block->selectors, SORT_STRING);
$block->sortKey = implode(",", $block->selectors);
}
public function sortKey($block) {
if (!isset($block->sortKey)) {
sort($block->selectors, SORT_STRING);
$block->sortKey = implode(",", $block->selectors);
}
return $block->sortKey;
}
return $block->sortKey;
}
function sortBlock($block) {
usort($block->children, function($a, $b) {
$sort = strcmp($this->sortKey($a), $this->sortKey($b));
if ($sort == 0) {
// TODO
}
return $sort;
});
public function sortBlock($block) {
usort($block->children, function($a, $b) {
$sort = strcmp($this->sortKey($a), $this->sortKey($b));
if ($sort == 0) {
// TODO
}
return $sort;
});
}
}
function block($block) {
$this->sortBlock($block);
return parent::block($block);
}
public function block($block) {
$this->sortBlock($block);
return parent::block($block);
}
}
$less = new lesscNormalized();
$less->setFormatter(new SortingFormatter);
echo $less->parse(file_get_contents($fname));