3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasImplicitNullDefaultValue(\ReflectionProperty $reflection): bool { if (null !== $reflection->getDefaultValue()) { return false; } if (false === $reflection->getDocComment()) { return true; } $docComment = $reflection->getDocComment(); if (!preg_match('/@var\s+([^\s]+)/', $docComment, $matches)) { return true; } return false !== strpos(strtolower($matches[1]), 'null'); } class foo { public $foo; /** * @var int */ public $bar; /** * @var int|null */ public $baz; } echo '$foo' . PHP_EOL; echo 'Implicit null set. As we do not know otherwise null is fine' . PHP_EOL; $reflection = new ReflectionProperty('foo', 'foo'); var_Dump($reflection->hasDefaultValue()); var_Dump($reflection->getDefaultValue()); var_Dump(hasImplicitNullDefaultValue($reflection)); echo PHP_EOL . '$bar' . PHP_EOL; echo 'null can not be an implicit value as this should be an int' . PHP_EOL; $reflection = new ReflectionProperty('foo', 'bar'); var_Dump($reflection->hasDefaultValue()); var_Dump($reflection->getDefaultValue()); var_Dump(hasImplicitNullDefaultValue($reflection)); echo PHP_EOL . '$baz' . PHP_EOL; echo 'Null is explicitly allowed as type, so the implicit null is fine' . PHP_EOL; $reflection = new ReflectionProperty('foo', 'baz'); var_Dump($reflection->hasDefaultValue()); var_Dump($reflection->getDefaultValue()); var_Dump(hasImplicitNullDefaultValue($reflection));

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.10.0060.00316.87
8.5.00.0110.01120.27
8.4.150.0020.00014.05
8.4.140.0280.01217.72
8.4.130.0140.00718.90
8.4.120.0100.00924.17
8.4.110.0030.00820.99
8.4.100.0110.00919.04
8.4.90.0070.01120.60
8.4.80.0120.00818.71
8.4.70.0090.00318.78
8.4.60.0160.00718.75
8.4.50.0090.01120.35
8.4.40.0130.00718.81
8.4.30.0090.00920.39
8.4.20.0160.00321.34
8.4.10.0160.00619.63
8.3.280.0110.00918.63
8.3.270.0110.01416.62
8.3.260.0150.00516.66
8.3.250.0120.00718.95
8.3.240.0120.00617.19
8.3.230.0040.00416.74
8.3.220.0090.00719.09
8.3.210.0110.00818.44
8.3.200.0060.00416.84
8.3.190.0090.00917.32
8.3.180.0110.00818.75
8.3.170.0100.00717.20
8.3.160.0200.00018.32
8.3.150.0120.00617.36
8.3.140.0040.00416.88
8.3.130.0330.01016.41
8.3.120.0330.00816.43
8.3.110.0320.00916.54
8.3.100.0420.00316.77
8.3.90.0430.00416.75
8.3.80.0450.00816.76
8.3.70.0380.00616.78
8.3.60.0310.01416.79
8.3.50.0220.02216.59
8.3.40.0290.00617.70
8.3.30.0180.01817.64
8.3.20.0280.01117.73
8.3.10.0300.00717.50
8.3.00.0220.00417.70
8.2.290.0070.00420.51
8.2.280.0170.00318.49
8.2.270.0110.01116.56
8.2.260.0090.00917.44
8.2.250.0340.00316.57
8.2.240.0280.01116.90
8.2.230.0220.01116.53
8.2.220.0250.00916.63
8.2.210.0260.01416.56
8.2.200.0320.00016.78
8.2.190.0290.00416.61
8.2.180.0230.01316.36
8.2.170.0370.00717.69
8.2.160.0290.01117.65
8.2.150.0370.00417.70
8.2.140.0360.00617.41
8.2.130.0380.00317.45
8.2.120.0340.00817.67
8.2.110.0370.00317.64
8.2.100.0320.00317.63
8.2.90.0330.00017.73
8.2.80.0350.00417.54
8.2.70.0360.00717.66
8.2.60.0450.00317.62
8.2.50.0360.00317.63
8.2.40.0310.00717.57
8.2.30.0320.00417.45
8.2.20.0190.00617.39
8.2.10.0150.02217.40
8.2.00.0300.00717.59
8.1.330.0110.00821.97
8.1.320.0100.00916.10
8.1.310.0060.01216.72
8.1.300.0320.00716.33
8.1.290.0300.00816.48
8.1.280.0310.00816.18
8.1.270.0280.01317.20
8.1.260.0220.01117.89
8.1.250.0300.01017.33
8.1.240.0280.00817.41
8.1.230.0220.01117.54
8.1.220.0210.01417.39
8.1.210.0290.00717.57
8.1.200.0220.00717.41
8.1.190.0270.00917.20
8.1.180.0290.00617.11
8.1.170.0240.01217.64
8.1.160.0300.00617.32
8.1.150.0230.01317.32
8.1.140.0270.00917.28
8.1.130.0290.00717.46
8.1.120.0290.00717.42
8.1.110.0250.01217.39
8.1.100.0250.00717.33
8.1.90.0220.00717.39
8.1.80.0250.01117.25
8.1.70.0390.00317.41
8.1.60.0380.00317.58
8.1.50.0220.01317.64
8.1.40.0280.00517.54
8.1.30.0290.00717.67
8.1.20.0270.00717.51
8.1.10.0280.00417.54
8.1.00.0330.00617.45

preferences:
33.45 ms | 403 KiB | 5 Q