Skip to content

Commit db5979d

Browse files
committed
Make highlight_string() accept string in zpp
To satisfy the type declaration.
1 parent c23eefb commit db5979d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ext/standard/basic_functions.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,22 +1931,18 @@ PHP_FUNCTION(php_strip_whitespace)
19311931
/* {{{ Syntax highlight a string or optionally return it */
19321932
PHP_FUNCTION(highlight_string)
19331933
{
1934-
zval *expr;
1934+
zend_string *str;
19351935
zend_syntax_highlighter_ini syntax_highlighter_ini;
19361936
char *hicompiled_string_description;
19371937
zend_bool i = 0;
19381938
int old_error_reporting = EG(error_reporting);
19391939

19401940
ZEND_PARSE_PARAMETERS_START(1, 2)
1941-
Z_PARAM_ZVAL(expr)
1941+
Z_PARAM_STR(str)
19421942
Z_PARAM_OPTIONAL
19431943
Z_PARAM_BOOL(i)
19441944
ZEND_PARSE_PARAMETERS_END();
19451945

1946-
if (!try_convert_to_string(expr)) {
1947-
RETURN_THROWS();
1948-
}
1949-
19501946
if (i) {
19511947
php_output_start_default();
19521948
}
@@ -1957,8 +1953,12 @@ PHP_FUNCTION(highlight_string)
19571953

19581954
hicompiled_string_description = zend_make_compiled_string_description("highlighted code");
19591955

1960-
highlight_string(expr, &syntax_highlighter_ini, hicompiled_string_description);
1956+
// TODO: Accept zend_string in highlight_string API.
1957+
zval str_zv;
1958+
ZVAL_STR_COPY(&str_zv, str);
1959+
highlight_string(&str_zv, &syntax_highlighter_ini, hicompiled_string_description);
19611960
efree(hicompiled_string_description);
1961+
zval_ptr_dtor(&str_zv);
19621962

19631963
EG(error_reporting) = old_error_reporting;
19641964

0 commit comments

Comments
 (0)