Skip to content

ReflectionClass::toString() should have better output for enums #15766

Closed
@DanielEScherzer

Description

@DanielEScherzer

Description

Tested against git master, see https://3v4l.org/hColU/rfc#vgit.master - when outputting a reflection class (or the subclass ReflectionEnum) for enums, the output be improved a bit (below each suggestion is a snippet from the current output)

  • the heading with the basic type information should say that it is an enum, rather than a final class, and remove the interface implementations, instead indicating the backing type if any
Class [ <user> final class Suit implements UnitEnum ] {
Class [ <user> final class MyBool implements UnitEnum, BackedEnum ] {
  - Static properties [0] {
  }
  • the "Constants" block should only include the regular class constants, and the cases be indicated separately, and for backed enums include their values
  - Constants [5] {
    Constant [ public Suit Hearts ] { Object }
    Constant [ public Suit Diamonds ] { Object }
    Constant [ public Suit Clubs ] { Object }
    Constant [ public Suit Spades ] { Object }
    Constant [ public Suit OtherHearts ] { Object }
  }

  - Constants [3] {
    Constant [ public MyBool MyFalse ] { Object }
    Constant [ public MyBool MyTrue ] { Object }
    Constant [ public MyBool OtherTrue ] { Object }
  }

If there is support for these improvements, please assign this task to me

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions