3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ParentClass { protected readonly int $value; } trait Foo { protected readonly int $value; } class ChildClassWithoutTrait extends ParentClass { protected readonly int $value; } $reflector = new ReflectionClass(ChildClassWithoutTrait::class); $instance = $reflector->newInstanceWithoutConstructor(); var_dump( $reflector->hasProperty('value'), $prop = $reflector->getProperty('value') ); $prop->setValue($instance, 20); var_dump($instance); echo '--------------------------------------------------------------------------------------------------------', PHP_EOL; class ClassWithTraitAndNoParent { use Foo; } $reflector = new ReflectionClass(ClassWithTraitAndNoParent::class); $instance = $reflector->newInstanceWithoutConstructor(); var_dump( $reflector->hasProperty('value'), $prop = $reflector->getProperty('value') ); $prop->setValue($instance, 20); var_dump($instance); echo '--------------------------------------------------------------------------------------------------------', PHP_EOL; class ChildClassWithTrait extends ParentClass { use Foo; } $reflector = new ReflectionClass(ChildClassWithTrait::class); $instance = $reflector->newInstanceWithoutConstructor(); var_dump( $reflector->hasProperty('value'), $prop = $reflector->getProperty('value') ); $prop->setValue($instance, 20); var_dump($instance);

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.4.120.0150.00618.51
8.4.110.0060.00420.50
8.4.100.0110.00918.00
8.4.90.0060.00420.67
8.4.80.0040.00320.44
8.4.70.0110.01018.91
8.4.60.0070.00122.31
8.4.50.0200.00819.06
8.4.40.0260.00817.50
8.4.30.0270.00819.16
8.4.20.0280.00918.29
8.4.10.0300.00618.35
8.3.250.0080.00416.84
8.3.240.0100.01016.81
8.3.230.0110.00816.79
8.3.220.0090.00918.85
8.3.210.0060.01416.81
8.3.200.0030.00616.76
8.3.190.0250.00817.67
8.3.180.0240.00818.01
8.3.170.0220.00516.89
8.3.160.0210.01116.72
8.3.150.0170.00516.73
8.3.140.0090.00616.60
8.3.130.0140.00117.74
8.3.120.0080.00618.78
8.3.110.0260.00916.55
8.3.100.0360.00716.55
8.3.90.0360.00616.82
8.3.80.0340.00716.46
8.3.70.0350.00616.50
8.3.60.0380.00916.47
8.3.50.0350.00616.49
8.3.40.0320.00917.43
8.3.30.0350.00617.44
8.3.20.0370.00517.49
8.3.10.0290.00817.44
8.3.00.0190.00818.05
8.2.290.0110.00617.24
8.2.280.0220.00717.45
8.2.270.0200.00916.65
8.2.260.0180.00716.75
8.2.250.0170.00816.66
8.2.240.0220.00617.69
8.2.230.0200.01016.53
8.2.220.0310.00516.63
8.2.210.0260.00716.65
8.2.200.0270.00716.41
8.2.190.0240.01016.34
8.2.180.0280.00816.48
8.2.170.0280.01217.67
8.2.160.0280.00717.64
8.2.150.0290.00517.55
8.2.140.0300.00617.50
8.2.130.0260.01017.48
8.2.120.0310.00617.55
8.2.110.0350.00917.54
8.2.100.0360.00517.58
8.2.90.0350.00817.53
8.2.80.0370.00917.41
8.2.70.0350.01017.36
8.2.60.0360.00917.51
8.2.50.0340.00717.57
8.2.40.0320.01017.45
8.2.30.0340.00717.44
8.2.20.0310.01017.31
8.2.10.0310.00617.53
8.2.00.0310.00617.41
8.1.330.0130.00616.20
8.1.320.0110.00517.08
8.1.310.0200.00416.23
8.1.300.0250.00416.44
8.1.290.0350.00816.04
8.1.280.0340.00816.21
8.1.270.0240.01217.26
8.1.260.0320.00717.27
8.1.250.0360.00817.18
8.1.240.0290.00517.17
8.1.230.0300.00817.18
8.1.220.0270.00917.20
8.1.210.0280.00817.12
8.1.200.0320.00817.22
8.1.190.0340.00517.21
8.1.180.0270.01117.13
8.1.170.0290.00817.22
8.1.160.0320.00817.14
8.1.150.0350.00817.14
8.1.140.0330.00817.19
8.1.130.0330.00617.24
8.1.120.0300.00917.27
8.1.110.0270.01117.17
8.1.100.0300.00817.24
8.1.90.0350.00617.23
8.1.80.0290.01017.15
8.1.70.0320.00817.12
8.1.60.0370.00717.34
8.1.50.0340.00817.15
8.1.40.0310.01017.30
8.1.30.0290.00817.38
8.1.20.0340.00617.43
8.1.10.0290.01217.39
8.1.00.0310.00917.38

preferences:
40.64 ms | 403 KiB | 5 Q