Skip to content

how to generate a self::CONSTANT in an attribute #173

Description

@tacman

I'm trying to generate the following:

const PLACE_NEW = 'new';

#[Transition(from: self::PLACE_NEW)]
const TRANSITION='load';

Creating the constants is easy, but how do I create a self:: instead of the actual value? This isn't working:

            $from = 'self::PLACE_NEW'; // generates the string with self::, 
            $from = new Constant('PLACE_NEW', 'new')  // generates 'new', not self::PLACE_NEW

            $constant = $class->addConstant('TRANSITION');
            $constant->addAttribute(Transition::class, ['from' => $from]);

kinda tricky, but this library has is amazing so maybe it has something for this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions