3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class FormattedString { private string $value; private function __construct (string $str) { $this->value = $str; } public static function create (string $str): self|NotValidFormattedString { $matches = null; preg_match("/[a-z]{2}-[a-z]{2}-[a-z]{8}-[a-z]{1}/", $str, $matches); if (count($matches) === 0) { return new NotValidFormattedString($str, "poshel nahoi suka, chto za govno ti mne peredal, blyad"); } return new self($str); } } readonly class NotValidFormattedString { public function __construct (public string $str, public string $err) {} } class ValidateFormattedString { public function __invoke(string $str): FormattedString|NotValidFormattedString { return FormattedString::create($str); } } class SuperYellowCircle { public function __construct (public FormattedString $toChtoVMoemPrimereByloClassomYoba) {} } $stringOne = (new ValidateFormattedString)("aa-bb-cccccccc-d"); $circleOne = new SuperYellowCircle($stringOne); var_dump($circleOne); $stringTwo = (new ValidateFormattedString)("butthurt"); $circleTwo = new SuperYellowCircle($stringTwo); var_dump($circleTwo);

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.4.120.0030.00624.32
8.4.110.0060.00322.54
8.4.100.0040.00818.75
8.4.90.0110.01018.70
8.4.80.0120.00818.74
8.4.70.0110.00918.46
8.4.60.0150.00717.98
8.4.50.0130.00819.93
8.4.40.0040.01418.16
8.4.30.0130.00718.72
8.4.20.0040.00418.36
8.4.10.0080.00019.73
8.3.250.0100.00918.75
8.3.240.0150.00417.05
8.3.230.0050.00317.31
8.3.220.0060.01318.81
8.3.210.0120.00716.82
8.3.200.0130.00716.90
8.3.190.0130.00717.07
8.3.180.0120.00717.03
8.3.170.0120.00618.92
8.3.160.0060.01218.63
8.3.150.0150.00317.54
8.3.140.0100.01020.73
8.3.130.0080.00018.77
8.3.120.0070.01019.16
8.3.110.0120.00818.55
8.3.100.0040.00416.71
8.3.50.0090.00616.88
8.3.00.0160.00528.09
8.2.290.0130.00620.59
8.2.280.0090.00618.53
8.2.270.0150.00316.93
8.2.260.0070.00317.11
8.2.250.0060.00316.97
8.2.240.0000.00917.27
8.2.230.0140.00416.70
8.2.220.0030.01316.99
8.1.330.0140.00521.76
8.1.320.0100.00816.19
8.1.310.0040.01416.07
8.1.300.0030.00518.23

preferences:
29.83 ms | 403 KiB | 5 Q