3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Car { protected Supplier $supplier; public function __construct() { $this->supplier = new Supplier(); } final public function getSupplier(): Supplier { return $this->supplier; } } class Supplier { const SUPPLIERS = [ 1 => 'toyota', 2 => 'bmw' ]; private $id; private $name; final public function set(mixed $value): void { if (is_int($value)) { $this->id = $value; $this->name = self::SUPPLIERS[$value]; } elseif (is_string($value)) { $this->name = $value; $this->id = array_search($value, self::SUPPLIERS); } else { throw new \InvalidArgumentException('Invalid value:' . $value); } } public function setByName(string $name) { $this->name = $name; $this->id = array_search($name, self::SUPPLIERS); } public function getId(): int { return $this->id; } public function getName(): string { return $this->name; } } $car = new Car(); // IdのセットでNameも自動でセットされる $car->getSupplier()->set(1); echo $car->getSupplier()->getId() . PHP_EOL; // 1 echo $car->getSupplier()->getName() . PHP_EOL; // toyota // NameのセットでIdも自動でセットされる $car->getSupplier()->set('bmw'); echo $car->getSupplier()->getId() . PHP_EOL; // 2 echo $car->getSupplier()->getName() . PHP_EOL; // bmw

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.5.10.0140.00616.88
8.5.00.0130.01020.26
8.4.160.0120.00823.97
8.4.150.0020.00014.05
8.4.140.0110.01217.52
8.4.130.0050.00518.89
8.4.120.0090.00317.95
8.4.110.0100.01324.04
8.4.100.0110.00917.65
8.4.90.0120.00820.58
8.4.80.0050.00318.98
8.4.70.0070.01218.92
8.4.60.0140.00818.87
8.4.50.0120.00819.35
8.4.40.0120.00917.86
8.4.30.0070.00720.40
8.4.20.0070.00719.82
8.4.10.0060.01319.36
8.3.280.0150.00718.52
8.3.270.0110.00916.71
8.3.260.0100.00916.52
8.3.250.0130.01016.54
8.3.240.0100.00616.91
8.3.230.0110.00816.55
8.3.220.0130.00619.08
8.3.210.0050.00316.79
8.3.200.0040.00516.34
8.3.190.0100.01016.56
8.3.180.0060.00416.61
8.3.170.0180.00018.83
8.3.160.0070.01118.52
8.3.150.0050.00318.42
8.3.140.0090.00919.08
8.3.130.0080.00018.50
8.3.120.0000.00919.23
8.3.110.0060.00320.94
8.3.100.0030.00624.06
8.3.90.0060.01526.77
8.3.80.0030.00718.30
8.3.70.0120.00916.75
8.3.60.0140.00716.75
8.3.50.0160.00616.85
8.3.40.0120.00320.34
8.3.30.0170.00019.29
8.3.20.0070.00024.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.290.0100.00316.72
8.2.280.0110.00818.36
8.2.270.0120.00617.06
8.2.260.0040.01119.95
8.2.250.0080.00016.66
8.2.240.0030.00717.16
8.2.230.0090.00622.58
8.2.220.0070.01037.54
8.2.210.0090.00926.77
8.2.200.0000.00916.88
8.2.190.0070.00718.16
8.2.180.0090.00625.92
8.2.170.0080.00818.93
8.2.160.0030.01022.96
8.2.150.0080.00025.66
8.2.140.0040.01124.66
8.2.130.0040.00426.16
8.2.120.0050.00319.48
8.2.110.0150.00622.07
8.2.100.0070.00420.58
8.2.90.0160.00620.65
8.2.80.0150.00620.67
8.2.70.0070.01420.48
8.2.60.0150.00620.45
8.2.50.0100.01020.48
8.2.40.0140.00720.73
8.2.30.0130.00720.45
8.2.20.0110.01120.56
8.2.10.0100.00720.81
8.2.00.0100.00720.63
8.1.330.0100.00916.32
8.1.320.0090.01116.16
8.1.310.0090.00018.40
8.1.300.0120.00620.25
8.1.290.0070.00330.84
8.1.280.0070.00725.92
8.1.270.0030.00623.95
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0160.00620.38
8.1.230.0180.00320.48
8.1.220.0070.01320.39
8.1.210.0150.00721.69
8.1.200.0150.00620.20
8.1.190.0190.00320.29
8.1.180.0140.00720.39
8.1.170.0100.00620.27
8.1.160.0150.00720.65
8.1.150.0150.00620.52
8.1.140.0120.00820.28
8.1.130.0100.00620.29
8.1.120.0000.00920.41
8.1.110.0060.00320.33
8.1.100.0090.00020.46
8.1.90.0060.00320.36
8.1.80.0070.01520.32
8.1.70.0030.00620.66
8.1.60.0090.00020.46
8.1.50.0050.00520.30
8.1.40.0120.00920.58
8.1.30.0140.00720.82
8.1.20.0100.01020.53
8.1.10.0190.00320.53
8.1.00.0110.00620.41
8.0.300.0090.00919.64
8.0.290.0040.01219.73
8.0.280.0150.00019.69
8.0.270.0070.01419.83
8.0.260.0130.00619.58
8.0.250.0110.00019.83
8.0.240.0100.00719.80
8.0.230.0140.00319.99
8.0.220.0200.00319.77
8.0.210.0140.00719.70
8.0.200.0070.01519.78
8.0.190.0070.01019.76
8.0.180.0180.00319.80
8.0.170.0070.01019.76
8.0.160.0070.00319.70
8.0.150.0090.00319.48
8.0.140.0060.00319.61
8.0.130.0210.00019.64
8.0.120.0100.01017.96
8.0.110.0130.00918.08
8.0.100.0030.00618.00
8.0.90.0060.00317.91
8.0.80.0030.00617.96
8.0.70.0040.01117.82
8.0.60.0100.00017.73
8.0.50.0090.00017.96
8.0.30.0000.00918.05
8.0.20.0140.00717.88
8.0.10.0100.00017.95

preferences:
32.36 ms | 403 KiB | 5 Q