Skip to content

Commit 9439ca5

Browse files
committed
Improve handling of #[ in php -a
PHP treats `#ini_setting=value` as a call to `ini_set('ini_setting', 'value')`, and silently skips undeclared settings. This is a problem due to `#[` becoming supported attribute syntax: - `#[Attr] const X = 123;` (this is not a valid place to put an attribute) This does not create a constant. - `#[Attr] function test($x=false){}` also contains `=`. This does not create a function. Instead, only treat lines starting with `#` as a special case when the next character isn't `[` Closes GH-6085
1 parent aa613f8 commit 9439ca5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/readline/readline_cli.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
518518
}
519519
if (text[0] == '$') {
520520
retval = cli_completion_generator_var(text, textlen, &cli_completion_state);
521-
} else if (text[0] == '#') {
521+
} else if (text[0] == '#' && text[1] != '[') {
522522
retval = cli_completion_generator_ini(text, textlen, &cli_completion_state);
523523
} else {
524524
char *lc_text, *class_name_end;
@@ -630,7 +630,7 @@ static int readline_shell_run(void) /* {{{ */
630630

631631
len = strlen(line);
632632

633-
if (line[0] == '#') {
633+
if (line[0] == '#' && line[1] != '[') {
634634
char *param = strstr(&line[1], "=");
635635
if (param) {
636636
zend_string *cmd;

0 commit comments

Comments
 (0)