3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Filters { /** * @return array */ public function toArray() { return array_map(function ($value) { return json_encode($value); }, get_object_vars($this)); } /** * @param array $arrayOfFilters * @return Filters */ public static function fromArray($arrayOfFilters) { $instance = new self; foreach ($arrayOfFilters as $key => $value) { $instance->{$key} = $value; } return $instance; } } final class UserFilters extends Filters { /** @var array */ private $registeredAtRange; /** * @param \DateTimeInterface $start * @param \DateTimeInterface|null $end */ public function setRegisteredAtRange(\DateTimeInterface $start, \DateTimeInterface $end = null) { if (is_null($end)) { $end = new \DateTime; } $this->registeredAtRange = [ 'start' => $start->format('Y-m-d H:i:s'), 'end' => $end->format('Y-m-d H:i:s'), ]; } /** * Will return 2 date time strings or null. * * @return array|null */ public function getRegisteredAtRange() { return $this->registeredAtRange; } } $a = new UserFilters; $a->setRegisteredAtRange(new DateTime('now')); $b = $a->toArray(); var_dump($b); var_dump(UserFilters::fromArray($b));

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.3.60.0120.00316.88
8.3.50.0100.01018.30
8.3.40.0040.01119.01
8.3.30.0000.01518.79
8.3.20.0050.00320.21
8.3.10.0000.00823.65
8.3.00.0050.00319.41
8.2.180.0000.01516.63
8.2.170.0140.00722.96
8.2.160.0110.00720.55
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00419.89
8.2.110.0030.00619.30
8.2.100.0070.00717.75
8.2.90.0080.00019.35
8.2.80.0040.00417.97
8.2.70.0060.00317.88
8.2.60.0040.00418.16
8.2.50.0030.00518.07
8.2.40.0000.00819.13
8.2.30.0050.00320.65
8.2.20.0060.00318.00
8.2.10.0000.00818.23
8.2.00.0000.01018.28
8.1.280.0100.00725.92
8.1.270.0000.00823.97
8.1.260.0000.00826.35
8.1.250.0000.00728.09
8.1.240.0050.00523.84
8.1.230.0090.00317.79
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00717.60
8.1.190.0000.00817.48
8.1.180.0040.00418.10
8.1.170.0070.00318.75
8.1.160.0040.00422.04
8.1.150.0000.00718.98
8.1.140.0040.00419.65
8.1.130.0070.00017.79
8.1.120.0050.00217.64
8.1.110.0070.00017.70
8.1.100.0050.00217.68
8.1.90.0040.00417.70
8.1.80.0000.00717.66
8.1.70.0000.00717.64
8.1.60.0030.00517.62
8.1.50.0040.00417.58
8.1.40.0080.00017.71
8.1.30.0000.00817.74
8.1.20.0000.00717.76
8.1.10.0000.00817.58
8.1.00.0040.00417.64
8.0.300.0060.00318.77
8.0.290.0070.00017.00
8.0.280.0000.00718.53
8.0.270.0000.00717.35
8.0.260.0070.00018.53
8.0.250.0000.00717.27
8.0.240.0040.00417.11
8.0.230.0000.00717.22
8.0.220.0050.00217.16
8.0.210.0000.00717.05
8.0.200.0030.00517.12
8.0.190.0050.00317.25
8.0.180.0000.00717.19
8.0.170.0000.00717.20
8.0.160.0050.00317.10
8.0.150.0050.00317.09
8.0.140.0060.00617.04
8.0.130.0060.00013.52
8.0.120.0030.00517.13
8.0.110.0030.00517.15
8.0.100.0050.00317.08
8.0.90.0070.00017.23
8.0.80.0060.01017.05
8.0.70.0040.00416.97
8.0.60.0000.00717.24
8.0.50.0040.00417.12
8.0.30.0120.00517.10
8.0.20.0080.01017.40
8.0.10.0040.00417.23
8.0.00.0080.00916.94
7.4.330.0000.00616.70
7.4.320.0000.00716.67
7.4.300.0000.00716.64
7.4.290.0040.00416.82
7.4.280.0030.00616.66
7.4.270.0000.00716.71
7.4.260.0030.00316.78
7.4.250.0000.00816.70
7.4.240.0010.00616.67
7.4.230.0070.00016.73
7.4.220.0070.01116.61
7.4.210.0080.00916.78
7.4.200.0000.00816.87
7.4.160.0110.00416.77
7.4.150.0090.00917.40
7.4.140.0120.00717.86
7.4.130.0110.00716.54
7.4.120.0080.01016.85
7.4.110.0060.01316.59
7.4.100.0120.01216.71
7.4.90.0030.01516.56
7.4.80.0070.01019.39
7.4.70.0100.01016.65
7.4.60.0110.01116.65
7.4.50.0030.01316.53
7.4.40.0030.01316.82
7.4.30.0060.01216.79
7.4.00.0040.01115.36
7.3.330.0070.00013.44
7.3.320.0030.00313.33
7.3.310.0030.00316.47
7.3.300.0030.00316.34
7.3.290.0000.00716.43
7.3.280.0090.00716.36
7.3.270.0140.00317.40
7.3.260.0080.00816.36
7.3.250.0090.00916.64
7.3.240.0080.01416.53
7.3.230.0120.00416.49
7.3.210.0100.00716.77
7.3.200.0000.01716.73
7.3.190.0060.01216.43
7.3.180.0130.00316.39
7.3.170.0120.01116.66
7.3.160.0060.01116.66
7.3.10.0060.00716.54
7.3.00.0180.00016.46
7.2.330.0060.01216.74
7.2.320.0090.01317.02
7.2.310.0170.01016.84
7.2.300.0090.00916.63
7.2.290.0060.01116.95
7.2.130.0060.00616.69
7.2.120.0120.00817.07
7.2.110.0060.00916.76
7.2.100.0110.00816.99
7.2.90.0070.01016.96
7.2.80.0190.00717.00
7.2.70.0030.01517.05
7.2.60.0080.01116.93
7.2.50.0070.01716.54
7.2.40.0130.01616.91
7.2.30.0100.00416.81
7.2.20.0160.00417.14
7.2.10.0040.01316.92
7.2.00.0110.00518.09
7.1.250.0130.00415.87
7.1.200.0040.00415.80
7.1.100.0030.00918.17
7.1.70.0000.00717.35
7.1.60.0070.01719.36
7.1.50.0120.01217.08
7.1.00.0070.07322.48
7.0.200.0000.00816.88
7.0.90.0430.07720.02
7.0.80.0570.08719.90
7.0.70.0300.04319.98
7.0.60.0530.07319.98
7.0.50.0670.08020.27
7.0.40.0030.08320.02
7.0.30.0100.08319.95
7.0.20.0000.09020.13
7.0.10.0100.06020.14
7.0.00.0070.04320.01
5.6.280.0000.06021.00
5.6.240.0130.08320.70
5.6.230.0200.06020.55
5.6.220.0000.06720.71
5.6.210.0130.06020.62
5.6.200.0070.09021.07
5.6.190.0130.07721.18
5.6.180.0130.07321.18
5.6.170.0030.07020.96
5.6.160.0100.04321.14
5.6.150.0030.08021.05
5.6.140.0000.05320.96
5.6.130.0270.06721.05
5.6.120.0130.05321.01
5.6.110.0130.08020.98
5.6.100.0200.07021.05
5.6.90.0000.08321.03
5.6.80.0000.07720.33
5.6.70.0030.04720.52
5.6.60.0100.04320.40
5.6.50.0070.07020.43
5.6.40.0100.07320.40
5.6.30.0030.06020.32
5.6.20.0200.07320.36
5.6.10.0070.07020.44
5.6.00.0100.07720.48
5.5.380.0170.06720.46
5.5.370.0100.05720.40
5.5.360.0100.07320.45
5.5.350.0070.06020.46
5.5.340.0100.07020.77
5.5.330.0130.04320.83
5.5.320.0130.07720.75
5.5.310.0070.08320.93
5.5.300.0070.07720.91
5.5.290.0070.08320.91
5.5.280.0070.08020.82
5.5.270.0070.04320.86
5.5.260.0070.07020.75
5.5.250.0000.08320.68
5.5.240.0030.08020.04
5.5.230.0170.07020.30
5.5.220.0130.07020.03
5.5.210.0130.07320.19
5.5.200.0070.07720.16
5.5.190.0270.04020.12
5.5.180.0070.08020.14
5.5.160.0100.06719.98
5.5.150.0070.08720.13
5.5.140.0170.03320.24
5.5.130.0000.08020.12
5.5.120.0030.05720.27
5.5.110.0100.07720.13
5.5.100.0000.05020.07
5.5.90.0030.04320.17
5.5.80.0130.06320.08
5.5.70.0000.04020.18
5.5.60.0000.05020.07
5.5.50.0030.06020.10
5.5.40.0030.04320.17
5.5.30.0030.06019.93
5.5.20.0200.06720.06
5.5.10.0130.07320.01
5.5.00.0100.07320.08

preferences:
46.68 ms | 401 KiB | 5 Q