3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait GetterAndSetter { /** * @var string */ private $setterPrefix = 'set'; /** * @var string */ private $getterPrefix = 'get'; /** * Assigns value to property by attempting to find its * setter. If no setter exists the value is casted into * appropriate type and assigned to the property directly. * * @param $key * @param $value * @return $this */ function __set($key, $value) { $expectedSetter = "{$this->setterPrefix}{$key}"; if ( method_exists($this, $expectedSetter) ) { $this->{$expectedSetter}($value); } elseif ( property_exists($this, $key) ){ $enforcedType = gettype($this->{$key}); $this->{$key} = $value; settype($this->{$key}, $enforcedType); } return $this; } /** * Invokes matching getter if defined * otherwise returns property as is. * * @param $key * @return mixed */ function __get($key) { $expectedGetter = $this->getterPrefix . $key; if ( method_exists($this, $expectedGetter) ) { return $this->{$expectedGetter}(); } return $this->{$key}; } /** * Resolves setClassProperty($val) to $obj->classProperty = $val, * casts appropriate type to value and assigns * to property * * @param $method string Name of possible setter method * @param $val mixed Value to assign to property * @return $this */ function __call($method, $val=[]) { $possibleKey = lcfirst(str_replace($this->setterPrefix, '', $method)); if ( property_exists($this, $possibleKey) ){ $enforcedType = gettype($this->{$possibleKey}); $this->{$possibleKey} = $val[0]; settype($this->{$possibleKey}, $enforcedType); } return $this; } } class AuthorizeNetCustomer { //Will call setters when available otherwise //value will be casted to the property's type //and assigned. use GetterAndSetter; private $merchantCustomerId; private $description; private $email; private $paymentProfiles = array(); private $shipToList = array(); private $customerProfileId; function __construct() { $this->merchantCustomerId = (int) $this->merchantCustomerId; $this->customerProfileId = (int) $this->customerProfileId; $this->description = (string) $this->description; $this->email = (string) $this->email; } public function setPaymentProfiles(array $val){ $this->paymentProfiles = $val; } public function setShipToList(array $val){ $this->shipToList = $val; } public function getShipToList() { return 'adasd'; } } $a = new AuthorizeNetCustomer(); $a->setEmail('cgrandos@delivery.com'); $a->merchantCustomerId = '1'; $a->setCustomerProfileId('34') ->setDescription(232323) ->setShipToList([1,2,3]); var_dump($a->email); var_dump($a->merchantCustomerId); var_dump($a->customerProfileId); var_dump($a->description); var_dump($a->shipToList);

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.0100.01316.75
8.3.50.0260.00821.24
8.3.40.0110.00718.79
8.3.30.0040.01119.21
8.3.20.0000.00720.13
8.3.10.0050.00321.91
8.3.00.0040.00417.75
8.2.180.0150.00016.88
8.2.170.0080.01222.96
8.2.160.0040.01020.33
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0000.00726.16
8.2.120.0080.00020.87
8.2.110.0040.00722.15
8.2.100.0090.00317.78
8.2.90.0000.00817.75
8.2.80.0000.00818.86
8.2.70.0040.00418.16
8.2.60.0030.00617.63
8.2.50.0060.00319.48
8.2.40.0000.00719.33
8.2.30.0080.00018.25
8.2.20.0050.00317.79
8.2.10.0000.00818.16
8.2.00.0040.00418.22
8.1.280.0150.00325.92
8.1.270.0080.00020.08
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0030.00623.91
8.1.230.0120.00022.49
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0080.00017.35
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0030.00518.86
8.1.160.0000.00722.05
8.1.150.0000.00820.66
8.1.140.0000.00717.47
8.1.130.0080.00017.66
8.1.120.0000.00817.47
8.1.110.0000.00817.48
8.1.100.0040.00417.40
8.1.90.0080.00017.52
8.1.80.0030.00517.52
8.1.70.0000.00717.43
8.1.60.0040.00417.61
8.1.50.0000.00817.60
8.1.40.0060.00617.42
8.1.30.0040.00417.59
8.1.20.0040.00417.66
8.1.10.0000.00817.65
8.1.00.0080.00017.52
8.0.300.0040.00418.77
8.0.290.0050.00316.88
8.0.280.0040.00418.51
8.0.270.0030.00317.27
8.0.260.0040.00417.31
8.0.250.0000.00717.05
8.0.240.0000.00816.88
8.0.230.0030.00317.03
8.0.220.0000.00816.86
8.0.210.0060.00316.94
8.0.200.0080.00017.04
8.0.190.0000.00717.00
8.0.180.0100.00316.92
8.0.170.0030.00616.97
8.0.160.0040.00416.87
8.0.150.0040.00416.86
8.0.140.0000.00716.92
8.0.130.0020.00513.46
8.0.120.0030.00616.80
8.0.110.0080.00016.91
8.0.100.0000.00816.80
8.0.90.0000.00816.82
8.0.80.0060.01016.96
8.0.70.0000.00716.74
8.0.60.0000.00816.81
8.0.50.0000.00816.80
8.0.30.0090.01216.94
8.0.20.0090.01117.40
8.0.10.0040.00416.98
8.0.00.0110.00716.78
7.4.330.0030.00315.06
7.4.320.0060.00016.64
7.4.300.0060.00016.56
7.4.290.0080.00016.49
7.4.280.0000.00916.54
7.4.270.0000.00816.66
7.4.260.0060.00616.63
7.4.250.0030.00616.52
7.4.240.0020.00516.58
7.4.230.0030.00316.72
7.4.220.0110.00816.58
7.4.210.0100.00816.55
7.4.200.0000.00716.57
7.4.160.0050.01416.52
7.4.150.0060.01217.40
7.4.140.0110.01117.86
7.4.130.0130.00616.59
7.4.120.0070.01116.44
7.4.110.0100.01016.56
7.4.100.0140.00616.60
7.4.90.0080.00816.61
7.4.80.0090.01219.39
7.4.70.0100.00716.40
7.4.60.0000.01816.52
7.4.50.0040.00416.61
7.4.40.0120.00916.75
7.4.30.0120.00616.45
7.4.00.0090.00314.89
7.3.330.0000.00513.41
7.3.320.0030.00313.30
7.3.310.0000.00816.43
7.3.300.0030.00616.36
7.3.290.0070.00016.36
7.3.280.0050.01116.39
7.3.270.0130.00417.40
7.3.260.0090.00916.44
7.3.250.0100.01016.43
7.3.240.0130.00516.59
7.3.230.0140.00816.45
7.3.210.0140.00316.64
7.3.200.0060.01819.39
7.3.190.0060.01216.40
7.3.180.0070.01116.52
7.3.170.0050.01116.45
7.3.160.0090.00616.57
7.2.330.0060.00916.77
7.2.320.0090.01516.90
7.2.310.0130.00616.77
7.2.300.0150.00316.50
7.2.290.0120.01016.86
7.2.00.0090.00619.22
7.1.100.0030.01418.13
7.1.70.0030.00717.19
7.1.60.0130.01319.59
7.1.50.0100.01016.89
7.1.00.0030.07722.36
7.0.200.0000.00816.63
7.0.60.0000.08320.05
7.0.50.0030.05317.98
7.0.40.0130.08020.21
7.0.30.0130.04720.21
7.0.20.0230.06320.23
7.0.10.0100.07320.15
7.0.00.0070.09020.25
5.6.280.0070.07020.84
5.6.210.0070.06020.71
5.6.200.0070.08018.12
5.6.190.0130.06320.67
5.6.180.0430.04320.63
5.6.170.0270.04020.40
5.6.160.0000.09020.54
5.6.150.0030.08318.14
5.6.140.0070.08018.21
5.6.130.0070.08018.15
5.6.120.0070.04320.99
5.6.110.0030.09021.15
5.6.100.0030.07021.04
5.6.90.0130.06721.02
5.6.80.0200.07020.35
5.5.350.0230.08020.51
5.5.340.0100.08017.94
5.5.330.0100.08320.33
5.5.320.0030.07020.36
5.5.310.0400.07320.36
5.5.300.0070.06717.94
5.5.290.0100.08318.04
5.5.280.0070.08020.79
5.5.270.0070.07020.74
5.5.260.0230.08320.81
5.5.250.0100.08020.56
5.5.240.0070.07320.14
5.4.450.0570.05319.70
5.4.440.0600.06319.70
5.4.430.0930.05019.54
5.4.420.0700.05719.21
5.4.410.0600.05719.16
5.4.400.0570.05719.23
5.4.390.0770.05019.34
5.4.380.0730.04018.99
5.4.370.0730.05319.19
5.4.360.0700.04719.11
5.4.350.0630.05719.34
5.4.340.0700.05719.00
5.4.320.0600.05719.20
5.4.310.0670.04718.96
5.4.300.0630.06019.34
5.4.290.0800.05018.90
5.4.280.0700.04718.96
5.4.270.0670.05018.99
5.4.260.0700.04718.88
5.4.250.0800.04019.15
5.4.240.0700.04719.32
5.4.230.0770.05019.10
5.4.220.0770.05019.11
5.4.210.0800.04719.11
5.4.200.0900.03716.78
5.4.190.0970.03019.11
5.4.180.0830.04318.92
5.4.170.0800.05719.14
5.4.160.0670.05718.96
5.4.150.0700.05718.96
5.4.140.0800.04316.67
5.4.130.0670.05716.43
5.4.120.0700.05316.25
5.4.110.0800.04316.40
5.4.100.0730.05016.67
5.4.90.0670.05716.30
5.4.80.0770.04716.43
5.4.70.0730.06016.25
5.4.60.0730.05016.43
5.4.50.0730.04716.25
5.4.40.0570.06016.38
5.4.30.0670.04316.55
5.4.20.0630.05016.41
5.4.10.0800.04316.21
5.4.00.0730.04715.91
5.3.290.0670.05314.68
5.3.280.0770.05714.54
5.3.270.0770.05014.52
5.3.260.0830.05014.47
5.3.250.0700.05714.58
5.3.240.0700.05314.61
5.3.230.0700.06014.52
5.3.220.0700.04314.46
5.3.210.0770.05014.36
5.3.200.0670.04314.60
5.3.190.0670.05714.44
5.3.180.0730.05014.38
5.3.170.0830.04014.43
5.3.160.0770.04714.41
5.3.150.0700.05314.46
5.3.140.0730.05014.42
5.3.130.0600.05714.34
5.3.120.0770.05014.34
5.3.110.0670.05714.39
5.3.100.0800.04313.89
5.3.90.0670.05313.95
5.3.80.0770.05313.95
5.3.70.0700.05313.89
5.3.60.0700.05313.98
5.3.50.0730.04713.88
5.3.40.0600.05713.80
5.3.30.0570.05713.89
5.3.20.0670.04713.55
5.3.10.0700.04013.49
5.3.00.0670.05313.50
5.2.170.0630.03710.99
5.2.160.0700.04011.24
5.2.150.0600.05011.25
5.2.140.0630.04011.15
5.2.130.0530.04311.05
5.2.120.0600.03711.11
5.2.110.0630.04711.04
5.2.100.0600.04011.05
5.2.90.0570.04310.93
5.2.80.0530.04710.94
5.2.70.0600.04010.95
5.2.60.0600.04010.96
5.2.50.0600.04010.88
5.2.40.0430.04310.84
5.2.30.0400.04310.98
5.2.20.0430.03310.85
5.2.10.0500.04010.80
5.2.00.0470.04010.66
5.1.60.0370.0409.83
5.1.50.0570.0239.93
5.1.40.0370.0379.98
5.1.30.0430.03710.36
5.1.20.0470.03310.25
5.1.10.0530.03310.17
5.1.00.0470.0379.96
5.0.50.0200.0308.43
5.0.40.0200.0308.34
5.0.30.0300.0408.13
5.0.20.0200.0278.30
5.0.10.0200.0378.08
5.0.00.0270.0378.26
4.4.90.0230.0175.86
4.4.80.0130.0275.84
4.4.70.0230.0305.84
4.4.60.0270.0275.79
4.4.50.0200.0235.77
4.4.40.0230.0305.78
4.4.30.0300.0205.73
4.4.20.0270.0275.86
4.4.10.0300.0205.93
4.4.00.0230.0305.93
4.3.110.0270.0135.75
4.3.100.0170.0235.82
4.3.90.0200.0205.64
4.3.80.0200.0335.68
4.3.70.0130.0275.82
4.3.60.0200.0205.76
4.3.50.0300.0135.76
4.3.40.0270.0275.81
4.3.30.0070.0234.58
4.3.20.0070.0234.50
4.3.10.0070.0234.34
4.3.00.0100.0207.13

preferences:
60.27 ms | 401 KiB | 5 Q