[php-src] Issue #22373: AST pretty-printing drops meaningful parentheses surrounding property access

From: Date: Sun, 21 Jun 2026 10:21:00 +0000
Subject: [php-src] Issue #22373: AST pretty-printing drops meaningful parentheses surrounding property access
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252228@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22373 Author: TimWolla ### Description The following code: ```php <?php try { assert(false && new class { public function __construct(public Closure $f = strrev(...)) { var_dump(($this->f)('abc')); } }); } catch (AssertionError $e) { echo $e->getMessage(), PHP_EOL; } ``` Resulted in this output: ``` assert(false && new class { public function __construct(public Closure $f = strrev(...)) { var_dump($this->f('abc')); } }) ``` But I expected this output instead: ``` assert(false && new class { public function __construct(public Closure $f = strrev(...)) { var_dump(($this->f)('abc')); } }) ``` because the parentheses around $this->f are needed to disambiguate. ### PHP Version ```plain PHP 8.6.0-dev (cli) (built: Jun 21 2026 12:05:35) (NTS 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_

« previous php.bugs (#252228) next »