Skip to content

Commit

Permalink
Improve handling of #[ in php -a
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TysonAndre committed Sep 5, 2020
1 parent aa613f8 commit 9439ca5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
}
if (text[0] == '$') {
retval = cli_completion_generator_var(text, textlen, &cli_completion_state);
} else if (text[0] == '#') {
} else if (text[0] == '#' && text[1] != '[') {
retval = cli_completion_generator_ini(text, textlen, &cli_completion_state);
} else {
char *lc_text, *class_name_end;
Expand Down Expand Up @@ -630,7 +630,7 @@ static int readline_shell_run(void) /* {{{ */

len = strlen(line);

if (line[0] == '#') {
if (line[0] == '#' && line[1] != '[') {
char *param = strstr(&line[1], "=");
if (param) {
zend_string *cmd;
Expand Down

0 comments on commit 9439ca5

Please sign in to comment.