Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions sapi/phpdbg/phpdbg_prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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) {
Expand Down Expand Up @@ -507,16 +507,17 @@ 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();
}

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)) {
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions sapi/phpdbg/tests/stdin_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Test stdin input with strict types
--PHPDBG--
stdin foo
<?php
declare(strict_types=1);
echo "Hello, world!\n";
foo
b 3
r
c
r
q
--EXPECT--
prompt> [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>