Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Name From Class Variable Throws Exception #2410

Open
cyreb7 opened this issue Dec 13, 2024 · 1 comment
Open

Class Name From Class Variable Throws Exception #2410

cyreb7 opened this issue Dec 13, 2024 · 1 comment

Comments

@cyreb7
Copy link

cyreb7 commented Dec 13, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@cyreb7 and others