3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace ProjectInfinity\ReportRTS\command\sub; use pocketmine\command\CommandSender; use pocketmine\IPlayer; use ProjectInfinity\ReportRTS\ReportRTS; use ProjectInfinity\ReportRTS\util\MessageHandler; use ProjectInfinity\ReportRTS\util\PermissionHandler; use ProjectInfinity\ReportRTS\util\ToolBox; class AssignTicket { private $plugin; private $data; public function __construct(ReportRTS $plugin) { $this->plugin = $plugin; $this->data = $plugin->getDataProvider(); } public function handleCommand(CommandSender $sender, $args) { if(!$sender->hasPermission(PermissionHandler::canAssign)) { $sender->sendMessage(sprintf(MessageHandler::$permissionError, PermissionHandler::canAssign)); return true; } if(count($args) < 3) { $sender->sendMessage(sprintf(MessageHandler::$generalError, "You need to specify a ticket ID then a player.")); return true; } if(!ToolBox::isNumber($args[1])) { $sender->sendMessage(sprintf(MessageHandler::$generalError, "Ticket ID must be a number. Provided: ".$args[1])); return true; } $ticketId = intval($args[1]); if(!isset(ReportRTS::$tickets[$ticketId]) or ReportRTS::$tickets[$ticketId]->getStatus() == 1) { # The ticket that the user is trying to claim is not in the array or is already claimed (not open). $sender->sendMessage(MessageHandler::$ticketNotOpen); return true; } $user = $this->data->getUser($args[2]); if($user['id'] == 0) { # Try to get the player from files. $player = $this->plugin->getServer()->getOfflinePlayer($args[2]); if($player->getFirstPlayed() === null) { $sender->sendMessage(sprintf(MessageHandler::$userNotExists, $player->getName())); return true; } # Create the user since it does not exist but is online. $this->data->createUser($player->getName()); $user = $this->data->getUser($player->getName()); } $ticket = ReportRTS::$tickets[$args[1]]; $timestamp = round(microtime(true)); if($resultCode = $this->data->setTicketStatus($ticketId, $user['username'], 1, null, 0, $timestamp) and $resultCode != 1) { if($resultCode == -1) { # Username is invalid or does not exist. $sender->sendMessage(sprintf(MessageHandler::$userNotExists, $user['username'])); return true; } if($resultCode == -2) { # Ticket status incompatibilities. $sender->sendMessage(MessageHandler::$ticketStatusError); return true; } $sender->sendMessage(sprintf(MessageHandler::$generalError, "Unable to assign ticket #".$ticketId." to ".$args[2])); return true; } # Set ticket info in the ticket array too. $ticket->setStatus(1); $ticket->setStaffName($user['username']); $ticket->setStaffId($user['id']); $ticket->setStaffTimestamp($timestamp); ReportRTS::$tickets[$args[1]] = $ticket; $player = $this->plugin->getServer()->getPlayer($ticket->getName()); if($player != null) { $player->sendMessage(MessageHandler::$ticketAssignUser, $user['username']); $player->sendMessage(MessageHandler::$ticketClaimText, $ticket->getMessage()); } # Let staff know about this change. $this->plugin->messageStaff(sprintf(MessageHandler::$ticketAssign, $user['username'], $ticketId)); return true; } }

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.0.110.0000.00716.73
8.0.100.0070.00016.79
8.0.90.0020.00516.84
8.0.80.0060.00916.89
8.0.70.0040.00416.84
8.0.60.0000.00716.79
8.0.50.0050.00316.67
8.0.30.0080.01117.01
8.0.20.0100.00917.40
8.0.10.0050.00316.81
8.0.00.0050.01416.66
7.4.240.0030.00316.54
7.4.230.0030.00316.62
7.4.220.0030.01616.53
7.4.210.0040.01116.54
7.4.200.0050.00216.46
7.4.160.0100.01316.54
7.4.150.0160.00317.40
7.4.140.0120.00617.86
7.4.130.0110.00816.45
7.4.120.0100.00716.34
7.4.110.0110.00616.65
7.4.100.0080.00816.26
7.4.90.0070.01116.42
7.4.80.0130.01019.39
7.4.70.0090.00816.50
7.4.60.0060.01516.64
7.4.50.0000.00516.60
7.4.40.0090.01316.41
7.4.30.0100.00716.48
7.4.00.0100.00715.09
7.3.300.0000.00616.27
7.3.290.0070.01316.30
7.3.280.0080.00816.35
7.3.270.0140.00617.40
7.3.260.0080.00816.44
7.3.250.0120.00616.53
7.3.240.0090.01316.38
7.3.230.0120.00616.45
7.3.210.0120.00616.38
7.3.200.0130.00319.39
7.3.190.0130.01016.39
7.3.180.0160.00016.53
7.3.170.0070.01016.61
7.3.160.0070.01016.46
7.3.10.0110.00415.92
7.3.00.0070.00716.29
7.2.330.0060.01316.69
7.2.320.0120.00616.70
7.2.310.0080.00816.40
7.2.300.0060.01016.39
7.2.290.0100.00716.59
7.2.130.0100.00716.66
7.2.120.0090.00615.93
7.2.110.0070.01016.44
7.2.100.0070.00716.46
7.2.90.0090.00916.52
7.2.80.0080.00816.34
7.2.70.0000.01016.45
7.2.60.0040.00916.60
7.2.50.0030.00716.50
7.2.40.0080.00516.37
7.2.30.0150.00016.45
7.2.20.0070.00716.23
7.2.10.0140.00316.65
7.2.00.0080.00617.77
7.1.250.0040.01115.05
7.1.200.0000.01515.51
7.1.100.0070.00717.98
7.1.70.0000.00916.83
7.1.60.0070.01719.32
7.1.50.0040.01416.89
7.1.00.0030.07322.45
7.0.200.0040.00416.64
7.0.140.0030.06722.09
7.0.60.0130.08020.07
7.0.50.0100.05017.96
7.0.40.0000.06019.96
7.0.30.0400.08020.23
7.0.20.0400.06020.04
7.0.10.0070.04320.18
7.0.00.0200.07020.06
5.6.280.0000.07721.16
5.6.210.0070.06320.77
5.6.200.0100.07718.19
5.6.190.0070.04320.40
5.6.180.0270.06320.61
5.6.170.0230.05320.45
5.6.160.0100.07720.46
5.6.150.0030.06318.30
5.6.140.0030.05018.31
5.6.130.0030.08018.19
5.6.120.0000.04721.10
5.6.110.0130.08021.03
5.6.100.0170.06721.18
5.6.90.0070.08021.07
5.6.80.0070.08320.45
5.6.70.0470.06320.37
5.5.350.0170.06020.51
5.5.340.0030.04318.11
5.5.330.0070.05320.21
5.5.320.0030.04720.31
5.5.310.0330.07320.44
5.5.300.0130.07718.05
5.5.290.0200.06718.02
5.5.280.0170.07720.89
5.5.270.0100.08020.84
5.5.260.0030.04320.99
5.5.250.0130.07320.59
5.5.240.0170.07020.27
5.4.450.0070.05019.55
5.4.440.0330.04319.16
5.4.430.0530.03719.19
5.4.420.0670.00019.51
5.4.410.0630.00019.21
5.4.400.0630.00019.12
5.4.390.0700.00019.13
5.4.380.0630.00019.16
5.4.370.0600.00019.21
5.4.360.0630.00019.16
5.4.350.0670.00018.99
5.4.340.0060.03812.05
5.4.320.0070.03912.57
5.4.310.0070.03712.57
5.4.300.0050.04112.57
5.4.290.0050.04012.54
5.4.280.0060.03712.43
5.4.270.0070.03612.43
5.4.260.0050.04512.43
5.4.250.0060.03812.43
5.4.240.0040.03712.43
5.4.230.0110.04012.42
5.4.220.0100.04212.43
5.4.210.0070.03512.43
5.4.200.0040.03912.43
5.4.190.0080.03512.42
5.4.180.0080.03912.43
5.4.170.0120.05512.44
5.4.160.0130.04912.43
5.4.150.0090.03512.43
5.4.140.0050.04012.11
5.4.130.0080.03912.10
5.4.120.0090.03612.06
5.4.110.0050.03812.05
5.4.100.0040.03712.05
5.4.90.0110.03412.05
5.4.80.0100.04012.05
5.4.70.0080.03312.05
5.4.60.0090.03612.05
5.4.50.0070.03612.04
5.4.40.0110.04412.04
5.4.30.0100.04712.03
5.4.20.0120.04512.03
5.4.10.0120.04912.04
5.4.00.0060.03911.52
5.3.290.0090.03912.81
5.3.280.0060.03912.74
5.3.270.0070.04212.75
5.3.260.0060.04312.75
5.3.250.0120.06212.75
5.3.240.0090.04712.75
5.3.230.0060.04012.74
5.3.220.0080.04012.71
5.3.210.0080.03812.71
5.3.200.0110.03312.71
5.3.190.0070.04512.71
5.3.180.0080.03512.71
5.3.170.0060.03712.71
5.3.160.0080.03812.71
5.3.150.0080.04012.71
5.3.140.0070.04012.71
5.3.130.0070.03812.70
5.3.120.0040.04312.69
5.3.110.0030.04312.70
5.3.100.0050.04112.21
5.3.90.0060.03612.17
5.3.80.0080.03912.16
5.3.70.0070.03612.16
5.3.60.0060.04212.15
5.3.50.0070.04012.09
5.3.40.0110.03212.09
5.3.30.0080.04412.05
5.3.20.0060.03511.84
5.3.10.0090.03811.80
5.3.00.0060.03811.78
5.2.170.0050.0369.18
5.2.160.0050.0299.19
5.2.150.0090.0489.19
5.2.140.0070.0289.18
5.2.130.0070.0289.14
5.2.120.0060.0339.14
5.2.110.0060.0289.15
5.2.100.0070.0339.14
5.2.90.0030.0329.15
5.2.80.0070.0319.14
5.2.70.0040.0319.14
5.2.60.0060.0309.09
5.2.50.0040.0319.06
5.2.40.0060.0349.04
5.2.30.0070.0309.02
5.2.20.0080.0289.00
5.2.10.0030.0308.93
5.2.00.0070.0288.78
5.1.60.0060.0238.07
5.1.50.0060.0318.06
5.1.40.0070.0308.05
5.1.30.0050.0268.41
5.1.20.0050.0278.42
5.1.10.0080.0228.14
5.1.00.0050.0288.14
5.0.50.0040.0256.63
5.0.40.0040.0246.48
5.0.30.0060.0366.30
5.0.20.0060.0226.27
5.0.10.0050.0196.24
5.0.00.0060.0346.24
4.4.90.0040.0174.78
4.4.80.0050.0154.75
4.4.70.0030.0174.75
4.4.60.0050.0164.76
4.4.50.0040.0164.77
4.4.40.0040.0294.70
4.4.30.0040.0204.76
4.4.20.0030.0154.84
4.4.10.0010.0174.85
4.4.00.0010.0284.75
4.3.110.0020.0194.67
4.3.100.0040.0174.66
4.3.90.0050.0184.64
4.3.80.0040.0304.59
4.3.70.0050.0174.63
4.3.60.0030.0144.63
4.3.50.0060.0174.63
4.3.40.0060.0304.54
4.3.30.0020.0173.29
4.3.20.0040.0143.26
4.3.10.0050.0153.22
4.3.00.0030.01710.59

preferences:
57.58 ms | 401 KiB | 5 Q