<?php #[Attribute()] class Foo { public function __construct( public int $a, public string $b ) { } } // With ordered arguments #[Foo(123, 'abc')] class Bar { } // With named arguments #[Foo( a: 123, b: 'abc' )] class Baz { } var_dump((new ReflectionClass(Bar::class))->getAttributes(Foo::class)[0]->newInstance()); var_dump((new ReflectionClass(Baz::class))->getAttributes(Foo::class)[0]->newInstance());
You have javascript disabled. You will not be able to edit any code.