3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class HookDependsOn { public function __construct( public readonly ?string $module = NULL, ) { } } #[HookDependsOn(foo: 'bar')] class Example {} $reflectionClass = new \ReflectionClass(Example::class); var_dump($reflectionClass->getAttributes()[0]->newInstance());
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Uncaught Error: Unknown named parameter $foo in /in/31a3W:14 Stack trace: #0 /in/31a3W(19): ReflectionAttribute->newInstance() #1 {main} thrown in /in/31a3W on line 14
Process exited with code 255.

preferences:
29.29 ms | 406 KiB | 5 Q