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

Class Name From Class Variable Throws Exception

Open cyreb7 opened this issue 1 year ago • 1 comments

There seems to be a PHP Prettier parse exception when ::class is called on a class property. This is a contrived example, but the following is a minimal reproducible example that throws an exception when checked:

class Test
{
    public $exception;

    public function test()
    {
        $this->exception = new \Exception("test");
        return $this->exception::class; // Throws "SyntaxError: Parse Error : syntax error, unexpected 'class' (T_CLASS)"
    }
}

Happens on the PHP Prettier playground and my local with:

  • Node 18.20.5
  • Prettier 3.4.2
  • PHP Prettier 0.22.2

cyreb7 avatar Dec 13 '24 00:12 cyreb7