Support fixup for dynamic class const name

This is new in PHP 8.3.

(cherry picked from commit e9416a0eaec601df910045a6f63361068cffddbf)
This commit is contained in:
Nikita Popov 2023-02-26 16:00:35 +01:00
parent 21a61ece15
commit 6d2584bdf1
2 changed files with 7 additions and 1 deletions

View File

@ -1230,7 +1230,10 @@ abstract class PrettyPrinterAbstract
Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS],
Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS],
Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS],
Expr\ClassConstFetch::class => ['class' => self::FIXUP_STATIC_DEREF_LHS],
Expr\ClassConstFetch::class => [
'class' => self::FIXUP_STATIC_DEREF_LHS,
'name' => self::FIXUP_BRACED_NAME,
],
Expr\New_::class => ['class' => self::FIXUP_NEW],
Expr\MethodCall::class => [
'var' => self::FIXUP_DEREF_LHS,

View File

@ -47,6 +47,7 @@ $x instanceof Foo;
Foo :: bar;
Foo :: $bar;
Foo :: bar();
Foo :: bar;
-----
$stmts[0]->expr->name = new Expr\Variable('a');
$stmts[1]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
@ -64,6 +65,7 @@ $stmts[10]->expr->class = new Scalar\String_('Foo');
$stmts[11]->expr->class = new Expr\ConstFetch(new Node\Name('FOO'));
$stmts[12]->expr->class = new Expr\ConstFetch(new Node\Name('FOO'));
$stmts[13]->expr->class = new Expr\ConstFetch(new Node\Name('FOO'));
$stmts[14]->expr->name = new Expr\Variable('bar');
-----
<?php
$a ();
@ -80,3 +82,4 @@ $x instanceof ('Foo');
(FOO) :: bar;
(FOO) :: $bar;
(FOO) :: bar();
Foo :: {$bar};