Skip to content

Class Name From Class Variable Throws Exception #2410

Open
@cyreb7

Description

@cyreb7

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions