plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Unexpected syntax error with multi-level scope resolution

Open plafrance opened this issue 2 years ago • 1 comments

@prettier/plugin-php v0.19.4 Playground link

Input:

<?php
enum Bar: int {
    case test = 42;
}

class Foo
{
	const BarInFoo = Bar::test;
}

print Foo::BarInFoo::class; //Prints Bar
?>

Output:

Parse Error : syntax error, unexpected '::' (T_DOUBLE_COLON) on line 11

   9 | }
  10 |
> 11 | print Foo::BarInFoo::class; //Prints Bar
     |                   ^
  12 | ?>

Expected behavior:

No error reported.

plafrance avatar Apr 30 '23 16:04 plafrance

Hi @plafrance, thanks for the bug report. This seems to be a parser problem, I created an issue for it: https://github.com/glayzzle/php-parser/issues/1093

czosel avatar Apr 30 '23 18:04 czosel