using Php;

namespace PhpNative {
    public int strpos (string haystack, string needle) {
        return haystack.index_of (needle);
    }

    public int strpos_static (string haystack, string needle, string php_file, int php_line) throws Error {
        return strpos (haystack, needle);
    }

    public zval strpos_zval (zval haystack, zval needle, string php_file, int php_line) throws Error {
        int position = strpos_static (zval_to_string (haystack), zval_to_string (needle), php_file, php_line);
        return position < 0 ? zval.boolean (false) : zval.integer (position);
    }
}
