Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

LESS: Clean up various issues in legacy library.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* The `lessc_formatter` takes a CSS tree, and dumps it to a formatted string,
* handling things like indentation.
*/
#[\AllowDynamicProperties]
class lessc {
static public $VERSION = "v0.5.0";

Expand Down Expand Up @@ -662,7 +663,7 @@ protected function zipSetArgs($args, $orderedValues, $keywordValues) {

// check for a rest
$last = end($args);
if ($last[0] == "rest") {
if (isset($last[0]) && $last[0] == "rest") {
$argsCount = is_countable( $args ) ? count( $args ) : 0;
$rest = array_slice($orderedValues, $argsCount - 1);
$this->set($last[1], $this->reduce(array("list", " ", $rest)));
Expand Down Expand Up @@ -1269,7 +1270,7 @@ protected function lib_contrast($args) {

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 (0.2126 * $color[1] / 255) + (0.7152 * $color[2] / 255) + (0.0722 * $color[3] / 255);
}


Expand Down Expand Up @@ -1569,7 +1570,7 @@ protected function coerceColor($value) {
$width = strlen($colorStr) == 3 ? 16 : 256;

for ($i = 3; $i > 0; $i--) { // 3 2 1
$t = $num % $width;
$t = (int) $num % $width;
$num /= $width;

$c[$i] = $t * (256/$width) + $t * floor(16/$width);
Expand Down Expand Up @@ -2273,6 +2274,7 @@ public static function cexecute($in, $force = false, $less = null) {

// responsible for taking a string of LESS code and converting it into a
// syntax tree
#[\AllowDynamicProperties]
class lessc_parser {
static protected $nextBlockId = 0; // used to uniquely identify blocks

Expand Down Expand Up @@ -3500,7 +3502,7 @@ protected function match($regex, &$out, $eatWhitespace = null) {
if ($eatWhitespace === null) $eatWhitespace = $this->eatWhiteDefault;

$r = '/'.$regex.($eatWhitespace && !$this->writeComments ? '\s*' : '').'/Ais';
if (preg_match($r, $this->buffer, $out, null, $this->count)) {
if (preg_match($r, $this->buffer, $out, 0, $this->count)) {
$this->count += strlen($out[0]);
if ($eatWhitespace && $this->writeComments) $this->whitespace();
return true;
Expand Down Expand Up @@ -3531,7 +3533,7 @@ protected function whitespace() {
protected function peek($regex, &$out = null, $from=null) {
if (is_null($from)) $from = $this->count;
$r = '/'.$regex.'/Ais';
$result = preg_match($r, $this->buffer, $out, null, $from);
$result = preg_match($r, $this->buffer, $out, 0, $from);

return $result;
}
Expand Down Expand Up @@ -3754,6 +3756,7 @@ public function block($block) {
}
}

#[\AllowDynamicProperties]
class lessc_formatter_compressed extends lessc_formatter_classic {
public $disableSingle = true;
public $open = "{";
Expand Down