rouge icon indicating copy to clipboard operation
rouge copied to clipboard

php: Support enum definition

Open nsfisis opened this issue 2 months ago • 0 comments

Part of https://github.com/rouge-ruby/rouge/issues/2169

Support enum definition since PHP 8.1.

https://www.php.net/manual/en/language.enumerations.basics.php

enum Suit
{
    case Hearts;
    case Diamonds;
    case Clubs;
    case Spades;
}

https://www.php.net/manual/en/language.enumerations.backed.php

enum Suit: string
{
    case Hearts = 'H';
    case Diamonds = 'D';
    case Clubs = 'C';
    case Spades = 'S';
}

This pull requests introduced three new states:

  • in_enum
  • in_enum_base_type: handles syntax rule of backed-enum, an enum type having base type.
  • in_enum_body: handles case keyword.

nsfisis avatar Oct 27 '25 17:10 nsfisis