Skip to content

Support defining #[Meta] on traits #9

@stancl

Description

@stancl

That way, users can create a trait such as:

/**
 * @method string description()
 */
#[Meta(Description::class)
trait HasDescription
{}

And use this across their enums as:

enum Status
{
+   use HasDescription;

+   #[Description('Completed Task')]
    case COMPLETED;
}

enum Role
{
+   use HasDescription;

+   #[Description('Administrator')]
    case ADMIN;

+   #[Description('Read-only user')]
    case GUEST;
}

Implementation

Edit ArchTech\Enums\Meta\Reflection::metaProperties() to also recursively walk through the enum's traits, and extract the enabled meta properties in their #[Meta] attributes, if they're defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions