Leafo\ScssPhp\Compiler::callNativeFunction PHP Method

callNativeFunction() protected method

Call built-in and registered (PHP) functions
protected callNativeFunction ( string $name, array $args, array &$returnValue ) : boolean
$name string
$args array
$returnValue array
return boolean Returns true if returnValue is set; otherwise, false
    protected function callNativeFunction($name, $args, &$returnValue)
    {
        // try a lib function
        $name = $this->normalizeName($name);
        if (isset($this->userFunctions[$name])) {
            // see if we can find a user function
            list($f, $prototype) = $this->userFunctions[$name];
        } elseif (($f = $this->getBuiltinFunction($name)) && is_callable($f)) {
            $libName = $f[1];
            $prototype = isset(static::${$libName}) ? static::${$libName} : null;
        } else {
            return false;
        }
        list($sorted, $kwargs) = $this->sortArgs($prototype, $args);
        if ($name !== 'if' && $name !== 'call') {
            foreach ($sorted as &$val) {
                $val = $this->reduce($val, true);
            }
        }
        $returnValue = call_user_func($f, $sorted, $kwargs);
        if (!isset($returnValue)) {
            return false;
        }
        $returnValue = $this->coerceValue($returnValue);
        return true;
    }
Compiler