3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace texdc\cicerone; use InvalidArgumentException; /** * Provides encapsulation and validation of HTTP method values * * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html */ final class HttpMethod { /**#@+ * method constants * @var string */ const ANY = '*'; const GET = 'GET'; const HEAD = 'HEAD'; const POST = 'POST'; const PUT = 'PUT'; const DELETE = 'DELETE'; const OPTIONS = 'OPTIONS'; const TRACE = 'TRACE'; /**#@- */ /** @var string[] */ private static $allValues = [ self::ANY, self::GET, self::HEAD, self::POST, self::PUT, self::DELETE, self::OPTIONS, self::TRACE, ]; /** @var self[] */ private static $instances = []; /** @var string */ private $value; /** * @param string $aValue * @throws InvalidArgumentException */ public function HttpMethod($aValue) { if (!self::validate($aValue)) { throw new InvalidArgumentException("Invalid method [$aValue]"); } $this->value = self::sanitize($aValue); self::$instances[$this->value] = $this; } /** * @param string $aMethod * @param array $arguments * @return self */ public static function __callStatic($aMethod, $arguments = []) { if (!isset(self::$instances[$aMethod])) { $instance = new static($aMethod); $aMethod = $instance->value; } var_dump(self::$instances); return self::$instances[$aMethod]; } /** * @param string $aValue * @return string */ public static function sanitize($aValue) { return trim(strtoupper($aValue)); } /** * @param string $aValue * @return bool */ public static function validate($aValue) { return in_array(self::sanitize($aValue), self::$allValues); } /** * @param string $aValue * @return bool */ public function hasValue($aValue) { return $this->value === (string) $aValue; } /** @return bool */ public function isAny() { return $this->hasValue(self::ANY); } /** @return bool */ public function isGet() { return $this->hasValue(self::GET) || $this->isAny(); } /** @return bool */ public function isHead() { return $this->hasValue(self::HEAD) || $this->isAny(); } /** @return bool */ public function isPost() { return $this->hasValue(self::POST) || $this->isAny(); } /** @return bool */ public function isPut() { return $this->hasValue(self::PUT) || $this->isAny(); } /** @return bool */ public function isDelete() { return $this->hasValue(self::DELETE) || $this->isAny(); } /** @return bool */ public function isOptions() { return $this->hasValue(self::OPTIONS) || $this->isAny(); } /** @return bool */ public function isTrace() { return $this->hasValue(self::TRACE) || $this->isAny(); } /** @return string */ public function __toString() { return $this->value; } } var_dump(HttpMethod::PUT());

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.0140.00716.71
8.3.50.0070.01321.93
8.3.40.0110.00418.66
8.3.30.0120.00319.09
8.3.20.0030.00520.35
8.3.10.0080.00021.69
8.3.00.0080.00019.38
8.2.180.0130.01017.00
8.2.170.0060.01222.96
8.2.160.0100.00320.52
8.2.150.0080.00025.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00419.66
8.2.110.0030.00621.07
8.2.100.0090.00317.88
8.2.90.0030.00619.17
8.2.80.0050.00317.97
8.2.70.0040.00417.75
8.2.60.0060.00617.93
8.2.50.0040.00418.07
8.2.40.0060.00320.07
8.2.30.0080.00018.19
8.2.20.0080.00017.84
8.2.10.0000.00818.18
8.2.00.0080.00017.80
8.1.280.0090.00925.92
8.1.270.0000.00818.83
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00317.65
8.1.230.0040.00817.48
8.1.220.0050.00317.74
8.1.210.0000.00818.77
8.1.200.0030.00717.48
8.1.190.0000.00817.25
8.1.180.0040.00418.10
8.1.170.0030.00520.25
8.1.160.0000.00722.06
8.1.150.0000.00918.93
8.1.140.0030.00617.55
8.1.130.0000.00717.82
8.1.120.0000.01117.55
8.1.110.0000.00717.48
8.1.100.0040.00417.50
8.1.90.0000.00717.38
8.1.80.0070.00017.45
8.1.70.0070.00017.48
8.1.60.0040.00417.55
8.1.50.0070.00417.61
8.1.40.0060.00317.41
8.1.30.0030.00617.56
8.1.20.0030.00617.57
8.1.10.0050.00317.56
8.1.00.0040.00417.55
8.0.300.0030.00518.77
8.0.290.0060.00316.88
8.0.280.0000.00718.43
8.0.270.0000.00717.30
8.0.260.0050.00317.22
8.0.250.0000.00716.96
8.0.240.0000.00817.10
8.0.230.0030.00316.95
8.0.220.0030.00317.04
8.0.210.0050.00216.88
8.0.200.0060.00017.00
8.0.190.0070.00017.05
8.0.180.0000.00717.08
8.0.170.0000.00717.01
8.0.160.0040.00417.01
8.0.150.0040.00416.98
8.0.140.0040.00416.93
8.0.130.0000.00613.49
8.0.120.0040.00416.97
8.0.110.0040.00416.97
8.0.100.0040.00416.84
8.0.90.0000.00716.84
8.0.80.0040.01217.00
8.0.70.0050.00216.92
8.0.60.0000.00817.04
8.0.50.0000.00816.95
8.0.30.0130.00917.13
8.0.20.0080.01117.43
8.0.10.0040.00416.98
8.0.00.0080.01016.97
7.4.330.0000.00515.09
7.4.320.0070.00016.58
7.4.300.0030.00316.52
7.4.290.0030.00316.54
7.4.280.0000.00916.52
7.4.270.0040.00316.65
7.4.260.0070.00016.47
7.4.250.0040.00416.62
7.4.240.0040.00416.69
7.4.230.0000.00716.48
7.4.220.0040.01116.54
7.4.210.0090.00616.63
7.4.200.0040.00416.65
7.4.160.0030.01316.32
7.4.150.0090.00917.40
7.4.140.0120.00617.86
7.4.130.0100.00816.78
7.4.120.0110.00816.63
7.4.110.0000.01816.57
7.4.100.0110.00716.59
7.4.90.0120.00616.64
7.4.80.0060.01619.39
7.4.70.0140.00316.60
7.4.60.0060.01016.42
7.4.50.0030.00616.59
7.4.40.0090.00916.45
7.4.30.0060.01816.75
7.4.10.0070.01115.24
7.4.00.0030.01515.10
7.3.330.0030.00313.28
7.3.320.0100.00513.44
7.3.310.0040.00416.24
7.3.300.0000.00716.48
7.3.290.0000.01416.41
7.3.280.0090.00816.45
7.3.270.0090.00917.40
7.3.260.0110.01116.39
7.3.250.0030.01516.43
7.3.240.0130.00416.43
7.3.230.0060.01216.39
7.3.210.0120.00916.61
7.3.200.0110.00619.39
7.3.190.0060.01516.51
7.3.180.0100.00616.62
7.3.170.0090.00916.63
7.3.160.0130.00316.53
7.3.130.0110.00714.64
7.3.120.0120.00516.03
7.3.110.0090.00816.00
7.3.100.0080.00515.99
7.3.90.0080.00815.95
7.3.80.0070.00816.13
7.3.70.0030.00816.05
7.3.60.0040.01116.07
7.3.50.0130.00315.97
7.3.40.0050.00515.92
7.3.30.0040.00916.00
7.3.20.0030.01016.91
7.3.10.0130.00616.71
7.3.00.0160.00716.79
7.2.330.0080.01116.73
7.2.320.0050.01816.37
7.2.310.0070.01016.54
7.2.300.0110.00716.84
7.2.290.0090.01416.40
7.2.260.0070.01114.92
7.2.250.0120.00615.29
7.2.240.0050.01016.09
7.2.230.0030.01416.12
7.2.220.0090.00416.05
7.2.210.0070.01115.96
7.2.200.0090.00616.19
7.2.190.0080.00715.93
7.2.180.0050.01216.09
7.2.170.0070.00816.01
7.2.160.0060.00915.98
7.2.150.0040.01216.95
7.2.140.0060.00617.11
7.2.130.0240.00516.83
7.2.120.0100.00616.88
7.2.110.0210.00516.88
7.2.100.0080.00816.77
7.2.90.0140.00816.85
7.2.80.0140.00916.92
7.2.70.0370.00616.90
7.2.60.0160.00516.89
7.2.50.0180.00516.87
7.2.40.0170.00716.97
7.2.30.0210.01116.99
7.2.20.0050.01316.79
7.2.10.0140.00416.90
7.2.00.0090.00717.34
7.1.330.0050.01016.40
7.1.320.0120.00316.57
7.1.310.0030.00816.32
7.1.300.0040.01116.52
7.1.290.0030.01216.46
7.1.280.0040.00816.37
7.1.270.0090.00516.42
7.1.260.0010.01416.58
7.1.250.0140.00716.15
7.1.240.0070.00715.66
7.1.230.0030.00715.61
7.1.220.0110.00415.64
7.1.210.0000.01415.82
7.1.200.0090.00315.50
7.1.190.0070.01015.73
7.1.180.0030.01015.68
7.1.170.0070.00715.71
7.1.160.0030.00715.69
7.1.150.0040.00715.79
7.1.140.0070.00715.87
7.1.130.0030.00915.69
7.1.120.0070.00715.71
7.1.110.0040.00715.75
7.1.100.0060.00716.89
7.1.90.0080.00415.59
7.1.80.0110.00415.63
7.1.70.0020.01016.30
7.1.60.0080.00517.63
7.1.50.0070.00916.44
7.1.40.0040.00815.77
7.1.30.0000.01115.79
7.1.20.0070.00615.32
7.1.10.0050.01015.46
7.1.00.0040.04218.84
7.0.330.0080.00015.38
7.0.320.0070.00715.38
7.0.310.0000.01315.40
7.0.300.0040.00815.32
7.0.290.0000.01215.50
7.0.280.0040.00715.38
7.0.270.0060.01115.34
7.0.260.0040.00715.48
7.0.250.0080.00415.42
7.0.240.0080.00015.26
7.0.230.0040.00415.59
7.0.220.0000.00815.36
7.0.210.0080.00415.29
7.0.200.0020.00716.10
7.0.190.0060.00315.30
7.0.180.0030.01015.45
7.0.170.0070.00715.46
7.0.160.0040.00815.14
7.0.150.0000.01415.31
7.0.140.0040.03818.72
7.0.130.0060.00615.45
7.0.120.0030.00515.50
7.0.110.0090.00615.42
7.0.100.0080.00315.34
7.0.90.0070.00315.45
7.0.80.0060.00315.39
7.0.70.0060.00615.58
7.0.60.0100.03717.63
7.0.50.0050.04416.76
7.0.40.0080.04216.81
7.0.30.0120.02716.75
7.0.20.0220.04216.82
7.0.10.0030.02616.75
7.0.00.0070.03516.87
5.6.400.0120.00314.60
5.6.390.0060.01014.57
5.6.380.0110.00414.13
5.6.370.0140.00014.22
5.6.360.0080.00814.09
5.6.350.0040.00814.46
5.6.340.0060.00614.21
5.6.330.0090.00614.27
5.6.320.0000.01014.63
5.6.310.0040.01114.73
5.6.300.0030.00914.52
5.6.290.0040.00714.38
5.6.280.0070.03717.68
5.6.270.0060.00314.70
5.6.260.0040.00714.35
5.6.250.0050.00514.27
5.6.240.0040.00814.33
5.6.230.0030.00614.25
5.6.220.0070.00714.30
5.6.210.0070.03017.52
5.6.200.0030.02816.29
5.6.190.0090.03717.60
5.6.180.0200.02517.31
5.6.170.0190.03417.34
5.6.160.0030.03117.44
5.6.150.0080.02316.25
5.6.140.0050.02816.21
5.6.130.0110.03316.19
5.6.120.0120.02217.81
5.6.110.0080.04317.82
5.6.100.0020.03717.75
5.6.90.0070.02417.74
5.6.80.0170.03617.34
5.6.70.0090.00914.52
5.6.60.0000.00814.45
5.6.50.0120.00014.30
5.6.40.0040.00814.23
5.6.30.0070.00714.52
5.6.20.0030.00614.07
5.6.10.0000.01714.54
5.6.00.0100.00614.34
5.5.380.0040.00714.19
5.5.370.0070.00414.18
5.5.360.0030.01214.52
5.5.350.0050.03017.22
5.5.340.0100.04016.27
5.5.330.0050.04517.23
5.5.320.0200.03417.30
5.5.310.0130.03117.17
5.5.300.0130.02316.09
5.5.290.0030.02516.13
5.5.280.0050.04917.51
5.5.270.0090.02717.54
5.5.260.0090.04517.43
5.5.250.0050.02617.32
5.5.240.0020.02017.21
5.5.230.0030.01014.37
5.5.220.0040.00414.39
5.5.210.0110.00414.08
5.5.200.0040.01113.98
5.5.190.0100.00314.03
5.5.180.0030.00714.21
5.5.170.0070.01014.43
5.5.160.0060.00814.22
5.5.150.0080.00314.12
5.5.140.0060.00614.11
5.5.130.0090.00614.21
5.5.120.0030.01214.45
5.5.110.0060.00614.35
5.5.100.0070.00413.86
5.5.90.0040.00414.06
5.5.80.0030.01014.38
5.5.70.0040.01113.79
5.5.60.0030.00614.29
5.5.50.0050.00514.07
5.5.40.0120.00314.50
5.5.30.0070.00414.23
5.5.20.0000.01414.03
5.5.10.0030.00614.04
5.5.00.0000.01014.33
5.4.450.0350.02815.20
5.4.440.0500.03115.02
5.4.430.0120.03215.36
5.4.420.0450.03415.00
5.4.410.0520.03215.23
5.4.400.0150.03014.95
5.4.390.0120.02914.67
5.4.380.0150.02814.74
5.4.370.0080.03315.01
5.4.360.0150.02814.77
5.4.350.0160.02814.73
5.4.340.0150.02514.84
5.4.330.0030.01011.10
5.4.320.0120.03014.70
5.4.310.0130.02614.87
5.4.300.0070.03714.85
5.4.290.0180.02314.75
5.4.280.0140.02914.88
5.4.270.0130.02614.85
5.4.260.0120.03214.73
5.4.250.0120.03214.84
5.4.240.0250.03214.96
5.4.230.0120.02815.00
5.4.220.0150.02714.98
5.4.210.0150.03014.75
5.4.200.0150.02713.94
5.4.190.0130.03014.81
5.4.180.0100.03414.76
5.4.170.0130.03014.82
5.4.160.0110.03214.92
5.4.150.0100.03314.87
5.4.140.0200.02513.71
5.4.130.0120.03013.68
5.4.120.0130.03513.52
5.4.110.0170.02313.71
5.4.100.0130.03213.72
5.4.90.0150.02713.70
5.4.80.0150.03013.75
5.4.70.0160.02313.69
5.4.60.0140.02513.74
5.4.50.0150.02513.79
5.4.40.0150.03313.53
5.4.30.0160.02813.60
5.4.20.0190.03313.57
5.4.10.0200.03113.42
5.4.00.0190.03213.37
5.3.290.0230.06014.71
5.3.280.0270.05014.61
5.3.270.0300.05014.62
5.3.260.0200.06014.63
5.3.250.0300.05014.80
5.3.240.0270.05014.74
5.3.230.0330.04014.61
5.3.220.0100.06714.55
5.3.210.0230.05314.77
5.3.200.0300.07014.73
5.3.190.0270.07014.69
5.3.180.0300.07014.54
5.3.170.0270.05314.59
5.3.160.0200.05714.59
5.3.150.0200.06014.58
5.3.140.0230.05314.61
5.3.130.0470.05014.60
5.3.120.0330.04314.66
5.3.110.0330.05014.67
5.3.100.0300.06714.02
5.3.90.0300.06014.06
5.3.80.0300.05014.13
5.3.70.0300.04714.22
5.3.60.0330.04714.04
5.3.50.0200.05713.99
5.3.40.0400.05713.97
5.3.30.0300.07014.00
5.3.20.0270.05313.71
5.3.10.0200.05313.72
5.3.00.0130.06013.74
5.2.170.0270.03711.11
5.2.160.0270.04011.21
5.2.150.0300.04011.20
5.2.140.0370.05311.29
5.2.130.0230.04711.14
5.2.120.0270.03311.25
5.2.110.0200.03711.27
5.2.100.0200.04011.16
5.2.90.0200.04011.09
5.2.80.0230.03711.15
5.2.70.0200.04011.02
5.2.60.0130.04311.08
5.2.50.0130.04711.08
5.2.40.0100.04310.98
5.2.30.0200.04011.11
5.2.20.0100.05010.89
5.2.10.0170.05310.96
5.2.00.0200.03710.77
5.1.60.0170.04010.11
5.1.50.0130.03710.00
5.1.40.0270.02710.04
5.1.30.0130.03710.31
5.1.20.0330.03310.50
5.1.10.0130.03710.19
5.1.00.0170.04710.16
5.0.50.0100.0338.61
5.0.40.0100.0278.46
5.0.30.0100.0408.29
5.0.20.0100.0308.27
5.0.10.0070.0308.36
5.0.00.0100.0438.25
4.4.90.0030.0277.58
4.4.80.0030.0277.58
4.4.70.0200.0207.58
4.4.60.0170.0277.58
4.4.50.0030.0307.58
4.4.40.0070.0407.58
4.4.30.0100.0277.58
4.4.20.0170.0137.58
4.4.10.0070.0237.58
4.4.00.0130.0407.58
4.3.110.0170.0277.58
4.3.100.0130.0207.58
4.3.90.0000.0307.58
4.3.80.0070.0407.58
4.3.70.0100.0207.58
4.3.60.0200.0177.58
4.3.50.0070.0207.58
4.3.40.0030.0377.58
4.3.30.0030.0237.58
4.3.20.0070.0237.58
4.3.10.0100.0237.58
4.3.00.0070.0237.21

preferences:
51.75 ms | 401 KiB | 5 Q