From 597f20275cb405d98776a26d511d51d6745fd2fc Mon Sep 17 00:00:00 2001 From: shipcloudsebastiaan Date: Tue, 13 Oct 2026 16:14:49 +0200 Subject: [PATCH 1/3] PHP 8.4 compatibility: declare properties, fix deprecations - declare dynamic properties on lessc, lessc_parser and lessc_formatter_classic - replace ${var} interpolation with {$var} - pass 0 instead of null as preg_match() flags - cast float to int before modulo in color parsing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lessc.inc.php | 34 ++++++++++++++++++++++++++++------ lessify.inc.php | 2 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lessc.inc.php b/lessc.inc.php index 90fac1aa..c5e27a83 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -58,6 +58,14 @@ class lessc { protected $allParsedFiles = array(); + // formatter name or object, assigned by setFormatter() + public $formatterName; + + // compile state, assigned in compile() + public $parser; + public $env; + public $scope; + public $formatter; // set to the parser that generated the current line when compiling // so we know how to create error messages protected $sourceParser = null; @@ -1363,7 +1371,7 @@ public function assertArgs($value, $expectedArgs, $name="") { $name = $name . ": "; } - $this->throwError("${name}expecting $expectedArgs arguments, got $numValues"); + $this->throwError("{$name}expecting $expectedArgs arguments, got $numValues"); } return $values; @@ -1669,7 +1677,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); @@ -1745,7 +1753,7 @@ protected function evaluate($exp) { } // type based operators - $fname = "op_${ltype}_${rtype}"; + $fname = "op_{$ltype}_{$rtype}"; if (is_callable(array($this, $fname))) { $out = $this->$fname($op, $left, $right); if (!is_null($out)) return $out; @@ -2422,6 +2430,18 @@ class lessc_parser { */ protected $inParens = false; + // state assigned in the constructor / during parsing + public $eatWhiteDefault; + public $lessc; + public $sourceName; + public $writeComments; + public $seenComments; + public $line; + public $inExp; + public $env; + public $count; + public $buffer; + // caches preg escaped literals static protected $literalCache = array(); @@ -3605,7 +3625,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; @@ -3617,7 +3637,7 @@ protected function match($regex, &$out, $eatWhitespace = null) { protected function whitespace() { if ($this->writeComments) { $gotWhite = false; - while (preg_match(self::$whitePattern, $this->buffer, $m, null, $this->count)) { + while (preg_match(self::$whitePattern, $this->buffer, $m, 0, $this->count)) { if (isset($m[1]) && empty($this->seenComments[$this->count])) { $this->append(array("comment", $m[1])); $this->seenComments[$this->count] = true; @@ -3636,7 +3656,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; } @@ -3781,6 +3801,8 @@ class lessc_formatter_classic { public $compressColors = false; + public $indentLevel; + public function __construct() { $this->indentLevel = 0; } diff --git a/lessify.inc.php b/lessify.inc.php index c47301ad..20f41c2e 100644 --- a/lessify.inc.php +++ b/lessify.inc.php @@ -43,7 +43,7 @@ public function preg_quote($what) { public function match($regex, &$out, $eatWhitespace = true) { $r = '/'.$regex.($eatWhitespace ? '\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]); return true; } From 02f2cd9db0fc3085e75cc9cc63ad0f0ec3591d58 Mon Sep 17 00:00:00 2001 From: shipcloudsebastiaan Date: Tue, 13 Oct 2026 16:22:42 +0200 Subject: [PATCH 2/3] Declare _parseFile and currentProperty to avoid dynamic property deprecations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lessc.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lessc.inc.php b/lessc.inc.php index c5e27a83..af56e3ac 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -61,6 +61,9 @@ class lessc { // formatter name or object, assigned by setFormatter() public $formatterName; + // file set by the deprecated constructor path, used by parse() + public $_parseFile; + // compile state, assigned in compile() public $parser; public $env; @@ -2441,6 +2444,7 @@ class lessc_parser { public $env; public $count; public $buffer; + public $currentProperty; // caches preg escaped literals static protected $literalCache = array(); From 509f81ded3e3f8e7c594c45bc267c28252bcdce1 Mon Sep 17 00:00:00 2001 From: shipcloudsebastiaan Date: Tue, 13 Oct 2026 16:32:38 +0200 Subject: [PATCH 3/3] lessify: fix PHP 8 fatals (curly offset syntax, incompatible parse() signature) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lessify.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lessify.inc.php b/lessify.inc.php index 20f41c2e..7c3f2d5b 100644 --- a/lessify.inc.php +++ b/lessify.inc.php @@ -56,7 +56,7 @@ public function literal($what, $eatWhitespace = true) { // shortcut on single letter if (!$eatWhitespace and strlen($what) === 1) { - if ($this->buffer{$this->count} == $what) { + if ($this->buffer[$this->count] == $what) { $this->count++; return true; } @@ -367,7 +367,7 @@ public function dump() { print_r($this->env); } - public function parse($str = null) { + public function parse($str = null, $initialVariables = null) { $this->prepareParser($str ? $str : $this->buffer); while (false !== $this->parseChunk());