<?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.
@prettier/plugin-php v0.22.1 Playground link
Input:
Output:
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.