![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/demo.cartinsight.co/vendor/marcusschwarz/lesserphp/tests/ |
<?php error_reporting(E_ALL); 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"; } class lesscNormalized extends lessc { public $numberPrecision = 3; public function compileValue($value) { if ($value[0] == "raw_color") { $value = $this->coerceColor($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); } 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; }); } function block($block) { $this->sortBlock($block); return parent::block($block); } } $less = new lesscNormalized(); $less->setFormatter(new SortingFormatter); echo $less->parse(file_get_contents($fname));