[php-src] Issue #22387: AST pretty-printing drops meaningful parentheses around RHS of `instanceof`
| From: | TimWolla | Date: | Sun, 21 Jun 2026 17:11:23 +0000 |
| Subject: | [php-src] Issue #22387: AST pretty-printing drops meaningful parentheses around RHS of `instanceof` | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252230@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/22387
Author: TimWolla
### Description
The following code:
```php
<?php
$foo = new stdClass();
const bar = 'stdClass';
try {
assert(!$foo instanceof (bar));
} catch (AssertionError $e) {
echo $e->getMessage(), PHP_EOL;
}
```
Resulted in this output:
```
assert(!$foo instanceof bar)
```
But I expected this output instead:
```
assert(!$foo instanceof (bar))
```
### PHP Version
```plain
PHP 8.6.0-dev (cli) (built: Jun 21 2026 18:51:23) (ZTS DEBUG)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0-dev, Copyright © Zend by Perforce
with Zend OPcache v8.6.0-dev, Copyright ©, by Zend by Perforce
```
### Operating System
_No response_