<?php enum Status: int { case Open = 1; case Close = 2; } #[Attribute] class Bar { private int $value; public function __construct(int $value) { $this->value = $value; } public function debug() { var_dump("value is => [{$this->value}]"); } } #[Bar(Status::Open->value)] class Foo { } $reflector = new \ReflectionClass(Foo::class); $attributes = $reflector->getAttributes(); $bar = $attributes[0]->newInstance(); $bar->debug();
You have javascript disabled. You will not be able to edit any code.