1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Wrap class const LHS in parens if necessary

This looks like a very old bug in the pretty printer that showed
up in PHP 8 tests.
This commit is contained in:
Nikita Popov 2020-08-09 21:41:30 +02:00
parent 0cee2088ea
commit feb6bf7a0c
3 changed files with 6 additions and 1 deletions

View File

@ -577,7 +577,7 @@ class Standard extends PrettyPrinterAbstract
}
protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node) {
return $this->p($node->class) . '::' . $this->p($node->name);
return $this->pDereferenceLhs($node->class) . '::' . $this->p($node->name);
}
protected function pExpr_PropertyFetch(Expr\PropertyFetch $node) {

View File

@ -1157,6 +1157,9 @@ abstract class PrettyPrinterAbstract
'var' => self::FIXUP_DEREF_LHS,
'name' => self::FIXUP_BRACED_NAME,
],
Expr\ClassConstFetch::class => [
'var' => self::FIXUP_DEREF_LHS,
],
Scalar\Encapsed::class => [
'parts' => self::FIXUP_ENCAPSED,
],

View File

@ -10,6 +10,7 @@ $A::{$b[$c]}();
A::$$b[$c]();
($a->b)();
(A::$b)();
('a' . 'b')::X;
-----
!!php7
(function () {
@ -21,3 +22,4 @@ $A::{$b[$c]}();
A::${$b}[$c]();
($a->b)();
(A::$b)();
('a' . 'b')::X;