diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 994ac829b0a5e..8a5610554399b 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -454,6 +454,8 @@ PHPDBG_COMMAND(exec) /* {{{ */ return SUCCESS; } /* }}} */ +int phpdbg_compile_stdin_ex(zend_string *code, zend_compile_position position); + PHPDBG_COMMAND(stdin) { smart_str code = {0}; @@ -462,8 +464,6 @@ PHPDBG_COMMAND(stdin) int seplen = param->len; int bytes = 0; - smart_str_appends(&code, "?>"); - do { PHPDBG_G(input_buflen) += bytes; if (PHPDBG_G(input_buflen) <= 0) { @@ -507,7 +507,7 @@ PHPDBG_COMMAND(stdin) exec_code: smart_str_0(&code); - if (phpdbg_compile_stdin(code.s) == FAILURE) { + if (phpdbg_compile_stdin_ex(code.s ? code.s : ZSTR_EMPTY_ALLOC(), ZEND_COMPILE_POSITION_AT_OPEN_TAG) == FAILURE) { zend_exception_error(EG(exception), E_ERROR); zend_bailout(); } @@ -515,8 +515,9 @@ PHPDBG_COMMAND(stdin) return SUCCESS; } /* }}} */ -int phpdbg_compile_stdin(zend_string *code) { - PHPDBG_G(ops) = zend_compile_string(code, "Standard input code", ZEND_COMPILE_POSITION_AFTER_OPEN_TAG); +int phpdbg_compile_stdin_ex(zend_string *code, zend_compile_position position) +{ + PHPDBG_G(ops) = zend_compile_string(code, "Standard input code", position); zend_string_release(code); if (EG(exception)) { @@ -552,6 +553,11 @@ int phpdbg_compile_stdin(zend_string *code) { return SUCCESS; } +int phpdbg_compile_stdin(zend_string *code) +{ + return phpdbg_compile_stdin_ex(code, ZEND_COMPILE_POSITION_AFTER_OPEN_TAG); +} + int phpdbg_compile(void) /* {{{ */ { zend_file_handle fh; diff --git a/sapi/phpdbg/tests/stdin_002.phpt b/sapi/phpdbg/tests/stdin_002.phpt new file mode 100644 index 0000000000000..cb011d4d0d8e3 --- /dev/null +++ b/sapi/phpdbg/tests/stdin_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test stdin input with strict types +--PHPDBG-- +stdin foo + [Successful compilation of stdin input] +prompt> [Breakpoint #0 added at Standard input code:3] +prompt> [Breakpoint #0 at Standard input code:3, hits: 1] +>00003: echo "Hello, world!\n"; + 00004: +prompt> Hello, world! +[Script ended normally] +prompt> [Breakpoint #0 at Standard input code:3, hits: 1] +>00003: echo "Hello, world!\n"; + 00004: +prompt>