namespace PhpefRuntimeEmbed {
    [CCode (cname = "phpef_runtime_embed_call_php_function")]
    private extern PhpefRuntimeCore.Zval call_php_function(string function_name, PhpefRuntimeCore.Zval[] args);

    public PhpefRuntimeCore.Zval phpfunc_substr(PhpefRuntimeCore.Zval value, PhpefRuntimeCore.Zval offset, PhpefRuntimeCore.Zval? length = null) {
        if (length == null) {
            PhpefRuntimeCore.Zval[] args = { value, offset };
            return call_php_function("substr", args);
        }

        PhpefRuntimeCore.Zval[] args = { value, offset, length };
        return call_php_function("substr", args);
    }

    public PhpefRuntimeCore.Zval phpfunc_trim(PhpefRuntimeCore.Zval value, PhpefRuntimeCore.Zval? characters = null) {
        if (characters == null) {
            PhpefRuntimeCore.Zval[] args = { value };
            return call_php_function("trim", args);
        }

        PhpefRuntimeCore.Zval[] args = { value, characters };
        return call_php_function("trim", args);
    }
}
