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

Syntax error when attributes are defined to enum cases #2293

Open
kapersoft opened this issue Dec 17, 2023 · 0 comments
Open

Syntax error when attributes are defined to enum cases #2293

kapersoft opened this issue Dec 17, 2023 · 0 comments

Comments

@kapersoft
Copy link

@prettier/plugin-php v0.22.1
Playground link

Input:

<?php

namespace App\Enums;

use App\Support\Attributes\Description;

enum SalutationEnum: string
{
    #[Description('Mr.')]
    case MR = 'mr';

    #[Description('Mrs.')]
    case MRS = 'mrs';

    #[Description('Miss')]
    case MISS = 'miss';
}

Output:

Parse Error : syntax error, unexpected 'case' (T_CASE) on line 10

   8 | {
   9 |     #[Description('Mr.')]
> 10 |     case MR = 'mr';
     |    ^
  11 |
  12 |     #[Description('Mrs.')]
  13 |     case MRS = 'mrs';

I got the idea of using attributes to describe enum cases from this blogpost. The php code runs fine without any issues, but Prettier thinks it's a syntax error.

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

1 participant