3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); abstract class User { public const STATUS_ACTIVE = 'active'; public const STATUS_INACTIVE = 'inactive'; public function __construct(public string $email, public string $status = self::STATUS_ACTIVE) { } // le mot clé self a été modifié pour le mot clé static dans la méthode :) public function setStatus(string $status): void { assert( in_array($status, [static::STATUS_ACTIVE, static::STATUS_INACTIVE]), sprintf('Le status %s n\'est pas valide. Les status possibles sont : %s', $status, implode(', ',[static::STATUS_ACTIVE, static::STATUS_INACTIVE])) ); $this->status = $status; } public function getStatus(): string { return $this->status; } abstract public function getUsername(): string; } final class Admin extends User { public const STATUS_ACTIVE = 'is_active'; public const STATUS_INACTIVE = 'is_inactive'; // Ajout d'un tableau de roles pour affiner les droits des administrateurs :) public function __construct(string $email, string $status = self::STATUS_ACTIVE, public array $roles = []) { parent::__construct($email, $status); } public function getUsername(): string { return $this->email; } // ... } $admin = new Admin('michel@petrucciani.com'); var_dump($admin); $admin->setStatus(Admin::STATUS_INACTIVE);

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.10.0090.00019.44
8.3.140.0000.00816.55
8.3.130.0130.00316.80
8.3.120.0160.00319.00
8.3.110.0080.00320.94
8.3.100.0150.00834.84
8.3.90.0170.01026.77
8.3.80.0230.00621.70
8.3.70.0100.01221.70
8.3.60.0210.01223.84
8.3.50.0250.00922.41
8.3.40.0200.00722.69
8.3.30.0200.00622.73
8.3.20.0220.00425.47
8.3.10.0170.00825.71
8.3.00.0170.00826.46
8.2.250.0050.00518.46
8.2.240.0030.00617.42
8.2.230.0080.00022.58
8.2.220.0060.00337.54
8.2.210.0160.00926.77
8.2.200.0160.01121.82
8.2.190.0180.01321.70
8.2.180.0170.00926.34
8.2.170.0240.00722.86
8.2.160.0220.00524.87
8.2.150.0240.00826.21
8.2.140.0170.00325.71
8.2.130.0120.00326.46
8.2.120.0100.00423.21
8.2.110.0150.00024.51
8.2.100.0110.00422.34
8.2.90.0170.00622.20
8.2.80.0140.01022.78
8.2.70.0170.00650.76
8.2.60.0120.01422.13
8.2.50.0080.00921.30
8.2.40.0160.00723.98
8.2.30.0180.00522.36
8.2.20.0160.00522.36
8.2.10.0150.00723.07
8.2.00.0130.00822.95
8.1.300.0060.00315.96
8.1.290.0200.00822.82
8.1.280.0180.01026.34
8.1.270.0170.00925.39
8.1.260.0180.00526.56
8.1.250.0150.00427.43
8.1.240.0170.00725.28
8.1.230.0200.00322.93
8.1.220.0200.00622.26
8.1.210.0210.00422.77
8.1.200.0160.00422.06
8.1.190.0230.00722.00
8.1.180.0170.00722.43
8.1.170.0140.00922.51
8.1.160.0150.00822.79
8.1.150.0100.01022.83
8.1.140.0170.00722.82
8.1.130.0190.00322.86
8.1.120.0110.00519.39
8.1.110.0120.00619.66
8.1.100.0100.00819.00
8.1.90.0090.00819.01
8.1.80.0100.00718.80
8.1.70.0090.00418.18
8.1.60.0100.00618.71
8.1.50.0100.00818.52
8.1.40.0130.00518.57
8.1.30.0140.00518.38
8.1.20.0130.00518.35
8.1.10.0120.00618.45
8.1.00.0130.00718.42
8.0.300.0160.00722.77
8.0.290.0160.00721.76
8.0.280.0170.00622.59
8.0.270.0120.01022.34
8.0.260.0130.00520.20
8.0.250.0130.00619.33
8.0.240.0150.00318.86
8.0.230.0100.00518.54
8.0.220.0100.00618.75
8.0.210.0130.00418.24
8.0.200.0100.00718.31
8.0.190.0130.00418.14
8.0.180.0130.00517.95
8.0.170.0110.00617.98
8.0.160.0130.00717.88
8.0.150.0120.00517.75
8.0.140.0120.00417.81
8.0.130.0110.00617.35
8.0.120.0100.00617.78
8.0.110.0100.00517.80
8.0.100.0110.00517.83
8.0.90.0110.00417.62
8.0.80.0100.00517.78
8.0.70.0120.00417.73
8.0.60.0100.00617.74
8.0.50.0110.00517.80
8.0.30.0140.00317.67
8.0.20.0130.00517.78
8.0.10.0130.00517.82
8.0.00.0100.00417.90
7.4.330.0110.00218.35
7.4.320.0110.00718.45
7.4.300.0100.00417.51
7.4.290.0110.00617.50
7.4.280.0150.00417.63
7.4.270.0160.00417.33
7.4.260.0120.00517.06
7.4.250.0150.00417.41
7.4.240.0150.00317.36
7.4.230.0130.00617.51
7.4.220.0130.00417.42
7.4.210.0120.00417.51
7.4.200.0110.00517.31
7.4.190.0140.00417.38
7.4.180.0120.00517.44
7.4.160.0110.00517.33
7.4.150.0100.00717.29
7.4.140.0100.00717.22
7.4.130.0120.00417.12
7.4.120.0090.00717.15
7.4.110.0090.00617.31
7.4.100.0100.00517.26
7.4.90.0110.00517.09
7.4.80.0110.00617.15
7.4.70.0120.00417.14
7.4.60.0090.00617.30
7.4.50.0090.00517.11
7.4.40.0090.00517.07
7.4.30.0070.00717.12
7.4.20.0080.00617.31
7.4.10.0090.00517.28
7.4.00.0090.00417.32
7.3.330.0120.00517.16
7.3.320.0130.00416.85
7.3.310.0140.00417.32
7.3.300.0150.00317.36
7.3.290.0120.00517.37
7.3.280.0130.00617.30
7.3.270.0130.00417.12
7.3.260.0120.00617.07
7.3.250.0140.00417.14
7.3.240.0150.00417.06
7.3.230.0130.00517.07
7.3.220.0130.00517.00
7.3.210.0130.00517.03
7.3.200.0130.00517.02
7.3.190.0120.00517.00
7.3.180.0140.00317.21
7.3.170.0120.00517.05
7.3.160.0110.00517.00
7.3.150.0120.00417.19
7.3.140.0110.00517.00
7.3.130.0120.00517.03
7.3.120.0120.00617.01
7.3.110.0120.00517.01
7.3.100.0110.00517.00
7.3.90.0120.00617.27
7.3.80.0140.00417.02
7.3.70.0100.00817.09
7.3.60.0130.00417.30
7.3.50.0130.00417.34
7.3.40.0130.00517.13
7.3.30.0120.00617.12
7.3.20.0130.00517.99
7.3.10.0130.00617.95
7.3.00.0140.00517.98

preferences:
52.61 ms | 403 KiB | 5 Q