3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_FUNCTION|Attribute::TARGET_METHOD)] class Template { public function __construct( public string $name, public ?string $of = null, ) {} } #[Attribute(Attribute::TARGET_FUNCTION|Attribute::TARGET_METHOD|Attribute::TARGET_PARAMETER|Attribute::TARGET_PROPERTY)] class Type { public function __construct( public string $name, ) {} } #[Template(T)] #[Type(array<int,T>)] function asArray( #[Type(T)] $value, ): array { return [$value]; }
Output for 8.0.0
Parse error: syntax error, unexpected token "<", expecting ":" in /in/sQ4Ah on line 22
Process exited with code 255.
Output for 7.3.0 - 7.3.25, 7.4.0 - 7.4.13
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/sQ4Ah on line 7
Process exited with code 255.

preferences:
31.42 ms | 457 KiB | 5 Q