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] = entity2array($subValue, $recursionDepth - 1); } else { $result[$propertyName][$name] = "***"; //stop recursion } continue; } if (is_array($subValue)) { $result[$propertyName][$name] = $subValue; //stop recursion continue; } $result[$propertyName][$name] = $subValue; } continue; } if (is_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = 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.0100.01018.43
8.3.50.0090.00616.60
8.3.40.0150.00418.90
8.3.30.0090.00618.93
8.3.20.0040.00420.34
8.3.10.0040.00421.90
8.3.00.0080.00020.77
8.2.180.0150.00618.41
8.2.170.0000.01522.96
8.2.160.0110.00422.25
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00022.25
8.2.120.0040.00426.35
8.2.110.0000.01120.56
8.2.100.0060.00618.16
8.2.90.0040.00419.23
8.2.80.0050.00318.17
8.2.70.0030.00617.88
8.2.60.0040.00418.05
8.2.50.0060.00318.17
8.2.40.0040.00422.32
8.2.30.0000.01021.21
8.2.20.0030.00618.10
8.2.10.0050.00318.22
8.2.00.0030.00618.21
8.1.280.0120.00325.92
8.1.270.0080.00022.06
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0030.00722.68
8.1.230.0140.00419.17
8.1.220.0040.00417.79
8.1.210.0030.00618.77
8.1.200.0100.00017.47
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0060.00318.73
8.1.160.0050.00319.13
8.1.150.0030.00520.76
8.1.140.0000.00819.73
8.1.130.0000.00719.03
8.1.120.0050.00317.72
8.1.110.0000.00717.57
8.1.100.0090.00017.59
8.1.90.0040.00417.69
8.1.80.0000.00817.59
8.1.70.0040.00417.70
8.1.60.0060.00317.71
8.1.50.0080.00017.58
8.1.40.0050.00317.63
8.1.30.0040.00417.82
8.1.20.0040.00717.80
8.1.10.0030.00517.67
8.1.00.0040.00417.67
8.0.300.0000.00818.77
8.0.290.0040.00417.13
8.0.280.0030.00318.54
8.0.270.0040.00417.23
8.0.260.0030.00317.05
8.0.250.0000.00817.19
8.0.240.0060.00317.13
8.0.230.0030.00317.24
8.0.220.0030.00317.14
8.0.210.0080.00017.09
8.0.200.0040.00417.15
8.0.190.0080.00017.09
8.0.180.0000.00717.20
8.0.170.0000.00717.11
8.0.160.0040.00417.22
8.0.150.0070.00016.98
8.0.140.0000.00716.97
8.0.130.0030.00313.45
8.0.120.0080.00017.18
8.0.110.0020.00517.02
8.0.100.0000.00717.07
8.0.90.0000.00716.92
8.0.80.0060.01617.05
8.0.70.0040.00417.16
8.0.60.0060.00316.92
8.0.50.0060.00316.93
8.0.30.0130.00617.18
8.0.20.0070.01417.40
8.0.10.0040.00417.29
8.0.00.0060.01417.11
7.4.330.0000.00515.55
7.4.320.0000.00616.68
7.4.300.0000.00616.68
7.4.290.0070.00416.73
7.4.280.0030.00616.67
7.4.270.0040.00416.66
7.4.260.0060.00013.42
7.4.250.0040.00416.53
7.4.240.0000.00816.59
7.4.230.0080.00016.86
7.4.220.0030.01716.77
7.4.210.0060.00916.75
7.4.200.0040.00416.81
7.4.160.0100.00716.62
7.4.150.0180.00617.40
7.4.140.0120.00917.86
7.4.130.0230.00516.70
7.4.120.0140.00816.76
7.4.110.0100.01016.79
7.4.100.0120.01216.57
7.4.90.0060.01216.73
7.4.80.0090.00919.39
7.4.70.0000.01716.77
7.4.60.0120.01616.75
7.4.50.0120.00216.64
7.4.40.0120.00616.84
7.4.30.0000.01716.61
7.4.10.0070.00315.18
7.4.00.0040.01315.21
7.3.330.0030.00313.59
7.3.320.0030.00313.38
7.3.310.0040.00416.52
7.3.300.0030.00316.36
7.3.290.0070.00016.39
7.3.280.0080.00916.50
7.3.270.0080.01117.40
7.3.260.0100.00916.72
7.3.250.0110.01216.65
7.3.240.0140.00416.64
7.3.230.0060.01216.71
7.3.210.0100.01016.60
7.3.200.0080.00816.90
7.3.190.0170.00616.52
7.3.180.0090.00916.52
7.3.170.0040.01516.59
7.3.160.0070.01016.78
7.3.130.0050.01114.87
7.3.120.0080.00915.21
7.3.110.0060.01015.17
7.3.100.0080.00715.03
7.3.90.0080.00815.07
7.3.80.0090.00515.01
7.3.70.0080.00615.06
7.3.60.0090.00415.09
7.3.50.0100.00515.15
7.3.40.0050.00715.06
7.3.30.0050.00714.94
7.3.20.0030.01216.81
7.3.10.0050.00916.72
7.3.00.0060.01116.65
7.2.330.0150.00317.01
7.2.320.0040.01516.66
7.2.310.0120.00616.63
7.2.300.0090.00916.62
7.2.290.0060.01216.97
7.2.260.0130.00715.31
7.2.250.0050.00915.46
7.2.240.0060.01315.19
7.2.230.0070.00915.09
7.2.220.0040.00915.45
7.2.210.0050.01115.27
7.2.200.0060.00715.44
7.2.190.0050.00815.22
7.2.180.0090.00715.21
7.2.170.0020.01115.26
7.2.160.0060.00915.42
7.2.150.0090.00616.88
7.2.140.0100.00716.88
7.2.130.0050.01016.78
7.2.120.0100.00616.84
7.2.110.0050.01216.93
7.2.100.0050.00916.88
7.2.90.0050.01016.93
7.2.80.0070.01216.90
7.2.70.0050.00917.05
7.2.60.0070.00817.00
7.2.50.0080.00616.94
7.2.40.0160.00516.96
7.2.30.0060.00617.10
7.2.20.0080.00817.08
7.2.10.0050.00917.04
7.2.00.0030.01017.86
7.1.330.0050.01115.93
7.1.320.0020.01516.02
7.1.310.0050.01016.03
7.1.300.0060.00816.07
7.1.290.0050.01116.03
7.1.280.0050.00915.85
7.1.270.0050.00715.86
7.1.260.0140.00515.97
7.1.250.0070.01215.66
7.1.240.0110.00415.98
7.1.230.0110.00315.98
7.1.220.0000.00916.01
7.1.210.0030.01316.03
7.1.200.0030.01215.84
7.1.190.0030.01415.98
7.1.180.0030.01016.03
7.1.170.0060.00315.98
7.1.160.0030.00715.82
7.1.150.0070.00715.98
7.1.140.0070.00716.03
7.1.130.0030.01016.09
7.1.120.0040.00816.08
7.1.110.0090.00615.84
7.1.100.0020.01017.02
7.1.90.0110.00415.88
7.1.80.0000.00916.13
7.1.70.0020.00816.71
7.1.60.0320.01224.81
7.1.50.0510.01024.70
7.1.40.0270.01524.45
7.1.30.0320.01024.40
7.1.20.0320.00824.42
7.1.10.0240.00715.32
7.1.00.0300.01415.56
7.0.330.0040.01115.55
7.0.320.0090.00615.55
7.0.310.0060.00615.45
7.0.300.0000.01215.61
7.0.290.0060.00615.30
7.0.280.0040.00415.59
7.0.270.0040.00815.61
7.0.260.0040.01115.54
7.0.250.0000.01115.45
7.0.240.0000.01215.68
7.0.230.0030.01015.63
7.0.220.0120.00315.40
7.0.210.0040.01115.57
7.0.200.0330.01015.28
7.0.190.0230.00815.20
7.0.180.0170.01315.10
7.0.170.0280.00315.16
7.0.160.0280.01115.04
7.0.150.0200.01014.96
7.0.140.0200.01115.25
7.0.130.0200.01215.19
7.0.120.0250.00715.06
7.0.110.0200.00815.11
7.0.100.0270.00815.01
7.0.90.0210.00615.10
7.0.80.0180.00815.10
7.0.70.0220.00915.17
7.0.60.0330.00514.95
7.0.50.0500.00215.15
7.0.40.0220.00814.25
7.0.30.0150.01414.23
7.0.20.0240.00814.23
7.0.10.0180.01014.25
7.0.00.0290.00514.32
5.6.400.0030.01114.73
5.6.390.0060.00914.67
5.6.380.0110.00414.60
5.6.370.0030.01014.76
5.6.360.0060.00914.37
5.6.350.0080.00814.86
5.6.340.0060.00614.63
5.6.330.0030.01014.54
5.6.320.0050.00514.76
5.6.310.0030.00914.65
5.6.300.0100.00014.88
5.6.290.0060.00914.67
5.6.280.0040.01114.73
5.6.270.0070.00314.66
5.6.260.0030.01014.55
5.6.250.0070.00714.93
5.6.240.0100.00714.84
5.6.230.0060.00914.52
5.6.220.0070.00714.41
5.6.210.0120.00014.50
5.6.200.0060.00614.66
5.6.190.0070.01014.52
5.6.180.0000.01014.43
5.6.170.0040.00714.75
5.6.160.0060.00614.61
5.6.150.0030.01514.66
5.6.140.0100.00614.93
5.6.130.0070.01114.94
5.6.120.0070.01114.33
5.6.110.0170.00014.76
5.6.100.0090.00314.54
5.6.90.0000.01114.57
5.6.80.0090.00614.75
5.6.70.0030.00614.78
5.6.60.0000.01214.65
5.6.50.0050.00614.55
5.6.40.0030.01014.86
5.6.30.0100.00614.42
5.6.20.0060.01014.57
5.6.10.0090.00914.68
5.6.00.0120.00614.65

preferences:
54.4 ms | 400 KiB | 5 Q