diff --git a/ext/readline/php_readline.h b/ext/readline/php_readline.h index d825e19a11799..a9b56b6167df4 100644 --- a/ext/readline/php_readline.h +++ b/ext/readline/php_readline.h @@ -17,6 +17,12 @@ #ifndef PHP_READLINE_H #define PHP_READLINE_H +#if HAVE_LIBEDIT +#define READLINE_LIB "libedit" +#else +#define READLINE_LIB "readline" +#endif + #if HAVE_LIBREADLINE || HAVE_LIBEDIT extern zend_module_entry readline_module_entry; diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 544258eeca621..db2776fb27a9a 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -82,6 +82,9 @@ PHP_MINIT_FUNCTION(readline) #if HAVE_RL_CALLBACK_READ_CHAR ZVAL_UNDEF(&_prepped_callback); #endif + + register_readline_symbols(module_number); + return PHP_MINIT(cli_readline)(INIT_FUNC_ARGS_PASSTHRU); } diff --git a/ext/readline/readline.stub.php b/ext/readline/readline.stub.php index 804b02fde38c2..0e0db92af07c0 100644 --- a/ext/readline/readline.stub.php +++ b/ext/readline/readline.stub.php @@ -2,6 +2,12 @@ /** @generate-class-entries */ +/** + * @var string + * @cvalue READLINE_LIB + */ +const READLINE_LIB = UNKNOWN; + function readline(?string $prompt = null): string|false {} /** @param int|string|bool|null $value */ diff --git a/ext/readline/readline_arginfo.h b/ext/readline/readline_arginfo.h index de539fd3310cc..4c64448d715c9 100644 --- a/ext/readline/readline_arginfo.h +++ b/ext/readline/readline_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 1839e2895847790ef3db4263d4940fa1bc956ff2 */ + * Stub hash: 64d630be9ea75d584a4a999dd4d4c6bc769f5aca */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_readline, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, prompt, IS_STRING, 1, "null") @@ -114,3 +114,8 @@ static const zend_function_entry ext_functions[] = { #endif ZEND_FE_END }; + +static void register_readline_symbols(int module_number) +{ + REGISTER_STRING_CONSTANT("READLINE_LIB", READLINE_LIB, CONST_CS | CONST_PERSISTENT); +} diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index 8bf5d23df75f7..84b261db34283 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -771,12 +771,6 @@ PHP_MINIT_FUNCTION(cli_readline) ZEND_INIT_MODULE_GLOBALS(cli_readline, cli_readline_init_globals, NULL); REGISTER_INI_ENTRIES(); -#if HAVE_LIBEDIT - REGISTER_STRING_CONSTANT("READLINE_LIB", "libedit", CONST_CS|CONST_PERSISTENT); -#else - REGISTER_STRING_CONSTANT("READLINE_LIB", "readline", CONST_CS|CONST_PERSISTENT); -#endif - GET_SHELL_CB(cb); if (cb) { cb->cli_shell_write = readline_shell_write;