diff --git a/lessc.inc.php b/lessc.inc.php index 90fac1aa..af56e3ac 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -58,6 +58,17 @@ class lessc { protected $allParsedFiles = array(); + // 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; + 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 +1374,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 +1680,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 +1756,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 +2433,19 @@ 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; + public $currentProperty; + // caches preg escaped literals static protected $literalCache = array(); @@ -3605,7 +3629,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 +3641,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 +3660,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 +3805,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..7c3f2d5b 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; } @@ -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());