File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,13 @@ def builtins
248248 groups Keyword ::Declaration , Text , Name ::Class
249249 end
250250
251+ rule %r/(enum)
252+ (\s +)
253+ (#{ id_with_ns } )/ix do |m |
254+ groups Keyword ::Declaration , Text , Name ::Class
255+ push :in_enum
256+ end
257+
251258 mixin :names
252259
253260 rule %r/[;,\( \) \{ \} \[ \] ]/ , Punctuation
@@ -386,6 +393,29 @@ def builtins
386393 mixin :whitespace
387394 mixin :return
388395 end
396+
397+ state :in_enum do
398+ rule %r/:/ , Punctuation , :in_enum_base_type
399+ rule %r/\{ / , Punctuation , :in_enum_body
400+ mixin :escape
401+ mixin :whitespace
402+ mixin :return
403+ end
404+
405+ state :in_enum_base_type do
406+ rule id , Keyword ::Type , :pop!
407+ mixin :escape
408+ mixin :whitespace
409+ mixin :return
410+ end
411+
412+ state :in_enum_body do
413+ rule %r/\} / , Punctuation , :pop!
414+ rule %r/(case)(\s +)(#{ id } )/i do
415+ groups Keyword , Text , Name ::Constant
416+ end
417+ mixin :php
418+ end
389419 end
390420 end
391421end
Original file line number Diff line number Diff line change @@ -233,6 +233,22 @@ interface SomeInterface {
233233}
234234
235235
236+ /* Enums */
237+
238+ enum Suit {
239+ case Hearts;
240+ case Diamonds;
241+ case Clubs;
242+ case Spades;
243+ }
244+ enum Status: string {
245+ case Pending = 'pending';
246+ case Processing = 'processing';
247+ case Completed = 'completed';
248+ case Failed = 'failed';
249+ }
250+
251+
236252/* Imports */
237253
238254use some\namespace\ClassA;
You can’t perform that action at this time.
0 commit comments