3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Admin { private const STATUS_ACTIVE = 'active'; private const STATUS_INACTIVE = 'inactive'; // Ajout d'un tableau de roles pour affiner les droits des administrateurs :) public function __construct(public string $username, private array $roles = [], private 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; } // 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éfini le role ADMIN par défaut. public function getRoles(): array { $roles = $this->roles; $roles[] = 'ADMIN'; return $roles; } public function setRoles(array $roles): void { $this->roles = $roles; } } $a = new Admin('Bobby'); var_dump($a);

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.0050.00517.68
8.3.140.0060.00316.54
8.3.130.0060.00316.76
8.3.120.0140.00719.34
8.3.110.0110.00420.94
8.3.100.0060.00324.06
8.3.90.0060.00326.77
8.3.80.0180.00926.70
8.3.70.0070.00716.58
8.3.60.0070.01416.75
8.3.50.0110.00716.49
8.3.40.0000.01518.68
8.3.30.0090.00618.59
8.3.20.0000.00724.18
8.3.10.0060.00324.66
8.3.00.0100.00720.95
8.2.260.0080.00016.61
8.2.250.0050.00318.23
8.2.240.0060.00916.73
8.2.230.0060.00322.58
8.2.220.0090.00037.54
8.2.210.0070.00726.77
8.2.200.0030.00618.31
8.2.190.0040.01916.75
8.2.180.0070.01425.92
8.2.170.0110.00718.91
8.2.160.0110.00422.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0050.00226.16
8.2.120.0040.00421.11
8.2.110.0030.00620.52
8.2.100.0000.01117.78
8.2.90.0160.00318.55
8.2.80.0140.00817.66
8.2.70.0100.00742.19
8.2.60.0170.00617.53
8.2.50.0120.00317.85
8.2.40.0150.00618.44
8.2.30.0160.00618.16
8.2.20.0120.00518.17
8.2.10.0140.00418.20
8.2.00.0080.00518.34
8.1.310.0080.00016.66
8.1.300.0110.00716.40
8.1.290.0030.00618.88
8.1.280.0070.01025.92
8.1.270.0040.00423.99
8.1.260.0050.00226.35
8.1.250.0000.00828.09
8.1.240.0060.00323.79
8.1.230.0090.00323.86
8.1.220.0160.00517.41
8.1.210.0140.00717.67
8.1.200.0190.00217.24
8.1.190.0200.00216.99
8.1.180.0220.00117.56
8.1.170.0180.00417.75
8.1.160.0130.00617.99
8.1.150.0130.00617.97
8.1.140.0120.00618.27
8.1.130.0120.00517.84
8.1.120.0150.00417.68
8.1.110.0180.00117.74
8.1.100.0130.00617.66
8.1.90.0130.00417.59
8.1.80.0130.00617.58
8.1.70.0110.00417.56
8.1.60.0130.00617.75
8.1.50.0100.00617.62
8.1.40.0130.00617.69
8.1.30.0140.00517.96
8.1.20.0120.00617.84
8.1.10.0140.00417.79
8.1.00.0130.00417.66
8.0.300.0160.00717.82
8.0.290.0170.00516.60
8.0.280.0110.00617.92
8.0.270.0110.00617.54
8.0.260.0150.00317.56
8.0.250.0150.00417.33
8.0.240.0170.00417.25
8.0.230.0150.00417.18
8.0.220.0150.00417.16
8.0.210.0140.00417.12
8.0.200.0140.00417.17
8.0.190.0130.00617.13
8.0.180.0130.00517.08
8.0.170.0130.00517.02
8.0.160.0100.00717.06
8.0.150.0130.00416.99
8.0.140.0140.00416.97
8.0.130.0120.00516.67
8.0.120.0100.00616.95
8.0.110.0090.00516.95
8.0.100.0090.00616.92
8.0.90.0120.00416.92
8.0.80.0100.00516.95
8.0.70.0100.00516.91
8.0.60.0110.00416.96
8.0.50.0090.00416.93
8.0.30.0090.00616.91
8.0.20.0080.00617.07
8.0.10.0090.00517.05
8.0.00.0080.00617.07
7.4.330.0090.00416.42
7.4.320.0180.00216.98
7.4.300.0150.00216.83
7.4.290.0140.00316.70
7.4.280.0110.00416.65
7.4.270.0110.00616.61
7.4.260.0120.00516.38
7.4.250.0110.00416.61
7.4.240.0100.00416.53
7.4.230.0110.00416.57
7.4.220.0080.00616.59
7.4.210.0100.00416.56
7.4.200.0090.00516.55
7.4.190.0100.00516.61
7.4.180.0110.00316.62
7.4.160.0090.00516.58
7.4.150.0100.00416.50
7.4.140.0100.00516.47
7.4.130.0100.00516.43
7.4.120.0090.00516.43
7.4.110.0100.00516.42
7.4.100.0090.00516.51
7.4.90.0110.00416.43
7.4.80.0100.00416.42
7.4.70.0080.00516.42
7.4.60.0100.00416.39
7.4.50.0090.00516.36
7.4.40.0080.00616.36
7.4.30.0090.00416.39
7.4.20.0090.00516.42
7.4.10.0090.00516.43
7.4.00.0080.00516.43
7.3.330.0130.00516.39
7.3.320.0120.00516.17
7.3.310.0120.00416.41
7.3.300.0110.00416.35
7.3.290.0090.00616.37
7.3.280.0110.00416.33
7.3.270.0110.00416.35
7.3.260.0120.00516.38
7.3.250.0120.00416.33
7.3.240.0120.00416.36
7.3.230.0110.00516.38
7.3.220.0090.00616.26
7.3.210.0110.00516.28
7.3.200.0110.00416.31
7.3.190.0110.00516.33
7.3.180.0120.00416.28
7.3.170.0100.00616.28
7.3.160.0110.00416.32
7.3.150.0100.00516.29
7.3.140.0110.00416.28
7.3.130.0120.00416.26
7.3.120.0100.00516.28
7.3.110.0100.00516.26
7.3.100.0100.00516.25
7.3.90.0100.00516.51
7.3.80.0100.00516.31
7.3.70.0110.00416.35
7.3.60.0110.00416.41
7.3.50.0110.00416.40
7.3.40.0110.00416.39
7.3.30.0120.00316.35
7.3.20.0110.00517.21
7.3.10.0120.00417.17
7.3.00.0120.00417.16

preferences:
26.89 ms | 403 KiB | 5 Q