[php-src] Issue #22292: AST pretty printing does not correctly handle invalid variable names
[email protected] (TimWolla) Sat, 13 Jun 2026 13:13:57 +0000
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
Issue: https://github.com/php/php-src/issues/22292
Author: TimWolla
### Description
The following code:
```php
<?php
class Foo {
public function __get($name) { return $name; }
}
${'---'} = 'foo';
try {
assert(!${'---'});
} catch (Error $e) {
echo $e->getMessage(), PHP_EOL;
}
$f = new Foo();
try {
assert(!$f->{'---'});
} catch (Error $e) {
echo $e->getMessage(), PHP_EOL;
}
```
Resulted in this output:
```
assert(!${---})
assert(!$f->{---})
```
But I expected this output instead:
```
assert(!${'---'})
assert(!$f->{'---'})
```
### PHP Version
```plain
PHP 8.4.23-dev (cli) (built: Jun 13 2026 14:48:42) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.23-dev, Copyright (c) Zend Technologies
```
### Operating System
_No response_