Skip to content
Merged
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
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ PHP NEWS
. Fixed segfault in ReflectionMethod::createFromMethodName() on an
uninstantiable subclass. (iliaal)

- Readline:
. Fixed class constant completion in the interactive shell. (Weilin Du)

- Session:
. Fix corruption in mod_mm. (ndossche)
. Fixed bug GH-23043 (broken session id code can cause zend_mm_heap
Expand Down
4 changes: 3 additions & 1 deletion ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
} else {
char *lc_text;
const char *class_name_end;
const char *constant_text = text;
zend_string *class_name = NULL;
zend_class_entry *ce = NULL;

Expand All @@ -543,6 +544,7 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
zend_string_release_ex(class_name, 0);
return NULL;
}
constant_text = class_name_end + 2;
lc_text = zend_str_tolower_dup(class_name_end + 2, textlen - 2 - class_name_len);
textlen -= (class_name_len + 2);
} else {
Expand All @@ -559,7 +561,7 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
ZEND_FALLTHROUGH;
case 2:
case 3:
retval = cli_completion_generator_define(text, textlen, &cli_completion_state, ce ? &ce->constants_table : EG(zend_constants));
retval = cli_completion_generator_define(constant_text, textlen, &cli_completion_state, ce ? &ce->constants_table : EG(zend_constants));
if (retval || ce) {
break;
}
Expand Down
30 changes: 30 additions & 0 deletions ext/readline/tests/readline_cli_completion_class_constant.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Interactive shell: class constant completion
--EXTENSIONS--
readline
--SKIPIF--
<?php
if (READLINE_LIB !== "readline") die('skip readline only');
if (!function_exists('shell_exec')) die('skip shell_exec() not available');
?>
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
$ini = getenv('TEST_PHP_EXTRA_ARGS');

putenv('TERM=VT100');
Comment thread
LamentXU123 marked this conversation as resolved.
putenv('INPUTRC=/dev/null');

$code = <<<'PHP'
class Foo {
public const FooBar = "wrong_constant\n";
public const Zed = "zed_ok\n";
}
echo strtoupper(Foo::Ze );
exit
PHP;

echo shell_exec("echo " . escapeshellarg($code) . " | $php $ini -a");
?>
--EXPECTF--
%AInteractive shell%AZED_OK%A
Loading