3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute] class BaseAttribute { public function __construct(public readonly string $name) { } } #[Attribute] class ConstantlyNameAttribute extends BaseAttribute { public function __construct() { parent::__construct('Chris'); } } #[ConstantlyNameAttribute] class Thing{} $reflectionClass = new ReflectionClass(Thing::class); // Doesn't work var_dump(getName($reflectionClass->getAttributes(BaseAttribute::class))); // Works var_dump(getName($reflectionClass->getAttributes(BaseAttribute::class, ReflectionAttribute::IS_INSTANCEOF))); // Helper function function getName(array $reflectionAttributes) : ?string { if(!count($reflectionAttributes)){ return null; } $attribute = array_pop($reflectionAttributes); return $attribute->newInstance()->name; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.00.0120.01019.79
8.4.150.0030.00014.05
8.4.140.0110.00918.49
8.4.130.0140.00617.86
8.4.120.0130.00722.33
8.4.110.0130.00718.81
8.4.100.0100.01117.94
8.4.90.0130.00720.58
8.4.80.0100.00818.81
8.4.70.0030.00519.54
8.4.60.0110.01018.89
8.4.50.0100.01120.38
8.4.40.0060.00317.57
8.4.30.0130.00618.63
8.4.20.0100.01019.32
8.4.10.0090.00619.64
8.3.280.0110.00918.44
8.3.270.0090.01116.77
8.3.260.0080.01116.68
8.3.250.0030.00719.09
8.3.240.0070.00816.87
8.3.230.0110.00416.57
8.3.220.0040.00419.17
8.3.210.0030.00518.48
8.3.200.0070.00416.86
8.3.190.0020.00617.22
8.3.180.0120.00617.23
8.3.170.0080.00020.75
8.3.160.0050.00318.46
8.3.150.0090.00917.27
8.3.140.0070.01119.11
8.3.130.0060.00318.44
8.3.120.0090.00620.88
8.3.110.0060.01222.58
8.3.100.0050.00322.58
8.3.80.0250.00830.84
8.3.50.0030.00622.58
8.2.290.0110.00916.49
8.2.280.0080.00218.23
8.2.270.0120.00617.36
8.2.260.0150.00318.17
8.2.250.0040.00418.67
8.2.240.0000.00716.96
8.2.230.0040.00822.58
8.2.220.0040.00422.58
8.1.330.0120.00716.31
8.1.320.0080.01217.77
8.1.310.0030.01418.58
8.1.300.0000.00918.05

preferences:
36.28 ms | 403 KiB | 5 Q