<?php class RandomValue { public string $value; public function __construct(string $prefix) { $this->value = $prefix . random_int(1,100); } } #[Attribute] class Foo { public function __construct(public readonly RandomValue $bar) {} } #[Foo(new RandomValue('FooBar: '))] class Bar { } $ref = new ReflectionClass(Bar::class); $attribute = $ref->getAttributes()[0]; var_dump($attribute->getArguments()); var_dump($attribute->getArguments()); var_dump($attribute->getArguments());
You have javascript disabled. You will not be able to edit any code.