]> granicus.if.org Git - php/commitdiff
Make highlight_string() accept string in zpp
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 22 Oct 2020 12:31:23 +0000 (14:31 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 22 Oct 2020 12:31:42 +0000 (14:31 +0200)
To satisfy the type declaration.

ext/standard/basic_functions.c

index 8a7d9ca895bfb7ac25e195b8e36fbb5d2ce0e773..876ef347ebf892a65d835fb63be55d4c976421bf 100755 (executable)
@@ -1931,22 +1931,18 @@ PHP_FUNCTION(php_strip_whitespace)
 /* {{{ Syntax highlight a string or optionally return it */
 PHP_FUNCTION(highlight_string)
 {
-       zval *expr;
+       zend_string *str;
        zend_syntax_highlighter_ini syntax_highlighter_ini;
        char *hicompiled_string_description;
        zend_bool i = 0;
        int old_error_reporting = EG(error_reporting);
 
        ZEND_PARSE_PARAMETERS_START(1, 2)
-               Z_PARAM_ZVAL(expr)
+               Z_PARAM_STR(str)
                Z_PARAM_OPTIONAL
                Z_PARAM_BOOL(i)
        ZEND_PARSE_PARAMETERS_END();
 
-       if (!try_convert_to_string(expr)) {
-               RETURN_THROWS();
-       }
-
        if (i) {
                php_output_start_default();
        }
@@ -1957,8 +1953,12 @@ PHP_FUNCTION(highlight_string)
 
        hicompiled_string_description = zend_make_compiled_string_description("highlighted code");
 
-       highlight_string(expr, &syntax_highlighter_ini, hicompiled_string_description);
+       // TODO: Accept zend_string in highlight_string API.
+       zval str_zv;
+       ZVAL_STR_COPY(&str_zv, str);
+       highlight_string(&str_zv, &syntax_highlighter_ini, hicompiled_string_description);
        efree(hicompiled_string_description);
+       zval_ptr_dtor(&str_zv);
 
        EG(error_reporting) = old_error_reporting;