3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface MediatorInterface { public function send($message, Colleague $from); public function add(Colleague $colleague); } interface SuggestionProviderInterface { public function getSuggestionsFor($data); } class ContactSuggestionProvider implements SuggestionProviderInterface { public function getSuggestionsFor($data) { if (!isset($data['customer'])) { return [ 'contact a', // Suggestion 'contact b', // Suggestion 'contact c' // Suggestion ]; } return []; } } class WorkplaceSuggestionProvider implements SuggestionProviderInterface { public function getSuggestionsFor($data) { if (!isset($data['customer']) && !isset($data['contact'])) { return [ ['workplace a'], // Suggestion ['workplace b'] // Suggestion ]; } return []; } } class PaymentTypeSuggestionProvider implements SuggestionProviderInterface { public function getSuggestionsFor($data) { if (!isset($data['customer']) && !isset($data['contact']) && !isset($data['workplace'])) { return [ ['payment-type a'], // Suggestion ['payment-type b'] // Suggestion ]; } return []; } } abstract class Colleague { /** * @var Mediator */ private $mediator; abstract public function receive($suggestions); public function send($message) { $this->getMediator()->send($message, $this); } public function setMediator(MediatorInterface $mediator) { $this->mediator = $mediator; } public function getMediator() { return $this->mediator; } } class Customer extends Colleague { public function receive($suggestions) {} public function __change() { $this->send(['customer' => 'Ocramius']); } } class Contact extends Colleague { public function receive($suggestions) { var_dump($suggestions); } } class Workplace extends Colleague { public function receive($suggestions) { var_dump($suggestions); } } class PaymentType extends Colleague { public function receive($suggestions) { var_dump($suggestions); } } class SuggestionMediator implements MediatorInterface { private $colleagues = []; private $suggestionProviders = []; public function addSuggestionProvider(SuggestionProviderInterface $provider) { $this->suggestionProviders[] = $provider; } public function add(Colleague $colleague) { $colleague->setMediator($this); $this->colleagues[] = $colleague; } public function send($message, Colleague $from) { foreach ($this->colleagues as $colleague) { // what here I'll have here about providers? if ($from !== $colleague) { $colleague->receive($suggestions); } } } } $customer = new Customer(); $contact = new Contact(); $workplace = new Workplace(); $paymentType = new PaymentType(); $mediator = new SuggestionMediator(); $mediator->addSuggestionProvider(new ContactSuggestionProvider()); $mediator->addSuggestionProvider(new WorkplaceSuggestionProvider()); $mediator->addSuggestionProvider(new PaymentTypeSuggestionProvider()); $mediator->add($customer); $mediator->add($contact); $mediator->add($workplace); $mediator->add($paymentType); $customer->__change();

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.56
8.3.50.0100.01022.01
8.3.40.0160.00318.79
8.3.30.0120.00619.21
8.3.20.0040.00419.98
8.3.10.0050.00323.57
8.3.00.0070.00719.38
8.2.180.0040.01117.00
8.2.170.0150.00622.96
8.2.160.0030.01020.35
8.2.150.0110.00424.18
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0030.00622.17
8.2.110.0060.00619.45
8.2.100.0110.00017.91
8.2.90.0040.00417.74
8.2.80.0050.00317.97
8.2.70.0060.00317.75
8.2.60.0050.00318.05
8.2.50.0000.00818.07
8.2.40.0030.00618.03
8.2.30.0040.00418.24
8.2.20.0000.00817.75
8.2.10.0080.00018.23
8.2.00.0070.00017.72
8.1.280.0100.01025.92
8.1.270.0090.00623.70
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0040.00422.66
8.1.230.0000.01120.88
8.1.220.0030.00517.77
8.1.210.0060.00318.89
8.1.200.0030.00617.48
8.1.190.0000.00917.35
8.1.180.0000.00818.10
8.1.170.0000.00918.65
8.1.160.0070.00021.94
8.1.150.0000.00718.84
8.1.140.0040.00417.40
8.1.130.0040.00417.86
8.1.120.0000.00717.41
8.1.110.0000.00717.42
8.1.100.0030.00317.54
8.1.90.0050.00317.57
8.1.80.0070.00017.52
8.1.70.0000.00717.30
8.1.60.0000.00817.63
8.1.50.0040.00417.56
8.1.40.0060.00617.44
8.1.30.0090.00017.76
8.1.20.0000.00817.65
8.1.10.0040.00417.61
8.1.00.0080.00017.57
8.0.300.0000.00720.16
8.0.290.0000.00716.88
8.0.280.0000.00718.40
8.0.270.0000.00717.18
8.0.260.0030.00317.21
8.0.250.0030.00317.07
8.0.240.0040.00417.02
8.0.230.0040.00417.06
8.0.220.0000.00617.06
8.0.210.0000.00716.90
8.0.200.0000.00717.07
8.0.190.0070.00317.05
8.0.180.0000.00716.93
8.0.170.0080.00016.99
8.0.160.0030.00617.07
8.0.150.0040.00416.93
8.0.140.0000.00717.00
8.0.130.0000.00513.46
8.0.120.0000.01116.99
8.0.110.0030.00517.03
8.0.100.0000.00717.04
8.0.90.0000.00716.86
8.0.80.0100.00716.99
8.0.70.0000.00716.99
8.0.60.0040.00417.04
8.0.50.0040.00416.89
8.0.30.0110.00817.31
8.0.20.0080.01017.40
8.0.10.0070.00017.16
8.0.00.0060.01516.96
7.4.330.0000.00515.09
7.4.320.0080.00016.48
7.4.300.0030.00316.62
7.4.290.0030.00316.70
7.4.280.0080.00316.51
7.4.270.0070.00016.46
7.4.260.0070.00016.56
7.4.250.0000.00716.42
7.4.240.0000.00716.57
7.4.230.0030.00316.72
7.4.220.0060.01216.54
7.4.210.0120.00316.49
7.4.200.0070.00016.65
7.4.160.0060.00916.46
7.4.150.0070.01017.40
7.4.140.0120.01117.86
7.4.130.0080.01116.64
7.4.120.0060.01116.63
7.4.110.0140.00316.64
7.4.100.0000.01616.54
7.4.90.0100.00716.63
7.4.80.0130.01019.39
7.4.70.0030.01616.73
7.4.60.0100.00716.63
7.4.50.0040.00416.70
7.4.40.0150.00316.81
7.4.30.0110.01316.69
7.4.00.0090.00315.18
7.3.330.0000.00513.61
7.3.320.0030.00313.32
7.3.310.0000.00716.55
7.3.300.0000.00716.37
7.3.290.0180.00016.39
7.3.280.0050.01116.49
7.3.270.0000.01917.40
7.3.260.0060.01216.47
7.3.250.0090.01116.44
7.3.240.0100.00716.53
7.3.230.0030.01516.70
7.3.210.0100.00916.52
7.3.200.0120.00619.39
7.3.190.0100.01316.47
7.3.180.0030.01416.31
7.3.170.0130.00416.64
7.3.160.0060.01016.57
7.3.10.0040.01116.77
7.3.00.0030.01316.63
7.2.330.0090.00916.64
7.2.320.0120.00416.64
7.2.310.0120.00616.84
7.2.300.0060.01316.75
7.2.290.0090.01516.79
7.2.130.0130.00316.75
7.2.120.0060.00916.95
7.2.110.0090.00616.98
7.2.100.0040.01116.82
7.2.90.0140.00017.06
7.2.80.0050.00517.02
7.2.70.0030.01016.82
7.2.60.0060.01016.88
7.2.50.0060.00616.83
7.2.40.0040.00817.01
7.2.30.0040.01116.88
7.2.20.0060.00616.91
7.2.10.0060.00317.06
7.2.00.0030.01216.89
7.1.250.0110.00415.81
7.1.200.0000.01315.71
7.1.70.0000.00816.91
7.1.60.0130.01319.32
7.1.50.0070.02117.04
7.1.00.0000.08022.40
7.0.200.0070.00316.61
7.0.140.0030.07322.08
7.0.100.0170.07320.12
7.0.90.0100.08019.94
7.0.80.0200.06720.07
7.0.70.0100.07720.03
7.0.60.0000.07019.84
7.0.50.0100.08020.34
7.0.40.0070.08020.11
7.0.30.0030.08020.09
7.0.20.0130.06020.15
7.0.10.0070.07719.92
7.0.00.0030.08720.07
5.6.280.0100.06720.84
5.6.250.0130.07020.79
5.6.240.0230.06720.76
5.6.230.0130.05020.72
5.6.220.0030.04720.64
5.6.210.0000.07320.81
5.6.200.0070.06321.18
5.6.190.0030.08321.09
5.6.180.0130.07321.17
5.6.170.0030.08321.09
5.6.160.0130.07021.19
5.6.150.0100.07721.12
5.6.140.0070.07021.19
5.6.130.0070.06321.09
5.6.120.0200.06721.06
5.6.110.0170.07321.16
5.6.100.0130.05321.07
5.6.90.0030.05721.18
5.6.80.0170.05320.39
5.6.70.0100.07020.39
5.6.60.0070.07720.61
5.6.50.0030.04720.53
5.6.40.0100.07720.51
5.6.30.0130.07020.37
5.6.20.0030.08720.41
5.6.10.0100.07320.42
5.6.00.0070.08020.45
5.5.380.0030.08020.57
5.5.370.0070.07320.43
5.5.360.0100.07720.39
5.5.350.0030.08720.44
5.5.340.0030.08720.82
5.5.330.0070.08020.98
5.5.320.0130.06720.97
5.5.310.0100.07320.94
5.5.300.0070.04320.97
5.5.290.0070.08320.97
5.5.280.0100.08320.95
5.5.270.0100.07720.90
5.5.260.0000.05720.93
5.5.250.0100.05020.50
5.5.240.0170.06320.32
5.5.230.0130.06020.26
5.5.220.0130.08720.36
5.5.210.0130.05720.22
5.5.200.0100.04320.27
5.5.190.0100.06320.28
5.5.180.0130.07720.29
5.5.160.0070.06720.29
5.5.150.0130.07320.22
5.5.140.0070.06720.22
5.5.130.0100.07320.30
5.5.120.0030.07020.18
5.5.110.0030.08320.32
5.5.100.0000.08720.07
5.5.90.0170.04020.13
5.5.80.0170.06720.15
5.5.70.0000.05020.23
5.5.60.0030.06720.16
5.5.50.0100.04720.11
5.5.40.0030.07320.11
5.5.30.0070.04320.08
5.5.20.0100.09019.98
5.5.10.0030.08720.01
5.5.00.0100.08020.00
5.4.450.0070.08019.21
5.4.440.0130.08019.21
5.4.430.0070.07319.35
5.4.420.0070.06319.44
5.4.410.0070.07019.23
5.4.400.0170.03718.91
5.4.390.0070.07318.95
5.4.380.0070.08019.05
5.4.370.0070.07019.16
5.4.360.0030.05719.13
5.4.350.0070.07718.95
5.4.340.0000.08319.10
5.4.320.0130.07019.16
5.4.310.0270.06019.24
5.4.300.0100.06319.23
5.4.290.0070.07318.94
5.4.280.0070.07019.03
5.4.270.0070.04319.00
5.4.260.0000.08018.85
5.4.250.0070.07319.04
5.4.240.0200.06018.84
5.4.230.0130.06719.23
5.4.220.0130.07319.03
5.4.210.0070.07319.23
5.4.200.0070.06019.09
5.4.190.0100.06719.02
5.4.180.0030.04718.87
5.4.170.0100.06319.24
5.4.160.0070.07318.88
5.4.150.0070.06319.12
5.4.140.0170.06716.56
5.4.130.0030.04716.48
5.4.120.0130.06016.38
5.4.110.0130.06716.53
5.4.100.0030.07016.58
5.4.90.0070.04016.49
5.4.80.0100.06016.43
5.4.70.0030.04016.38
5.4.60.0000.08316.47
5.4.50.0000.05016.45
5.4.40.0130.06316.46
5.4.30.0030.03716.46
5.4.20.0070.07016.39
5.4.10.0030.07016.50
5.4.00.0070.06315.83

preferences:
43.29 ms | 401 KiB | 5 Q