3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @xmlNamespace http://www.webservices.nl/soap/ * @xmlType * @xmlName RiskAddress */ class Address { /** * @xmlType string * @xmlRender value * @xmlName postcode * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_postcode; /** * @xmlType string * @xmlRender value * @xmlName building * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_building; /** * @xmlType string * @xmlRender value * @xmlName street * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_street; /** * @xmlType integer * @xmlRender value * @xmlName house_number * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_house_number; /** * @xmlType string * @xmlRender value * @xmlName house_number_addition * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_house_number_addition; /** * @xmlType string * @xmlRender value * @xmlName city * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_city; /** * @xmlType string * @xmlRender value * @xmlName municipality * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_municipality; /** * @xmlType string * @xmlRender value * @xmlName state * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_state; /** * @xmlType string * @xmlRender value * @xmlName country * @xmlNamespace http://www.webservices.nl/soap/ */ protected $_country; /** * @return string */ public function getPostcode() { return $this->_postcode; } /** * @param string $postcode */ public function setPostcode($postcode) { $this->_postcode = (string) $postcode; } /** * @return string */ public function getBuilding() { return $this->_building; } /** * @param string $building */ public function setBuilding($building) { $this->_building = (string) $building; } /** * @return string */ public function getStreet() { return $this->_street; } /** * @param string $street */ public function setStreet($street) { $this->_street = (string) $street; } /** * @return integer */ public function getHouseNumber() { return $this->_house_number; } /** * @param (integer) $houseNumber */ public function setHouseNumber($houseNumber) { $this->_house_number = (integer) $houseNumber; } /** * @return string */ public function getHouseNumberAddition() { return $this->_house_number_addition; } /** * @param string $houseNumberAddition */ public function setHouseNumberAddition($houseNumberAddition) { $this->_house_number_addition = (string) $houseNumberAddition; } /** * @return string */ public function getCity() { return $this->_city; } /** * @param string $city */ public function setCity($city) { $this->_city = (string) $city; } /** * @return string */ public function getMunicipality() { return $this->_municipality; } /** * @param string $municipality */ public function setMunicipality($municipality) { $this->_municipality = $municipality; } /** * @return string */ public function getState() { return $this->_state; } /** * @param string $state */ public function setState($state) { $this->_state = (string) $state; } /** * @return string */ public function getCountry() { return $this->_country; } /** * @param string $country */ public function setCountry($country) { $this->_country = (string) $country; } } class AddressHelper { public static function parse(Address $address, $parts) { $parts = func_get_args(); $address = array_shift($parts); $format = '~^(.*?\n)??' . '(?<street>[^0-9].*|.*?[^0-9])[\b\s]*?' . '(?<number>[0-9]{1,5}?)[\b\s\-]*?' . '(?<addition>[^\s]*?)[\b\s,]*?' . '(?<postcode>[0-9]{4}\s?[A-Z]{2})[\b\s,]*?' . '(?<city>[\w][\w\s]*?)' . '(\n.*)??$~msiU'; if (preg_match($format, implode(PHP_EOL, $parts), $args)) { $street = $number = $postcode = $city = $addition = null; extract($args, EXTR_OVERWRITE); $address->setStreet($street); $address->setHouseNumber($number); $address->setHouseNumberAddition($addition); $address->setPostcode($postcode); $address->setCity(strtoupper(trim($city))); } return $address; } } class Marshaller { protected $_includeNilValues = true; public function __construct($includeNilValues = true) { $this->_includeNilValues = $includeNilValues; } public function marshall($object) { return $this->_marshallObject($object); } protected function _marshallObject($object) { $output = array(); $refClass = new ReflectionClass($object); foreach ($refClass->getProperties(ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PUBLIC) as $refProp) { $propValue = $object->{$this->_getPropertyAccessor($refProp->getName())}(); $this->_marshallProperty($refProp->getName(), $propValue, $output); } return $output; } protected function _marshallProperty($propName, &$propValue, array &$output) { if (($propValue === null || $propValue === '') && $this->_includeNilValues === false) return; if (is_object($propValue)) { $this->_assignArrayValue($output, $this->_getPropertyArrayKey($propName), $this->_marshallObject($propValue)); } elseif (is_array($propValue)) { $arrayOutput = array(); foreach ($propValue as $nestedPropVal) { $array = array(); $this->_marshallProperty($this->_getPropertyArrayKey($propName), $nestedPropVal, $array); $arrayOutput = array_merge_recursive($arrayOutput, array(array_shift($array))); } if ('' !== implode('', $arrayOutput)) $output[$this->_getPropertyArrayKey($propName)] = $arrayOutput; } else { $this->_assignArrayValue($output, $this->_getPropertyArrayKey($propName), $propValue); } } protected function _assignArrayValue(array &$output, $key, $value) { // remove empty arrays when include nilvalues is set to true if (false === $this->_includeNilValues && is_array($value) && empty($value) && '' == implode('', $value)) { return; } if (false === $this->_includeNilValues && (is_null($value) || $value === '')) { return; } $output[$key] = $value; } /** * Convert a class property name to an array key * @param string $propName * @return string */ protected function _getPropertyArrayKey($propName) { return ltrim($propName, '_'); } /** * Get the accessor for a class property name * @param string $propName * @return string */ protected function _getPropertyAccessor($propName) { $propName = ltrim($propName, '_'); $propParts = explode('_', $propName); foreach ($propParts as &$propPart) { $propPart = ucfirst($propPart); } return 'get' . implode('', $propParts); } public function includeNilValues() { $this->_includeNilValues = true; } public function excludeNilValues() { $this->_includeNilValues = false; } } //$parsedAddress = AddressHelper::parse(new Address(), null, null, null, null, null)); $address = new Address(); $marshaller = new Marshaller(false); $marshaller->marshall($address); $marshaller->marshall($address); var_dump($marshaller->marshall($address));

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.0000.01518.55
8.3.50.0110.00921.97
8.3.40.0090.00618.80
8.3.30.0080.00819.09
8.3.20.0090.00020.38
8.3.10.0080.00023.71
8.3.00.0040.00420.90
8.2.180.0110.00718.29
8.2.170.0120.00322.96
8.2.160.0030.01020.36
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0040.00420.98
8.2.110.0090.00022.28
8.2.100.0060.00619.38
8.2.90.0040.00419.11
8.2.80.0030.00517.97
8.2.70.0060.00317.63
8.2.60.0080.00018.04
8.2.50.0000.00818.07
8.2.40.0090.00019.88
8.2.30.0040.00418.34
8.2.20.0000.00717.79
8.2.10.0050.00318.07
8.2.00.0080.00017.76
8.1.280.0090.00625.92
8.1.270.0040.00423.79
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00322.13
8.1.230.0030.00919.14
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0070.00717.25
8.1.190.0080.00017.48
8.1.180.0040.00418.10
8.1.170.0050.00318.59
8.1.160.0000.00821.98
8.1.150.0050.00318.61
8.1.140.0000.00917.51
8.1.130.0040.00417.93
8.1.120.0040.00417.50
8.1.110.0030.00617.43
8.1.100.0030.00617.42
8.1.90.0050.00317.54
8.1.80.0040.00417.50
8.1.70.0000.00717.50
8.1.60.0030.00517.62
8.1.50.0050.00517.47
8.1.40.0080.00017.50
8.1.30.0040.00417.70
8.1.20.0000.00817.76
8.1.10.0000.00817.64
8.1.00.0030.00517.64
8.0.300.0000.00718.77
8.0.290.0040.00417.28
8.0.280.0000.00718.42
8.0.270.0040.00417.22
8.0.260.0070.00017.29
8.0.250.0070.00017.04
8.0.240.0040.00417.11
8.0.230.0030.00417.06
8.0.220.0070.00017.02
8.0.210.0030.00316.97
8.0.200.0080.00017.05
8.0.190.0000.00916.99
8.0.180.0040.00417.05
8.0.170.0030.00517.07
8.0.160.0000.00717.01
8.0.150.0000.00816.84
8.0.140.0050.00216.98
8.0.130.0040.00413.43
8.0.120.0040.00416.95
8.0.110.0000.00817.02
8.0.100.0000.00716.99
8.0.90.0040.00416.98
8.0.80.0060.01617.03
8.0.70.0000.00817.07
8.0.60.0040.00417.13
8.0.50.0040.00417.01
8.0.30.0080.01217.07
8.0.20.0160.00317.40
8.0.10.0000.00816.96
8.0.00.0120.00616.92
7.4.330.0020.00215.00
7.4.320.0070.00316.65
7.4.300.0000.00616.57
7.4.290.0030.00316.56
7.4.280.0000.00716.56
7.4.270.0070.00016.53
7.4.260.0030.00316.56
7.4.250.0000.00716.65
7.4.240.0000.00716.67
7.4.230.0000.00716.76
7.4.220.0070.01116.49
7.4.210.0060.00816.65
7.4.200.0050.00216.41
7.4.190.0050.00316.80
7.4.160.0060.01016.62
7.4.150.0030.01417.40
7.4.140.0070.01017.86
7.4.130.0120.00616.58
7.4.120.0130.00716.61
7.4.110.0120.00616.49
7.4.100.0090.01216.66
7.4.90.0090.00916.52
7.4.80.0040.01519.39
7.4.70.0060.01316.75
7.4.60.0140.00316.60
7.4.50.0050.00016.37
7.4.40.0110.00816.42
7.4.30.0130.00316.57
7.4.00.0060.00914.92
7.3.330.0000.00513.26
7.3.320.0050.00013.43
7.3.310.0040.00416.46
7.3.300.0000.00716.30
7.3.290.0060.01216.39
7.3.280.0050.01216.43
7.3.270.0030.01317.40
7.3.260.0090.00816.53
7.3.250.0110.01016.52
7.3.240.0120.00916.78
7.3.230.0090.00916.56
7.3.210.0120.00616.59
7.3.200.0120.00919.39
7.3.190.0130.00716.48
7.3.180.0070.01016.52
7.3.170.0060.00916.62
7.3.160.0100.00616.46
7.3.120.0080.00415.05
7.2.330.0150.00316.69
7.2.320.0070.01016.86
7.2.310.0070.01016.76
7.2.300.0100.00716.93
7.2.290.0040.01716.74
7.2.60.0040.01117.05
7.2.00.0120.00619.50
7.1.200.0070.00415.79
7.1.100.0000.00917.98
7.1.70.0040.00417.17
7.1.60.0090.01519.46
7.1.50.0070.01016.85
7.1.00.0070.07322.33
7.0.200.0040.00416.47
7.0.140.0000.07721.92
7.0.100.0130.07720.09
7.0.90.0030.09019.98
7.0.80.0100.08019.94
7.0.70.0070.08020.11
7.0.60.0170.07719.97
7.0.50.0070.07020.27
7.0.40.0130.07320.07
7.0.30.0130.04720.10
7.0.20.0070.08320.11
7.0.10.0200.07020.04
7.0.00.0100.07720.04
5.6.280.0030.07020.97
5.6.250.0130.06320.74
5.6.240.0100.09020.67
5.6.230.0070.09020.71
5.6.220.0130.04320.73
5.6.210.0100.07720.50
5.6.200.0030.08721.11
5.6.190.0070.08321.20
5.6.180.0200.07321.14
5.6.170.0100.08321.12
5.6.160.0030.09021.15
5.6.150.0070.05721.09
5.6.140.0170.04021.02
5.6.130.0070.08721.04
5.6.120.0030.08321.08
5.6.110.0070.07721.02
5.6.100.0130.08021.05
5.6.90.0030.08321.16
5.6.80.0170.05720.38
5.6.70.0130.07320.45
5.6.60.0070.08020.37
5.6.50.0130.07720.47
5.6.40.0130.04020.48
5.6.30.0100.07720.50
5.6.20.0100.07720.49
5.6.10.0030.08320.52
5.6.00.0100.07720.51
5.5.380.0000.09020.54
5.5.370.0070.08020.41
5.5.360.0030.08320.50
5.5.350.0000.09320.49
5.5.340.0130.04320.98
5.5.330.0130.07720.87
5.5.320.0070.08720.99
5.5.310.0100.08320.98
5.5.300.0130.07020.96
5.5.290.0200.07020.82
5.5.280.0230.06020.98
5.5.270.0200.07720.95
5.5.260.0130.07720.85
5.5.250.0130.07320.68
5.5.240.0100.07720.32
5.5.230.0100.08320.37
5.5.220.0130.04720.32
5.5.210.0100.07720.24
5.5.200.0070.08320.32
5.5.190.0200.05020.33
5.5.180.0030.08720.22
5.5.160.0100.06720.34
5.5.150.0130.07720.05
5.5.140.0070.05020.20
5.5.130.0130.07320.32
5.5.120.0100.07720.21
5.5.110.0070.08020.24
5.5.100.0100.07720.20
5.5.90.0100.07020.15
5.5.80.0100.07720.15
5.5.70.0100.08020.22
5.5.60.0070.07720.12
5.5.50.0000.08720.02
5.5.40.0100.07720.20
5.5.30.0100.07720.11
5.5.20.0130.07320.12
5.5.10.0230.05720.12
5.5.00.0130.07320.13
5.4.450.0100.07719.42
5.4.440.0100.07319.55
5.4.430.0070.07719.24
5.4.420.0070.07719.46
5.4.410.0070.07719.30
5.4.400.0100.06319.17
5.4.390.0070.07719.00
5.4.380.0070.07719.16
5.4.370.0100.07019.21
5.4.360.0130.07319.20
5.4.350.0030.08019.14
5.4.340.0100.07719.21
5.4.320.0130.07319.18
5.4.310.0070.07719.14
5.4.300.0130.07019.23
5.4.290.0070.08019.16
5.4.280.0130.07319.13
5.4.270.0030.05019.13
5.4.260.0070.07719.04
5.4.250.0100.07319.02
5.4.240.0070.07318.84
5.4.230.0230.06019.21
5.4.220.0030.08019.04
5.4.210.0000.08718.89
5.4.200.0030.08019.16
5.4.190.0100.07319.15
5.4.180.0030.08319.23
5.4.170.0070.07319.01
5.4.160.0100.07719.07
5.4.150.0070.07719.10
5.4.140.0170.05716.50
5.4.130.0070.06716.50
5.4.120.0100.06716.38
5.4.110.0070.07016.57
5.4.100.0100.06716.40
5.4.90.0100.06716.50
5.4.80.0100.07016.46
5.4.70.0100.04716.36
5.4.60.0070.07316.54
5.4.50.0100.07016.50
5.4.40.0170.04316.34
5.4.30.0070.07016.35
5.4.20.0000.07716.45
5.4.10.0030.06316.46
5.4.00.0130.06315.83
5.3.290.0070.07714.81
5.3.280.0070.04314.73
5.3.270.0030.07314.80
5.3.260.0070.07314.75
5.3.250.0100.07014.62
5.3.240.0170.05314.75
5.3.230.0130.07714.79
5.3.220.0000.08014.57
5.3.210.0130.07014.78
5.3.200.0070.07314.66
5.3.190.0000.05014.76
5.3.180.0100.06714.68
5.3.170.0100.07014.66
5.3.160.0100.07314.65
5.3.150.0100.07014.76
5.3.140.0200.06714.69
5.3.130.0130.07014.66
5.3.120.0130.07714.55
5.3.110.0070.06014.76
5.3.100.0030.08014.13
5.3.90.0030.08014.02
5.3.80.0100.07014.15
5.3.70.0130.06314.14
5.3.60.0000.08714.14
5.3.50.0070.07314.14
5.3.40.0030.05314.04
5.3.30.0070.07314.04
5.3.20.0270.06013.90
5.3.10.0030.07013.71
5.3.00.0100.05313.74

preferences:
43.44 ms | 401 KiB | 5 Q