3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class User { public const STATUS_ACTIVE = 'active'; public const STATUS_INACTIVE = 'inactive'; public function __construct(public string $username, public string $status = self::STATUS_ACTIVE) { } public function setStatus(string $status): void { assert( in_array($status, [self::STATUS_ACTIVE, self::STATUS_INACTIVE]), sprintf('Le status %s n\'est pas valide. Les status possibles sont : %s', $status, implode(‘, ‘, [self::STATUS_ACTIVE, self::STATUS_INACTIVE])) ); $this->status = $status; } public function getStatus(): string { return $this->status; } } class Admin extends User { // Ajout d'un tableau de roles pour affiner les droits des administrateurs :) public function __construct(public string $username, public array $roles = [], public string $status = self::STATUS_ACTIVE) { } // Méthode d'ajout d'un rôle, puis on supprime les doublons avec array_filter. public function addRole(string $role): void { $this->roles[] = $role; $this->roles = array_filter($this->roles); } // Méthode de renvoie des rôles, dans lequel on définit le rôle ADMIN par défaut. public function getRoles(): array { $roles = $this->roles; $roles[] = 'ADMIN'; return $roles; } public function setRoles(array $roles): void { $this->roles = $roles; } }

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.140.0080.00018.34
8.3.130.0080.00818.18
8.3.120.0130.01018.45
8.3.110.0150.00318.54
8.3.100.0180.00630.79
8.3.90.0130.00721.65
8.3.80.0100.00616.53
8.3.70.0200.00517.35
8.3.60.0190.01116.38
8.3.50.0260.00616.34
8.3.40.0190.00918.47
8.3.30.0220.01217.72
8.3.20.0180.00721.60
8.3.10.0190.00521.70
8.3.00.0130.00721.72
8.2.250.0000.00918.09
8.2.240.0180.00616.82
8.2.230.0210.00319.55
8.2.220.0160.00727.00
8.2.210.0240.00321.43
8.2.200.0200.00416.45
8.2.190.0210.01116.32
8.2.180.0210.00721.25
8.2.170.0240.01219.46
8.2.160.0280.00319.13
8.2.150.0220.00621.27
8.2.140.0200.00721.37
8.2.130.0190.00621.71
8.2.120.0170.00920.12
8.2.110.0190.00520.73
8.2.100.0180.00719.80
8.2.90.0150.00919.55
8.2.80.0160.00819.61
8.2.70.0130.00755.35
8.2.60.0150.00728.00
8.2.50.0110.00725.82
8.2.40.0120.00526.08
8.2.30.0110.00626.27
8.2.20.0120.00526.11
8.2.10.0140.00628.22
8.2.00.0100.00624.38
8.1.300.0270.00216.21
8.1.290.0130.01117.48
8.1.280.0230.00520.80
8.1.270.0190.00621.61
8.1.260.0160.00722.05
8.1.250.0130.00722.42
8.1.240.0170.01019.60
8.1.230.0150.00819.85
8.1.220.0150.00819.46
8.1.210.0170.00719.77
8.1.200.0150.00727.82
8.1.190.0140.00827.80
8.1.180.0150.00525.72
8.1.170.0160.00628.08
8.1.160.0140.00828.12
8.1.150.0140.00727.01
8.1.140.0140.00828.04
8.1.130.0110.00826.95
8.1.120.0150.00626.61
8.1.110.0130.00624.01
8.1.100.0170.00424.67
8.1.90.0100.00723.05
8.1.80.0110.00622.67
8.1.70.0110.00723.48
8.1.60.0170.00523.57
8.1.50.0120.00621.98
8.1.40.0120.00722.69
8.1.30.0140.00522.38
8.1.20.0110.00621.89
8.1.10.0130.00722.25
8.1.00.0140.00621.66
8.0.300.0120.00619.67
8.0.290.0140.00627.11
8.0.280.0140.00425.60
8.0.270.0170.00427.49
8.0.260.0150.00626.10
8.0.250.0140.00725.94
8.0.240.0170.00624.86
8.0.230.0130.00824.06
8.0.220.0110.00723.37
8.0.210.0120.00722.76
8.0.200.0140.00522.85
8.0.190.0120.00722.85
8.0.180.0130.00523.00
8.0.170.0150.00522.87
8.0.160.0130.00622.50
8.0.150.0140.00621.59
8.0.140.0150.00422.30
8.0.130.0150.00421.33
8.0.120.0150.00422.34
8.0.110.0120.00622.49
8.0.100.0110.00621.55
8.0.90.0100.00520.57
8.0.80.0110.00521.60
8.0.70.0120.00421.72
8.0.60.0100.00621.59
8.0.50.0110.00621.59
8.0.30.0090.00621.15
8.0.20.0090.00621.48
8.0.10.0110.00520.88
8.0.00.0110.00521.70
7.4.330.0130.00423.03
7.4.320.0190.00324.52
7.4.300.0140.00522.47
7.4.290.0170.00422.49
7.4.280.0150.00622.00
7.4.270.0110.00721.30
7.4.260.0120.00621.73
7.4.250.0160.00322.01
7.4.240.0120.00421.28
7.4.230.0110.00721.22
7.4.220.0120.00521.28
7.4.210.0130.00321.30
7.4.200.0110.00621.27
7.4.190.0130.00421.29
7.4.180.0100.00721.28
7.4.160.0120.00520.96
7.4.150.0120.00620.97
7.4.140.0120.00520.91
7.4.130.0100.00720.83
7.4.120.0130.00420.86
7.4.110.0120.00620.81
7.4.100.0120.00520.90
7.4.90.0130.00520.83
7.4.80.0130.00520.81
7.4.70.0130.00620.75
7.4.60.0130.00520.78
7.4.50.0110.00620.71
7.4.40.0120.00720.75
7.4.30.0130.00520.83
7.4.20.0130.00520.82
7.4.10.0120.00620.84
7.4.00.0110.00520.31
7.3.330.0140.00421.79
7.3.320.0150.00621.57
7.3.310.0190.00421.83
7.3.300.0160.00421.08
7.3.290.0160.00421.04
7.3.280.0130.00520.70
7.3.270.0140.00620.77
7.3.260.0140.00620.75
7.3.250.0120.00720.77
7.3.240.0130.00620.73
7.3.230.0150.00520.74
7.3.220.0130.00620.69
7.3.210.0140.00520.71
7.3.200.0140.00420.68
7.3.190.0130.00620.71
7.3.180.0160.00520.68
7.3.170.0150.00420.73
7.3.160.0140.00620.66
7.3.150.0140.00620.69
7.3.140.0120.00720.70
7.3.130.0160.00420.66
7.3.120.0130.00520.70
7.3.110.0120.00620.66
7.3.100.0140.00520.67
7.3.90.0120.00620.95
7.3.80.0140.00420.71
7.3.70.0150.00520.74
7.3.60.0130.00520.81
7.3.50.0130.00520.80
7.3.40.0110.00720.73
7.3.30.0130.00620.81
7.3.20.0160.00421.83
7.3.10.0140.00521.81
7.3.00.0130.00521.84

preferences:
45.13 ms | 403 KiB | 5 Q