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) { $this->timestamp = new \DateTimeImmutable(); } return $this->timestamp->format('c'); } } 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; } public function serialize($entity = null, $recursionDepth = 2) { $entity = $entity?: $this; $result = []; $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->serialize($subValue, $recursionDepth - 1); continue; } $result[$propertyName][$name] = "***"; continue; } if (is_array($subValue)) { $result[$propertyName][$name] = $subValue; continue; } $result[$propertyName][$name] = $subValue; } continue; } if (is_object($value)) { if ($recursionDepth > 0) { $result[$propertyName] = $this->serialize($value, $recursionDepth - 1); continue; } $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); $foo->addEvents($event); var_dump( $foo->serialize());

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.0120.00618.55
8.3.50.0150.00016.66
8.3.40.0030.01519.09
8.3.30.0160.00019.09
8.3.20.0040.00420.39
8.3.10.0000.00923.45
8.3.00.0040.00420.87
8.2.180.0090.00918.29
8.2.170.0090.00622.96
8.2.160.0110.00422.30
8.2.150.0080.00024.18
8.2.140.0050.00224.66
8.2.130.0040.00420.38
8.2.120.0080.00026.35
8.2.110.0100.00022.24
8.2.100.0000.01217.91
8.2.90.0040.00419.07
8.2.80.0030.00518.05
8.2.70.0030.00517.88
8.2.60.0080.00018.18
8.2.50.0000.00818.10
8.2.40.0030.00520.61
8.2.30.0040.00719.32
8.2.20.0000.00818.28
8.2.10.0000.00818.23
8.2.00.0050.00318.27
8.1.280.0040.01225.92
8.1.270.0000.00822.14
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00323.88
8.1.230.0000.01122.13
8.1.220.0060.00317.75
8.1.210.0000.00818.77
8.1.200.0030.00617.48
8.1.190.0030.00617.35
8.1.180.0050.00318.10
8.1.170.0030.00618.66
8.1.160.0000.00818.99
8.1.150.0030.00620.61
8.1.140.0040.00419.58
8.1.130.0030.00318.98
8.1.120.0040.00417.71
8.1.110.0050.00317.65
8.1.100.0030.00617.72
8.1.90.0000.00717.57
8.1.80.0030.00617.59
8.1.70.0080.00017.71
8.1.60.0030.00617.73
8.1.50.0080.00017.74
8.1.40.0000.00817.61
8.1.30.0050.00317.89
8.1.20.0000.01117.75
8.1.10.0080.00017.80
8.1.00.0040.00417.72
8.0.300.0040.00418.77
8.0.290.0040.00416.86
8.0.280.0030.00318.61
8.0.270.0080.00017.41
8.0.260.0070.00017.05
8.0.250.0040.00417.13
8.0.240.0080.00017.02
8.0.230.0060.00317.19
8.0.220.0050.00317.08
8.0.210.0050.00217.01
8.0.200.0030.00317.07
8.0.190.0030.00517.08
8.0.180.0000.00817.23
8.0.170.0030.00517.10
8.0.160.0000.00717.08
8.0.150.0000.00717.13
8.0.140.0000.00717.06
8.0.130.0000.00613.52
8.0.120.0040.00417.07
8.0.110.0080.00017.16
8.0.100.0040.00417.18
8.0.90.0080.00016.94
8.0.80.0060.00917.07
8.0.70.0040.00416.96
8.0.60.0030.00517.14
8.0.50.0000.00717.10
8.0.30.0100.01017.13
8.0.20.0110.00917.48
8.0.10.0040.00417.30
8.0.00.0060.01217.01
7.4.330.0000.00515.55
7.4.320.0000.00616.72
7.4.300.0030.00316.82
7.4.290.0040.00416.74
7.4.280.0030.00716.55
7.4.270.0000.00716.57
7.4.260.0060.00013.25
7.4.250.0000.00716.62
7.4.240.0040.00416.78
7.4.230.0030.00316.60
7.4.220.0160.01016.82
7.4.210.0000.01516.71
7.4.200.0030.00316.77
7.4.160.0100.00616.77
7.4.150.0160.00317.40
7.4.140.0150.00617.86
7.4.130.0110.01116.75
7.4.120.0110.01116.72
7.4.110.0070.01116.79
7.4.100.0120.00616.68
7.4.90.0030.01416.75
7.4.80.0110.01119.39
7.4.70.0060.01216.79
7.4.60.0130.00616.76
7.4.50.0030.00716.74
7.4.40.0150.00716.70
7.4.30.0080.01116.71
7.4.00.0100.00614.95
7.3.330.0000.00513.47
7.3.320.0060.00013.39
7.3.310.0050.00316.62
7.3.300.0030.00316.47
7.3.290.0100.00616.52
7.3.280.0090.01016.49
7.3.270.0150.00317.40
7.3.260.0100.01316.72
7.3.250.0140.00916.65
7.3.240.0140.00816.77
7.3.230.0080.01616.64
7.3.210.0130.00616.56
7.3.200.0070.01016.58
7.3.190.0090.00916.50
7.3.180.0060.01216.84
7.3.170.0100.00616.68
7.3.160.0070.01016.72
7.3.10.0140.00716.59
7.3.00.0160.00516.40
7.2.330.0110.00816.76
7.2.320.0140.00816.73
7.2.310.0030.01516.91
7.2.300.0200.00316.69
7.2.290.0210.00616.82
7.2.130.0140.00916.71
7.2.120.0110.00816.70
7.2.110.0140.00516.74
7.2.100.0100.00616.69
7.2.90.0070.01516.60
7.2.80.0100.01016.75
7.2.70.0100.01016.67
7.2.60.0130.00516.83
7.2.50.0180.00316.99
7.2.40.0110.01316.79
7.2.30.0150.00516.77
7.2.20.0140.00716.63
7.2.10.0180.00516.75
7.2.00.0050.01217.92
7.1.250.0100.00715.36
7.1.240.0080.01516.12
7.1.230.0070.01115.80
7.1.220.0100.00716.05
7.1.210.0130.00715.89
7.1.200.0090.00615.91
7.1.190.0080.01215.48
7.1.180.0130.01015.77
7.1.170.0060.01315.88
7.1.160.0130.00315.64
7.1.150.0150.00715.98
7.1.140.0070.01016.05
7.1.130.0070.00716.10
7.1.120.0120.00416.13
7.1.110.0120.00615.76
7.1.100.0060.00817.19
7.1.90.0150.00316.11
7.1.80.0140.00316.11
7.1.70.0090.00416.69
7.1.60.0210.01224.69
7.1.50.0300.00824.53
7.1.40.0180.01424.27
7.1.30.0220.01624.29
7.1.20.0230.01024.31
7.1.10.0210.00815.29
7.1.00.0170.01315.48
7.0.330.0150.00615.49
7.0.320.0090.01215.31
7.0.310.0190.00615.55
7.0.300.0140.00915.60
7.0.290.0140.00715.23
7.0.280.0040.01715.36
7.0.270.0070.01715.76
7.0.260.0110.01115.38
7.0.250.0180.00915.47
7.0.240.0090.01615.59
7.0.230.0160.00515.74
7.0.220.0100.00815.27
7.0.210.0120.01515.46
7.0.200.0160.01115.20
7.0.190.0190.01015.26
7.0.180.0250.00815.17
7.0.170.0220.01115.09
7.0.160.0170.01515.08
7.0.150.0220.01015.11
7.0.140.0180.01315.19
7.0.130.0200.01015.15
7.0.120.0200.00915.32
7.0.110.0210.00815.07
7.0.100.0250.00815.13
7.0.90.0230.00715.21
7.0.80.0230.00715.18
7.0.70.0190.01115.13
7.0.60.0250.01015.09
7.0.50.0210.01315.26
7.0.40.0230.00514.20
7.0.30.0190.00914.26
7.0.20.0300.00814.11
7.0.10.0180.00614.22
7.0.00.0170.00914.06
5.6.380.0150.00314.70

preferences:
46.39 ms | 401 KiB | 5 Q