leafo / lessphp

LESS compiler written in PHP
http://leafo.net/lessphp
Other
2.2k stars 527 forks source link

round(number,precision) : Precision value throws Error #617

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi, in v0.4.0 the round-function [lib_round($arg)] has no precision management included. Two arguments [ex. round(33.33333, 2)] creating an error. Documentation says that is possible.

Source:

 protected function lib_round($arg) {
    $value = $this->assertNumber($arg);
    return array("number", round($value), $arg[2]);
}

Fix:

 protected function lib_round($arg) {
    if($arg[0] == "list") {

        $values = $arg[2];

        $precision = $this->assertNumber($values[1]);
        $value = $this->assertNumber($values[0]);

        return array("number", round($value,$precision), $values[0][2]);

    } else {

        $value = $this->assertNumber($arg);
        return array("number", round($value), $arg[2]);

    }
}