3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReminderPushEvents { /** * @var array */ private $properties; /** * @var string */ private $event = 'reminder_push_event'; /** * @var \DateTimeInterface */ private $timestamp; /** * Constructor. */ public function __construct() { $this->properties = ['customers' => []]; } /** * [ * 'customers' => [ * ['customerId' => 1213], * ['customerId' => 1212] * ] * ] * * @param array $properties * * @return $this */ public function addProperties(array $properties) { $this->properties['customers'] = $properties; return $this; } /** * @return array */ public function getProperties() { if (!$this->properties) { throw new \RuntimeException(); } return $this->properties; } /** * @return string */ public function getEvent() { if (!$this->event) { throw new \RuntimeException(); } return $this->event; } /** * @return \DateTimeInterface */ public function getTimestamp() { if (!$this->timestamp) { return new \DateTimeImmutable(); } return $this->timestamp; } } class EventRequest { /** * @var string */ private $providerId; /** * @var array */ private $events; /** * Constructor. */ public function __construct($providerId) { $this->providerId = $providerId; $this->events = []; } /** * @return string */ public function getProviderId() { return $this->providerId; } /** * @return array */ public function getEvents() { return $this->events; } /** * @param EventsInterface $events * * @return $this */ public function addEvents( $events) { $this->events[] = $events; return $this; } } function entity2array($entity, $recursionDepth = 2) { $result = array(); $class = new \ReflectionClass(get_class($entity)); foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { $methodName = $method->name; if (strpos($methodName, "get") === 0 && strlen($methodName) > 3) { $propertyName = lcfirst(substr($methodName, 3)); $value = $method->invoke($entity); if (is_array($value)) { foreach ($value as $name => $subValue) { if (is_object($subValue)) { if ($recursionDepth > 0) { $result[$propertyName][$name] = $this->entity2array($subValue, $recursionDepth - 1); } else { $result[$propertyName][$name] = "***"; //stop recursion } continue; } if (is_array($subValue)) { throw new \RuntimeException('Multi-array is currently not supported.'); continue; } $result[$propertyName][$name] = $subValue; } continue; } if (is_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = $this->entity2array($value, $recursionDepth - 1); } else { $result[$propertyName] = "***"; //stop recursion } continue; } $result[$propertyName] = $value; } } return $result; } $foo = new EventRequest('crm_newsletter'); $event = new ReminderPushEvents(); $event->addProperties( [['customerId' => 1213], ['customerId' => 1212]]); $foo->addEvents($event); var_dump( entity2array($foo));

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.0110.00718.56
8.3.50.0070.00716.26
8.3.40.0120.00418.74
8.3.30.0030.01218.79
8.3.20.0040.00422.04
8.3.10.0040.00421.82
8.3.00.0090.00021.01
8.2.180.0110.00418.43
8.2.170.0130.00322.96
8.2.160.0070.00721.98
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0050.00321.83
8.2.120.0000.00826.35
8.2.110.0080.00421.03
8.2.100.0000.01217.84
8.2.90.0070.00317.88
8.2.80.0050.00518.82
8.2.70.0000.00917.88
8.2.60.0080.00017.93
8.2.50.0040.00418.10
8.2.40.0080.00020.41
8.2.30.0000.01021.09
8.2.20.0040.00418.07
8.2.10.0050.00218.08
8.2.00.0040.00418.09
8.1.280.0080.00825.92
8.1.270.0080.00022.23
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00723.91
8.1.230.0090.00321.03
8.1.220.0000.00818.68
8.1.210.0080.00018.77
8.1.200.0030.00617.47
8.1.190.0040.00517.35
8.1.180.0030.00518.10
8.1.170.0000.00818.59
8.1.160.0070.00019.09
8.1.150.0040.00420.63
8.1.140.0040.00419.62
8.1.130.0000.00718.87
8.1.120.0040.00417.57
8.1.110.0040.00417.50
8.1.100.0000.00917.48
8.1.90.0040.00417.41
8.1.80.0000.00717.50
8.1.70.0000.00717.40
8.1.60.0050.00517.62
8.1.50.0040.00417.54
8.1.40.0000.00817.54
8.1.30.0000.00817.68
8.1.20.0080.00317.55
8.1.10.0030.00517.63
8.1.00.0050.00317.58
8.0.300.0030.00520.10
8.0.290.0060.00316.75
8.0.280.0000.00718.54
8.0.270.0050.00217.15
8.0.260.0050.00316.98
8.0.250.0030.00317.07
8.0.240.0060.00316.94
8.0.230.0040.00317.09
8.0.220.0000.00716.99
8.0.210.0030.00317.06
8.0.200.0050.00216.95
8.0.190.0100.00017.06
8.0.180.0000.00717.00
8.0.170.0040.00416.91
8.0.160.0030.00516.94
8.0.150.0000.00716.91
8.0.140.0030.00317.00
8.0.130.0060.00013.50
8.0.120.0070.00016.91
8.0.110.0030.00616.96
8.0.100.0000.00717.02
8.0.90.0050.00317.07
8.0.80.0090.01217.04
8.0.70.0000.00816.91
8.0.60.0000.00816.98
8.0.50.0000.00716.84
8.0.30.0040.01417.04
8.0.20.0130.00817.44
8.0.10.0000.00817.23
8.0.00.0060.01216.84
7.4.330.0050.00015.55
7.4.320.0000.00716.63
7.4.300.0020.00516.64
7.4.290.0050.00516.53
7.4.280.0030.00516.70
7.4.270.0000.00716.62
7.4.260.0060.00013.21
7.4.250.0070.00316.59
7.4.240.0000.00816.63
7.4.230.0070.00016.48
7.4.220.0030.01616.53
7.4.210.0080.00916.57
7.4.200.0070.00016.54
7.4.160.0110.00616.48
7.4.150.0110.00717.40
7.4.140.0120.01217.86
7.4.130.0140.00916.64
7.4.120.0140.00516.56
7.4.110.0100.00716.66
7.4.100.0070.01416.44
7.4.90.0030.01316.34
7.4.80.0060.01019.39
7.4.70.0100.00716.59
7.4.60.0070.01116.70
7.4.50.0120.00316.30
7.4.40.0100.00716.70
7.4.30.0080.01516.44
7.4.10.0120.00915.09
7.4.00.0120.00515.13
7.3.330.0050.00013.46
7.3.320.0030.00313.32
7.3.310.0050.00216.49
7.3.300.0030.00316.50
7.3.290.0030.00316.52
7.3.280.0060.00816.44
7.3.270.0070.01017.40
7.3.260.0110.00916.60
7.3.250.0090.01316.61
7.3.240.0080.00816.52
7.3.230.0130.00316.45
7.3.210.0040.01216.61
7.3.200.0110.01116.70
7.3.190.0110.00916.50
7.3.180.0070.01016.49
7.3.170.0140.00316.47
7.3.160.0080.00816.62
7.3.130.0070.01014.86
7.3.120.0060.01015.00
7.3.110.0080.01015.08
7.3.100.0060.00515.01
7.3.90.0060.00814.87
7.3.80.0110.00314.94
7.3.70.0050.00914.85
7.3.60.0100.00415.01
7.3.50.0060.00814.97
7.3.40.0070.00915.00
7.3.30.0050.00914.81
7.3.20.0070.00716.76
7.3.10.0050.00516.47
7.3.00.0050.00716.83
7.2.330.0070.01016.50
7.2.320.0070.01116.89
7.2.310.0060.01016.88
7.2.300.0080.00816.83
7.2.290.0120.00516.85
7.2.260.0060.00914.79
7.2.250.0030.01214.98
7.2.240.0020.01514.94
7.2.230.0030.00915.10
7.2.220.0020.00915.12
7.2.210.0030.01115.03
7.2.200.0030.01215.16
7.2.190.0040.01415.25
7.2.180.0110.00415.16
7.2.170.0020.01414.94
7.2.160.0060.01015.26
7.2.150.0030.01016.88
7.2.140.0090.00616.66
7.2.130.0030.01316.68
7.2.120.0100.00416.70
7.2.110.0060.00916.75
7.2.100.0100.00316.91
7.2.90.0070.00717.18
7.2.80.0060.00916.98
7.2.70.0000.01017.02
7.2.60.0070.00516.98
7.2.50.0040.00816.73
7.2.40.0090.00617.05
7.2.30.0030.01017.03
7.2.20.0070.00316.92
7.2.10.0030.00617.01
7.2.00.0050.01017.98
7.1.330.0070.00716.01
7.1.320.0040.00915.82
7.1.310.0030.01115.59
7.1.300.0030.00815.68
7.1.290.0070.00815.73
7.1.280.0060.01015.76
7.1.270.0050.00615.77
7.1.260.0060.00615.92
7.1.250.0030.01015.92
7.1.240.0060.00615.83
7.1.230.0130.00015.74
7.1.220.0030.01015.80
7.1.210.0070.00715.54
7.1.200.0050.00815.90
7.1.190.0030.00915.71
7.1.180.0050.00315.60
7.1.170.0060.00315.84
7.1.160.0090.00615.59
7.1.150.0130.00315.77
7.1.140.0030.01115.92
7.1.130.0070.00715.69
7.1.120.0070.00715.82
7.1.110.0030.00815.64
7.1.100.0050.00717.10
7.1.90.0070.00715.92
7.1.80.0040.00715.80
7.1.70.0030.01016.37
7.1.60.0180.01224.66
7.1.50.0170.01224.41
7.1.40.0200.01024.08
7.1.30.0220.00924.29
7.1.20.0220.00924.37
7.1.10.0100.01515.49
7.1.00.0320.01115.38
7.0.330.0060.00915.26
7.0.320.0040.00815.45
7.0.310.0000.01615.37
7.0.300.0000.01315.12
7.0.290.0030.00615.47
7.0.280.0000.01315.21
7.0.270.0060.00315.46
7.0.260.0050.00515.21
7.0.250.0030.00815.32
7.0.240.0000.01315.37
7.0.230.0060.00615.29
7.0.220.0060.00915.29
7.0.210.0000.01115.52
7.0.200.0170.00715.22
7.0.190.0150.00715.26
7.0.180.0200.00814.90
7.0.170.0180.00815.05
7.0.160.0130.00814.95
7.0.150.0130.00814.87
7.0.140.0120.01015.05
7.0.130.0130.00815.10
7.0.120.0150.00715.06
7.0.110.0170.00515.07
7.0.100.0120.01215.04
7.0.90.0150.00514.93
7.0.80.0130.00815.08
7.0.70.0120.01014.92
7.0.60.0140.00714.89
7.0.50.0150.00915.00
7.0.40.0130.00814.19
7.0.30.0160.00514.04
7.0.20.0120.01014.04
7.0.10.0120.00914.10
7.0.00.0080.01114.07
5.6.400.0030.00714.69
5.6.390.0030.00614.82
5.6.380.0060.00314.75
5.6.370.0060.00314.49
5.6.360.0070.00714.32
5.6.350.0070.00714.23
5.6.340.0030.00914.81
5.6.330.0090.00614.68
5.6.320.0040.01214.40
5.6.310.0130.00314.53
5.6.300.0100.00314.57
5.6.290.0030.00614.20
5.6.280.0070.00714.45
5.6.270.0030.01014.76
5.6.260.0030.01014.44
5.6.250.0090.00914.55
5.6.240.0030.01014.37
5.6.230.0030.00914.61
5.6.220.0060.01214.71
5.6.210.0040.00814.57
5.6.200.0000.01014.59
5.6.190.0090.00614.81
5.6.180.0040.01114.57
5.6.170.0060.00614.53
5.6.160.0070.00314.34
5.6.150.0090.00914.94
5.6.140.0100.00314.63
5.6.130.0110.00414.55
5.6.120.0110.00414.55
5.6.110.0110.00714.77
5.6.100.0040.01414.25
5.6.90.0080.00414.62
5.6.80.0040.00414.48
5.6.70.0030.01014.36
5.6.60.0030.01014.50
5.6.50.0040.01114.73
5.6.40.0030.00614.15
5.6.30.0060.00614.50
5.6.20.0030.01314.59
5.6.10.0090.00614.37
5.6.00.0030.00714.35

preferences:
54.08 ms | 401 KiB | 5 Q