- Output for 8.2.6
- string(15) "value is => [1]"
<?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();