3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Version { const STAGE_ALPHA = 1; const STAGE_BETA = 2; const STAGE_RC = 3; const STAGE_RELEASE = 4; public $major; public $minor; public $release; public $stageName; public $stageNo; private $stageMap = [ 'alpha' => self::STAGE_ALPHA, 'beta' => self::STAGE_BETA, 'rc' => self::STAGE_RC, ]; /** * @param string $version * @throws \Exception */ public function __construct($version) { static $tagNameExpr = '# ^ v? (?P<major>[0-9]+) \. (?P<minor>[0-9]+) (?:\.(?P<release>[0-9]+))? (?:- (?P<stage>alpha|beta|rc) (?:(?P<stageno>\d+))? )? $ #ix'; if (!preg_match($tagNameExpr, trim(strtolower($version)), $match)) { throw new \Exception('Invalid version spec string'); } $this->major = (int)$match['major']; $this->minor = (int)$match['minor']; $this->release = isset($match['release']) ? (int)$match['release'] : null; $this->stageName = isset($match['stage']) ? $match['stage'] : ''; $this->stageNo = isset($match['stageno']) ? (int)$match['stageno'] : null; } /** * @return string */ public function __toString() { return "$this->major.$this->minor." . ($this->release ?: 0) . ($this->stageNo ? '-' . $this->stageName . $this->stageNo : ''); } /** * @param string[] $stages * @return bool */ public function isValidNextStage(array $stages) { $latestStageType = $latestStagePoint = 0; foreach ($stages as $stage) { if ($stage === '') { // a release already exists return false; } if (preg_match('#^(alpha|beta|rc)(\d+)$#', strtolower($stage), $match)) { if ($this->stageMap[$match[1]] > $latestStageType) { $latestStageType = $this->stageMap[$match[1]]; $latestStagePoint = 0; } else if ($this->stageMap[$match[1]] === $latestStageType && $match[2] > $latestStagePoint) { $latestStagePoint = (int)$match[2]; } } } if (!$this->stageName) { // this is a release and one does not yet exist return true; } if (!isset($this->stageMap[$this->stageName])) { // invalid new stage return false; } if ($this->stageMap[$this->stageName] < $latestStageType) { // new stage lower than latest return false; } if ($this->stageMap[$this->stageName] > $latestStageType) { // new stage greater than latest, number must be 1 if (!isset($this->stageNo)) { $this->stageNo = 1; return true; } return $this->stageNo === 1; } if (!isset($this->stageNo)) { $this->stageNo = $latestStagePoint + 1; return true; } return $this->stageNo === $latestStagePoint + 1; } } var_dump(new Version('1.12-beta'));

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.0070.00718.68
8.3.50.0250.01121.23
8.3.40.0140.00718.92
8.3.30.0110.00319.08
8.3.20.0050.00320.33
8.3.10.0060.00323.52
8.3.00.0090.00317.88
8.2.180.0120.00318.51
8.2.170.0120.00322.96
8.2.160.0100.00619.11
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0000.00822.40
8.2.110.0090.00922.25
8.2.100.0090.00318.00
8.2.90.0000.00819.40
8.2.80.0050.00317.97
8.2.70.0040.00417.75
8.2.60.0080.00318.05
8.2.50.0060.00318.07
8.2.40.0040.00420.01
8.2.30.0060.00318.14
8.2.20.0040.00417.93
8.2.10.0040.00418.13
8.2.00.0040.00418.01
8.1.280.0220.00025.92
8.1.270.0060.00323.96
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0090.00023.82
8.1.230.0090.00319.17
8.1.220.0030.00617.91
8.1.210.0000.00918.77
8.1.200.0090.00017.60
8.1.190.0040.00417.38
8.1.180.0030.00518.10
8.1.170.0030.00518.81
8.1.160.0020.00522.00
8.1.150.0040.00418.92
8.1.140.0000.00817.70
8.1.130.0030.00317.87
8.1.120.0040.00417.59
8.1.110.0040.00417.61
8.1.100.0000.00817.57
8.1.90.0020.00517.64
8.1.80.0070.00017.53
8.1.70.0040.00417.64
8.1.60.0030.00617.82
8.1.50.0040.00417.70
8.1.40.0090.00017.68
8.1.30.0000.00817.89
8.1.20.0000.00817.70
8.1.10.0040.00417.71
8.1.00.0020.00517.70
8.0.300.0040.00418.77
8.0.290.0000.00817.00
8.0.280.0000.00718.52
8.0.270.0000.00717.23
8.0.260.0070.00017.38
8.0.250.0030.00317.09
8.0.240.0030.00317.05
8.0.230.0080.00016.98
8.0.220.0000.01016.89
8.0.210.0000.00716.90
8.0.200.0060.00016.95
8.0.190.0060.00317.11
8.0.180.0000.00717.07
8.0.170.0040.00416.96
8.0.160.0070.00017.13
8.0.150.0040.00416.96
8.0.140.0030.00517.01
8.0.130.0000.00713.55
8.0.120.0060.00317.10
8.0.110.0040.00417.11
8.0.100.0040.00417.05
8.0.90.0040.00417.05
8.0.80.0120.00617.04
8.0.70.0030.00517.05
8.0.60.0000.00717.11
8.0.50.0040.00416.89
8.0.30.0120.01117.42
8.0.20.0150.01017.54
8.0.10.0040.00417.09
8.0.00.0100.00816.95
7.4.330.0050.00015.00
7.4.320.0000.00616.68
7.4.300.0030.00316.80
7.4.290.0070.00316.72
7.4.280.0040.00416.84
7.4.270.0040.00416.78
7.4.260.0030.00316.66
7.4.250.0000.00816.75
7.4.240.0060.00216.75
7.4.230.0070.00016.59
7.4.220.0070.01816.80
7.4.210.0060.00916.75
7.4.200.0000.00716.52
7.4.160.0030.01316.49
7.4.150.0100.00717.40
7.4.140.0080.01717.86
7.4.130.0080.01116.79
7.4.120.0070.01116.89
7.4.110.0060.01216.76
7.4.100.0080.00816.73
7.4.90.0120.00616.85
7.4.80.0100.01319.39
7.4.70.0060.01416.75
7.4.60.0180.00616.68
7.4.50.0040.00416.55
7.4.40.0150.00616.84
7.4.30.0150.00316.66
7.4.00.0090.00415.11
7.3.330.0000.00513.56
7.3.320.0000.00513.43
7.3.310.0050.00216.61
7.3.300.0020.00516.42
7.3.290.0080.00616.42
7.3.280.0060.01216.49
7.3.270.0060.01217.40
7.3.260.0070.01116.54
7.3.250.0170.00316.63
7.3.240.0080.01316.50
7.3.230.0110.00616.61
7.3.210.0090.00916.75
7.3.200.0130.00419.39
7.3.190.0070.01716.75
7.3.180.0030.01316.64
7.3.170.0140.00316.55
7.3.160.0160.00616.43
7.2.330.0040.01517.03
7.2.320.0150.00316.79
7.2.310.0090.01516.97
7.2.300.0000.01717.02
7.2.290.0030.02016.84
7.2.00.0030.01319.69
7.1.100.0040.00818.30
7.1.70.0040.00417.18
7.1.60.0180.00619.32
7.1.50.0040.01816.97
7.1.00.0030.07722.50
7.0.200.0070.00016.55
7.0.140.0100.06722.10
7.0.60.0070.08720.10
7.0.50.0130.07318.01
7.0.40.0070.04320.07
7.0.30.0330.04320.26
7.0.20.0270.07020.13
7.0.10.0030.09320.08
7.0.00.0170.05320.25
5.6.280.0070.07021.11
5.6.210.0130.08020.58
5.6.200.0100.03318.19
5.6.190.0030.04320.52
5.6.180.3270.03720.50
5.6.170.0200.03720.50
5.6.160.0130.05720.48
5.6.150.0130.06718.23
5.6.140.0070.03718.28
5.6.130.0100.07318.27
5.6.120.0130.07721.02
5.6.110.0070.04020.98
5.6.100.0100.07721.16
5.6.90.0030.08720.97
5.6.80.0030.08320.59
5.6.70.3670.03320.50
5.5.350.0070.08720.42
5.5.340.0070.03717.99
5.5.330.0030.08320.56
5.5.320.0330.04720.24
5.5.310.0330.06720.33
5.5.300.0100.08717.98
5.5.290.0030.07018.02
5.5.280.0030.04720.80
5.5.270.0030.08720.89
5.5.260.0000.06720.79
5.5.250.0170.07720.63
5.5.240.0230.06720.21
5.4.450.0900.05019.70
5.4.440.1000.05719.61
5.4.430.1030.05319.30
5.4.420.0700.00019.52
5.4.410.0670.00019.26
5.4.400.0670.00018.92
5.4.390.0630.00019.07
5.4.380.0670.00018.98
5.4.370.0670.00019.26
5.4.360.0630.00019.16
5.4.350.0830.00018.98
5.4.340.0070.03412.04
5.4.320.0050.03812.52
5.4.310.0080.04012.52
5.4.300.0080.04512.53
5.4.290.0120.03512.52
5.4.280.0040.03912.42
5.4.270.0080.03512.42
5.4.260.0100.04012.42
5.4.250.0100.03912.42
5.4.240.0050.03912.42
5.4.230.0100.04012.41
5.4.220.0070.03612.41
5.4.210.0090.04312.41
5.4.200.0100.03512.41
5.4.190.0060.04112.40
5.4.180.0060.04012.41
5.4.170.0080.03512.42
5.4.160.0050.03612.41
5.4.150.0070.03512.41
5.4.140.0050.03812.09
5.4.130.0090.03312.08
5.4.120.0050.04612.04
5.4.110.0040.04012.04
5.4.100.0050.03712.03
5.4.90.0100.03412.04
5.4.80.0030.04312.04
5.4.70.0060.04212.03
5.4.60.0060.03512.03
5.4.50.0080.03412.04
5.4.40.0110.04212.02
5.4.30.0080.03412.02
5.4.20.0040.03712.02
5.4.10.0050.03612.02
5.4.00.0060.03511.50
5.3.290.0070.04112.80
5.3.280.0080.04812.71
5.3.270.0090.04412.73
5.3.260.0070.05512.72
5.3.250.0100.04012.71
5.3.240.0040.04612.72
5.3.230.0060.04112.71
5.3.220.0110.03212.68
5.3.210.0080.03812.68
5.3.200.0080.03612.68
5.3.190.0100.03912.68
5.3.180.0080.03812.68
5.3.170.0030.03912.67
5.3.160.0100.03212.67
5.3.150.0090.04412.67
5.3.140.0060.04012.66
5.3.130.0060.03912.65
5.3.120.0090.04012.66
5.3.110.0080.03612.66
5.3.100.0070.03912.12
5.3.90.0060.03612.10
5.3.80.0050.03812.09
5.3.70.0070.03812.09
5.3.60.0090.03912.08
5.3.50.0070.04412.02
5.3.40.0050.03712.02
5.3.30.0040.04411.98
5.3.20.0090.03311.76
5.3.10.0070.03711.73
5.3.00.0070.04111.71
5.2.170.0050.0339.22
5.2.160.0100.0319.22
5.2.150.0020.0349.22
5.2.140.0050.0309.23
5.2.130.0050.0299.18
5.2.120.0080.0329.18
5.2.110.0060.0279.18
5.2.100.0090.0289.18
5.2.90.0070.0329.18
5.2.80.0020.0329.18
5.2.70.0070.0299.18
5.2.60.0080.0309.13
5.2.50.0070.0309.10
5.2.40.0040.0309.07
5.2.30.0050.0299.05
5.2.20.0020.0339.04
5.2.10.0080.0298.94
5.2.00.0060.0278.80
5.1.60.0060.0228.09
5.1.50.0060.0238.09
5.1.40.0060.0228.07
5.1.30.0090.0318.42
5.1.20.0050.0298.44
5.1.10.0030.0278.17
5.1.00.0040.0288.16
5.0.50.0040.0206.64
5.0.40.0020.0216.50
5.0.30.0010.0336.32
5.0.20.0000.0236.28
5.0.10.0050.0186.26
5.0.00.0020.0326.25
4.4.90.0060.0124.78
4.4.80.0020.0164.75
4.4.70.0040.0164.76
4.4.60.0040.0154.75
4.4.50.0060.0124.77
4.4.40.0040.0244.71
4.4.30.0020.0164.76
4.4.20.0020.0164.85
4.4.10.0020.0244.85
4.4.00.0050.0264.76
4.3.110.0040.0144.67
4.3.100.0000.0234.66
4.3.90.0020.0154.63
4.3.80.0030.0244.58
4.3.70.0040.0164.63
4.3.60.0020.0154.63
4.3.50.0040.0174.63
4.3.40.0020.0274.54
4.3.30.0000.0183.30
4.3.20.0030.0203.29
4.3.10.0010.0173.24
4.3.00.0200.0177.23

preferences:
42.62 ms | 401 KiB | 5 Q