Skip to content

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

@tacman

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.

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