3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class HookWithDependency { public function __construct( public readonly string $name, public readonly ?string $type = 'module', ) { } } #[HookWithDependency(name: 'bar')] class Example {} $reflectionClass = new \ReflectionClass(Example::class); var_dump($reflectionClass->getAttributes()[0]->newInstance());

preferences:
59.43 ms | 849 KiB | 5 Q