3v4l.org

run code in 500+ 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.5.90.0040.00316.91
8.5.80.0090.01016.85
8.5.70.0100.00816.83
8.5.60.0100.00816.64
8.5.50.0080.00918.46
8.5.30.0110.00619.24
8.5.20.0100.00819.93
8.5.10.0210.00918.13
8.5.00.0150.00717.45
8.4.240.0100.01219.82
8.4.230.0050.00419.67
8.4.220.0050.00519.61
8.4.210.0150.00819.45
8.4.180.0050.00519.58
8.4.170.0130.00823.96
8.4.160.0220.00922.21
8.4.150.0170.00618.32
8.4.140.0260.00717.69
8.4.130.0270.00918.04
8.4.120.0320.00717.93
8.4.110.0280.00718.68
8.4.100.0300.00917.75
8.4.90.0260.00818.61
8.4.80.0290.00718.68
8.4.70.0290.01118.10
8.4.60.0280.00519.31
8.4.50.0300.00818.43
8.4.40.0320.00917.55
8.4.30.0340.00818.37
8.4.20.0340.00818.01
8.4.10.0360.00717.95
8.3.330.0100.01218.73
8.3.320.0100.01018.75
8.3.310.0110.01018.59
8.3.300.0080.01422.87
8.3.290.0230.00819.65
8.3.280.0160.01018.34
8.3.270.0250.01116.68
8.3.260.0280.00816.77
8.3.250.0270.00916.79
8.3.240.0270.01116.72
8.3.230.0300.00816.73
8.3.220.0290.00917.39
8.3.210.0270.01116.70
8.3.200.0260.00716.77
8.3.190.0310.00917.23
8.3.180.0320.00817.32
8.3.170.0320.00516.76
8.3.160.0320.01116.77
8.3.150.0310.00716.69
8.3.140.0180.00716.67
8.3.130.0200.00417.21
8.3.120.0170.00717.70
8.3.110.0260.00916.59
8.3.100.0330.00616.70
8.3.90.0360.00716.71
8.3.80.0340.00816.59
8.3.70.0370.00716.59
8.3.60.0390.00916.47
8.3.50.0360.00816.57
8.3.40.0350.00917.68
8.3.30.0320.00817.57
8.3.20.0330.00817.67
8.3.10.0300.00817.66
8.3.00.0200.00917.96
8.2.320.0080.00818.23
8.2.310.0100.01018.04
8.2.300.0270.01118.47
8.2.290.0230.00916.87
8.2.280.0250.00917.17
8.2.270.0280.00716.63
8.2.260.0250.00816.57
8.2.250.0250.00916.73
8.2.240.0280.00717.12
8.2.230.0250.01016.59
8.2.220.0310.00716.66
8.2.210.0290.00716.65
8.2.200.0300.00816.43
8.2.190.0270.01016.47
8.2.180.0300.00816.54
8.2.170.0290.01117.88
8.2.160.0300.00917.80
8.2.150.0290.00717.71
8.2.140.0310.00717.65
8.2.130.0280.00917.64
8.2.120.0320.00517.65
8.2.110.0340.00817.67
8.2.100.0340.00717.66
8.2.90.0330.00917.73
8.2.80.0330.00817.57
8.2.70.0330.01017.51
8.2.60.0330.00917.61
8.2.50.0310.00917.64
8.2.40.0310.01017.63
8.2.30.0340.00717.57
8.2.20.0340.00917.50
8.2.10.0320.00717.66
8.2.00.0310.00717.55
8.1.340.0190.00918.96
8.1.330.0190.00616.11
8.1.320.0160.00716.63
8.1.310.0220.00516.18
8.1.300.0260.00516.33
8.1.290.0340.00816.10
8.1.280.0330.00816.21
8.1.270.0260.01117.37
8.1.260.0310.00917.39
8.1.250.0330.00917.35
8.1.240.0280.00817.35
8.1.230.0280.01017.34
8.1.220.0260.01017.38
8.1.210.0290.00817.34
8.1.200.0290.00817.38
8.1.190.0310.00717.32
8.1.180.0280.01017.32
8.1.170.0290.00817.41
8.1.160.0330.00817.28
8.1.150.0330.00817.32
8.1.140.0320.00917.35
8.1.130.0310.00917.35
8.1.120.0300.01017.41
8.1.110.0290.01017.35
8.1.100.0310.00717.33
8.1.90.0310.00817.39
8.1.80.0300.00917.24
8.1.70.0300.00917.28
8.1.60.0350.00717.46
8.1.50.0320.00917.39
8.1.40.0310.00917.45
8.1.30.0300.00817.49
8.1.20.0330.00617.55
8.1.10.0300.01017.53
8.1.00.0330.00817.40

preferences:
45.29 ms | 1194 KiB | 5 Q