Skip to content

Commit

Permalink
Remove null from highlight_* return types
Browse files Browse the repository at this point in the history
Also fix show_source() discrepancy in func_info.
  • Loading branch information
nikic committed Jul 21, 2020
1 parent 69af5ad commit be9c5da
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions ext/opcache/Optimizer/zend_func_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ static const func_info_t func_infos[] = {
F1("var_export", MAY_BE_NULL | MAY_BE_STRING),
F1("print_r", MAY_BE_TRUE | MAY_BE_STRING),
F0("register_shutdown_function", MAY_BE_NULL | MAY_BE_FALSE),
F1("highlight_file", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("show_source", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
F1("highlight_string", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("highlight_file", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("show_source", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("highlight_string", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("php_strip_whitespace", MAY_BE_STRING),
F1("ini_get_all", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("ini_alter", MAY_BE_FALSE | MAY_BE_STRING),
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,7 @@ PHP_FUNCTION(highlight_file)
if (i) {
php_output_get_contents(return_value);
php_output_discard();
ZEND_ASSERT(Z_TYPE_P(return_value) == IS_STRING);
} else {
RETURN_TRUE;
}
Expand Down Expand Up @@ -2004,6 +2005,7 @@ PHP_FUNCTION(highlight_string)
if (i) {
php_output_get_contents(return_value);
php_output_discard();
ZEND_ASSERT(Z_TYPE_P(return_value) == IS_STRING);
} else {
RETURN_TRUE;
}
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@ function forward_static_call_array(callable $function, array $args): mixed {}
/** @param callable $function */
function register_shutdown_function($function, mixed ...$args): ?bool {}

function highlight_file(string $filename, bool $return = false): string|bool|null {}
function highlight_file(string $filename, bool $return = false): string|bool {}

/** @alias highlight_file */
function show_source(string $filename, bool $return = false): string|bool|null {}
function show_source(string $filename, bool $return = false): string|bool {}

function php_strip_whitespace(string $filename): string {}

function highlight_string(string $string, bool $return = false): string|bool|null {}
function highlight_string(string $string, bool $return = false): string|bool {}

function ini_get(string $varname): string|false {}

Expand Down
6 changes: 3 additions & 3 deletions ext/standard/basic_functions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3f739b2ab0c9317b5e52779e16f4bf56bd19d86e */
* Stub hash: f19f6cfcda6c591e3842a3c108e078acea21d5be */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
Expand Down Expand Up @@ -467,7 +467,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_register_shutdown_function, 0, 1
ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_highlight_file, 0, 1, MAY_BE_STRING|MAY_BE_BOOL|MAY_BE_NULL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_highlight_file, 0, 1, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, return, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
Expand All @@ -478,7 +478,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_php_strip_whitespace, 0, 1, IS_S
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_highlight_string, 0, 1, MAY_BE_STRING|MAY_BE_BOOL|MAY_BE_NULL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_highlight_string, 0, 1, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, return, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
Expand Down

0 comments on commit be9c5da

Please sign in to comment.