3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class ToolSetFactory { protected array $products = []; public function make(string $productName, ...$params): Drawable { if ($product = $this->products[$productName] ?? null) return new $product($params); return new NullProduct(); } } class BasicToolSetFactory extends ToolSetFactory { public function __construct() { $this->products['general'] = GeneralProduct::class; $this->products['arrows'] = ArrowsProduct::class; } } // Interfaces interface Drawable { public function draw(): void; } interface General extends Drawable {} interface Arrows extends Drawable {} // Product classes class GeneralProduct implements General { public function draw(): void { print "Drawing general elements\n"; } // Other methods } class ArrowsProduct implements Arrows { public function draw(): void { print "Drawing arrows elements\n"; } // Other methods } // Client code class BasicToolSet { public function createToolSet(ToolSetFactory $factory): void { $general = $factory->make('general'); $arrows = $factory->make('arrows'); foreach ([$general, $arrows] as $product) { $product->draw(); } } } // Usage $basicToolSetFactory = new BasicToolSetFactory(); $basicToolSet = new BasicToolSet(); $basicToolSet->createToolSet($basicToolSetFactory);

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.120.0090.00019.17
8.3.110.0030.00616.76
8.3.100.0030.00616.34
8.3.90.0040.00416.55
8.3.80.0030.00618.29
8.3.70.0070.01116.76
8.3.60.0150.00018.31
8.3.50.0110.00716.47
8.3.40.0030.01220.47
8.3.30.0080.00818.84
8.3.20.0050.00324.18
8.3.10.0080.00024.66
8.3.00.0050.00326.16
8.2.240.0070.01018.31
8.2.230.0160.00320.94
8.2.220.0050.00324.06
8.2.210.0070.01026.77
8.2.200.0100.00016.50
8.2.190.0130.00616.58
8.2.180.0070.00716.38
8.2.170.0140.00419.00
8.2.160.0140.00322.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00421.03
8.2.110.0080.00322.25
8.2.100.0040.00420.40
8.2.20.0100.00118.64
8.1.300.0130.00717.85
8.1.290.0060.00318.88
8.1.280.0160.00325.92
8.1.270.0110.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00318.61
8.1.230.0100.00018.68

preferences:
41.87 ms | 403 KiB | 5 Q