protected function callBuiltin($name, $args, &$returnValue)
{
// try a lib function
$name = $this->normalizeName($name);
$libName = "lib_" . $name;
$f = array($this, $libName);
$prototype = isset(self::${$libName}) ? self::${$libName} : null;
if (is_callable($f)) {
$sorted = $this->sortArgs($prototype, $args);
foreach ($sorted as &$val) {
$val = $this->reduce($val, true);
}
$returnValue = call_user_func($f, $sorted, $this);
} elseif (isset($this->userFunctions[$name])) {
// see if we can find a user function
$fn = $this->userFunctions[$name];
foreach ($args as &$val) {
$val = $this->reduce($val[1], true);
}
$returnValue = call_user_func($fn, $args, $this);
}
if (isset($returnValue)) {
// coerce a php value into a scss one
if (is_numeric($returnValue)) {
$returnValue = array('number', $returnValue, "");
} elseif (is_bool($returnValue)) {
$returnValue = $returnValue ? self::$true : self::$false;
} elseif (!is_array($returnValue)) {
$returnValue = array('keyword', $returnValue);
}
return true;
}
return false;
}