Improved PHPDoc, Type Hints & Parameter Names
This commit is contained in:
@ -197,15 +197,18 @@ class AuthenticationManager implements CallbackListener {
|
||||
/**
|
||||
* Get a List of all Admins
|
||||
*
|
||||
* @param $authLevel
|
||||
* @param int $authLevel
|
||||
* @return array null
|
||||
*/
|
||||
public function getAdmins($authLevel = -1) {
|
||||
public function getAdmins($authLevel = null) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
if ($authLevel < 0) {
|
||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` > 0 ORDER BY `authLevel` DESC;";
|
||||
if ($authLevel === null) {
|
||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "`
|
||||
WHERE `authLevel` > 0
|
||||
ORDER BY `authLevel` DESC;";
|
||||
} else {
|
||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` = " . $authLevel . ";";
|
||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "`
|
||||
WHERE `authLevel` = {$authLevel};";
|
||||
}
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
@ -289,7 +292,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Player has enough Rights
|
||||
* Check whether the Player has enough Rights
|
||||
*
|
||||
* @param Player $player
|
||||
* @param int|Setting $neededAuthLevel
|
||||
@ -303,10 +306,10 @@ class AuthenticationManager implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a Minimum Right Level needed for an action
|
||||
* Define a Minimum Right Level needed for an Action
|
||||
*
|
||||
* @param $rightName
|
||||
* @param $authLevelNeeded
|
||||
* @param string $rightName
|
||||
* @param int $authLevelNeeded
|
||||
*/
|
||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||
$this->maniaControl->settingManager->initSetting($this, $rightName, $authLevelNeeded);
|
||||
|
@ -64,22 +64,15 @@ class BillManager implements CallbackListener {
|
||||
/**
|
||||
* Send Planets from the server to a Player
|
||||
*
|
||||
* @param $function
|
||||
* @param $receiverLogin
|
||||
* @param $amount
|
||||
* @param $message
|
||||
* @param callable $function
|
||||
* @param string $receiverLogin
|
||||
* @param int $amount
|
||||
* @param string $message
|
||||
* @return bool
|
||||
*/
|
||||
public function sendPlanets($function, $receiverLogin, $amount, $message) {
|
||||
if (!is_callable($function)) {
|
||||
trigger_error("Function is not callable");
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sendPlanets(callable $function, $receiverLogin, $amount, $message) {
|
||||
$bill = $this->maniaControl->client->pay($receiverLogin, $amount, $message);
|
||||
|
||||
$this->openBills[$bill] = new BillData($function, $receiverLogin, $amount, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -124,12 +124,12 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the commands for the HelpAll ManiaLink.
|
||||
* Prepare the commands for the HelpAll ManiaLink.
|
||||
*
|
||||
* @param $commands
|
||||
* @param $player
|
||||
* @param array $commands
|
||||
* @param mixed $player
|
||||
*/
|
||||
private function prepareHelpAll($commands, $player) {
|
||||
private function prepareHelpAll(array $commands, $player) {
|
||||
$showCommands = array();
|
||||
$registeredMethods = array();
|
||||
foreach (array_reverse($commands) as $command) {
|
||||
@ -157,10 +157,10 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
/**
|
||||
* Shows the HelpAll list to the player.
|
||||
*
|
||||
* @param $commands
|
||||
* @param $player
|
||||
* @param array $commands
|
||||
* @param mixed $player
|
||||
*/
|
||||
private function showHelpAllList($commands, $player) {
|
||||
private function showHelpAllList(array $commands, $player) {
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||
|
||||
|
@ -340,14 +340,14 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
/**
|
||||
* Gets the Menu Id
|
||||
*
|
||||
* @param $name
|
||||
* @param string $title
|
||||
* @return int
|
||||
*/
|
||||
public function getMenuId($name) {
|
||||
public function getMenuId($title) {
|
||||
$i = 0;
|
||||
foreach ($this->menus as $menu) {
|
||||
/** @var ConfiguratorMenu $menu */
|
||||
if ($menu == $name || $menu->getTitle() == $name) {
|
||||
if ($menu === $title || $menu->getTitle() === $title) {
|
||||
return $i;
|
||||
}
|
||||
$i++;
|
||||
|
@ -164,11 +164,9 @@ class ManiaControl implements CommandListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks connection every xxx Minutes
|
||||
*
|
||||
* @param $time
|
||||
* Check Connection
|
||||
*/
|
||||
public function checkConnection($time) {
|
||||
public function checkConnection() {
|
||||
if ($this->client->getIdleTime() > 180) {
|
||||
$this->client->getServerName();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class ManiaExchangeManager {
|
||||
/**
|
||||
* Unset Map by Mx Id
|
||||
*
|
||||
* @param $mxId
|
||||
* @param int $mxId
|
||||
*/
|
||||
public function unsetMap($mxId) {
|
||||
if (isset($this->mxIdUidVector[$mxId])) {
|
||||
@ -142,7 +142,7 @@ class ManiaExchangeManager {
|
||||
/**
|
||||
* Get the Whole MapList from MX by Mixed Uid and Id String fetch
|
||||
*
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* @return array|null
|
||||
*/
|
||||
public function getMaplistByMixedUidIdString($string) {
|
||||
@ -187,11 +187,11 @@ class ManiaExchangeManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Map Info from MX and store the mxid in the database and the mx info in the map object
|
||||
* Store MX Map Info in the Database and the MX Info in the Map Object
|
||||
*
|
||||
* @param $mxMapInfos
|
||||
* @param array $mxMapInfos
|
||||
*/
|
||||
public function updateMapObjectsWithManiaExchangeIds($mxMapInfos) {
|
||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
// Save map data
|
||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||
@ -231,11 +231,11 @@ class ManiaExchangeManager {
|
||||
/**
|
||||
* Get Map Info Asynchronously
|
||||
*
|
||||
* @param $id
|
||||
* @param $function
|
||||
* @param int $id
|
||||
* @param callable $function
|
||||
* @return bool
|
||||
*/
|
||||
public function getMapInfo($id, $function) {
|
||||
public function getMapInfo($id, callable $function) {
|
||||
// Get Title Prefix
|
||||
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
||||
|
||||
@ -344,9 +344,9 @@ class ManiaExchangeManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Current Environment by String
|
||||
* Get the Current Environment by String
|
||||
*
|
||||
* @param $env
|
||||
* @param string $env
|
||||
* @return int
|
||||
*/
|
||||
private function getEnvironment($env) {
|
||||
|
@ -52,11 +52,9 @@ class CustomUIManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle 1Second
|
||||
*
|
||||
* @param $time
|
||||
* Handle 1 Second Callback
|
||||
*/
|
||||
public function handle1Second($time) {
|
||||
public function handle1Second() {
|
||||
if (!$this->updateManialink) {
|
||||
return;
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ class IconManager implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an Icon by its name
|
||||
* Get an Icon by its Name
|
||||
*
|
||||
* @param $iconName
|
||||
* @param string $iconName
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon($iconName) {
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace ManiaControl\Maps;
|
||||
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
|
||||
/**
|
||||
* Map Model Class
|
||||
|
@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Maps;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
||||
|
||||
/**
|
||||
* Map Actions Class
|
||||
*
|
||||
@ -6,12 +12,6 @@
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
namespace ManiaControl\Maps;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
||||
|
||||
class MapActions {
|
||||
/*
|
||||
* Private Properties
|
||||
|
@ -359,10 +359,10 @@ class MapManager implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns map By UID
|
||||
* Get Map by UID
|
||||
*
|
||||
* @param $uid
|
||||
* @return Map array
|
||||
* @param string $uid
|
||||
* @return Map
|
||||
*/
|
||||
public function getMapByUid($uid) {
|
||||
if (!isset($this->maps[$uid])) {
|
||||
@ -417,7 +417,7 @@ class MapManager implements CallbackListener {
|
||||
/**
|
||||
* Initializes a Map
|
||||
*
|
||||
* @param $rpcMap
|
||||
* @param mixed $rpcMap
|
||||
* @return Map
|
||||
*/
|
||||
public function initializeMap($rpcMap) {
|
||||
|
@ -7,9 +7,9 @@ use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
|
||||
|
||||
/**
|
||||
@ -45,13 +45,6 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
private $buffer = array();
|
||||
private $nextNoQueue = false;
|
||||
|
||||
/**
|
||||
* Don't queue on the next MapChange
|
||||
*/
|
||||
public function dontQueueNextMapChange() {
|
||||
$this->nextNoQueue = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new server MapQueue
|
||||
*
|
||||
@ -80,6 +73,13 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$this->maniaControl->commandManager->registerCommandListener(array('jb', 'jukebox', 'mapqueue'), $this, 'command_MapQueue', false, 'Shows current maps in Map-Queue.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't queue on the next MapChange
|
||||
*/
|
||||
public function dontQueueNextMapChange() {
|
||||
$this->nextNoQueue = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds current map to buffer on startup
|
||||
*/
|
||||
@ -201,7 +201,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
* Adds map as first map in queue (for /replay)
|
||||
*
|
||||
* @param Player $player
|
||||
* @param Map $map
|
||||
* @param Map $map
|
||||
*/
|
||||
public function addFirstMapToMapQueue(Player $player, Map $map) {
|
||||
if ($map) {
|
||||
@ -303,7 +303,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
*/
|
||||
public function endMap(Map $map = null) {
|
||||
//Don't queue next map (for example on skip to map)
|
||||
if($this->nextNoQueue){
|
||||
if ($this->nextNoQueue) {
|
||||
$this->nextNoQueue = false;
|
||||
return;
|
||||
}
|
||||
@ -316,7 +316,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$player = $queuedMap[0];
|
||||
|
||||
// Check if map is added via replay vote/command
|
||||
if(isset($queuedMap[2]) && $queuedMap[2] === true) {
|
||||
if (isset($queuedMap[2]) && $queuedMap[2] === true) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -352,9 +352,9 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
/** @var Map $map */
|
||||
$this->maniaControl->chat->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
||||
|
||||
try{
|
||||
try {
|
||||
$this->maniaControl->client->setNextMapIdent($map->uid);
|
||||
}catch (NextMapException $e){
|
||||
} catch (NextMapException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,9 +415,9 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Queuer of a Map
|
||||
* Return the Queuer of a Map
|
||||
*
|
||||
* @param $uid
|
||||
* @param string $uid
|
||||
* @return mixed
|
||||
*/
|
||||
public function getQueuer($uid) {
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace ManiaControl\Players;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Utils\ClassUtil;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Player Model Class
|
||||
@ -80,6 +80,19 @@ class Player {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Login of the Player
|
||||
*
|
||||
* @param mixed $player
|
||||
* @return string
|
||||
*/
|
||||
public static function parseLogin($player) {
|
||||
if (is_object($player) && property_exists($player, 'login')) {
|
||||
return (string)$player->login;
|
||||
}
|
||||
return (string)$player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Escaped Nickname
|
||||
*
|
||||
@ -263,7 +276,7 @@ class Player {
|
||||
/**
|
||||
* Set the Cache Data for the given Name
|
||||
*
|
||||
* @param $object
|
||||
* @param mixed $object
|
||||
* @param string $cacheName
|
||||
* @param mixed $data
|
||||
*/
|
||||
@ -273,10 +286,10 @@ class Player {
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a Cache
|
||||
* Destroy a Cache
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param $cacheName
|
||||
* @param mixed $object
|
||||
* @param string $cacheName
|
||||
*/
|
||||
public function destroyCache($object, $cacheName) {
|
||||
$className = ClassUtil::getClass($object);
|
||||
@ -290,14 +303,13 @@ class Player {
|
||||
$this->cache = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the Player Data
|
||||
*
|
||||
* @param $object
|
||||
* @param $dataName
|
||||
* @param $serverIndex
|
||||
* @return mixed|null
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param int $serverIndex
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPlayerData($object, $dataName, $serverIndex = -1) {
|
||||
return $this->maniaControl->playerManager->playerDataManager->getPlayerData($object, $dataName, $this, $serverIndex);
|
||||
@ -306,10 +318,10 @@ class Player {
|
||||
/**
|
||||
* Sets the Player Data
|
||||
*
|
||||
* @param $object
|
||||
* @param $dataName
|
||||
* @param $value
|
||||
* @param $serverIndex
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param mixed $value
|
||||
* @param int $serverIndex
|
||||
* @return bool
|
||||
*/
|
||||
public function setPlayerData($object, $dataName, $value, $serverIndex = -1) {
|
||||
@ -324,7 +336,7 @@ class Player {
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the Players Cache
|
||||
* Var_Dump the Players Cache
|
||||
*/
|
||||
public function dumpCache() {
|
||||
var_dump($this->cache);
|
||||
|
@ -129,10 +129,10 @@ class PlayerDataManager {
|
||||
/**
|
||||
* Defines the Player-Data MetaData
|
||||
*
|
||||
* @param $object
|
||||
* @param $dataName
|
||||
* @param $default
|
||||
* @param $dataDescription (optional)
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param mixed $default
|
||||
* @param string $dataDescription (optional)
|
||||
* @return bool
|
||||
*/
|
||||
public function defineMetaData($object, $dataName, $default, $dataDescription = '') {
|
||||
@ -198,11 +198,11 @@ class PlayerDataManager {
|
||||
/**
|
||||
* Gets the Player Data
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param Player $player
|
||||
* @param int $serverIndex
|
||||
* @return mixed|null
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param Player $player
|
||||
* @param int $serverIndex
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPlayerData($object, $dataName, Player $player, $serverIndex = -1) {
|
||||
$className = ClassUtil::getClass($object);
|
||||
@ -254,11 +254,11 @@ class PlayerDataManager {
|
||||
/**
|
||||
* Set a PlayerData to a specific defined statMetaData
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param Player $player
|
||||
* @param mixed $value
|
||||
* @param int $serverIndex (let it empty if its global)
|
||||
* @param mixed $object
|
||||
* @param string $dataName
|
||||
* @param Player $player
|
||||
* @param mixed $value
|
||||
* @param int $serverIndex (empty if it's global)
|
||||
* @return bool
|
||||
*/
|
||||
public function setPlayerData($object, $dataName, Player $player, $value, $serverIndex = -1) {
|
||||
|
@ -19,8 +19,8 @@ class PluginManager {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const TABLE_PLUGINS = 'mc_plugins';
|
||||
const CB_PLUGIN_LOADED = 'PluginManager.PluginLoaded';
|
||||
const TABLE_PLUGINS = 'mc_plugins';
|
||||
const CB_PLUGIN_LOADED = 'PluginManager.PluginLoaded';
|
||||
const CB_PLUGIN_UNLOADED = 'PluginManager.PluginUnloaded';
|
||||
|
||||
/*
|
||||
@ -400,9 +400,9 @@ class PluginManager {
|
||||
/**
|
||||
* Fetch the Plugins List from the ManiaControl Website
|
||||
*
|
||||
* @param $function
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchPluginList($function) {
|
||||
public function fetchPluginList(callable $function) {
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||
|
@ -71,7 +71,7 @@ class RankingManager implements CallbackListener {
|
||||
/**
|
||||
* Update Game Rankings (never call this Method)
|
||||
*
|
||||
* @param $data
|
||||
* @param string $data
|
||||
*/
|
||||
public function updateRankings($data) {
|
||||
if (!is_string($data)) {
|
||||
|
@ -4,8 +4,9 @@ namespace ManiaControl\Server;
|
||||
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Utils\CommandLineHelper;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Utils\CommandLineHelper;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
@ -260,10 +261,11 @@ class Server implements CallbackListener {
|
||||
/**
|
||||
* Retrieve Validation Replay for the given Player
|
||||
*
|
||||
* @param $login
|
||||
* @param string $login
|
||||
* @return string
|
||||
*/
|
||||
public function getValidationReplay($login) {
|
||||
$login = Player::parseLogin($login);
|
||||
try {
|
||||
$replay = $this->maniaControl->client->getValidationReplay($login);
|
||||
} catch (Exception $e) {
|
||||
@ -279,7 +281,7 @@ class Server implements CallbackListener {
|
||||
/**
|
||||
* Retrieve Ghost Replay for the given Player
|
||||
*
|
||||
* @param $login
|
||||
* @param string $login
|
||||
* @return string
|
||||
*/
|
||||
public function getGhostReplay($login) {
|
||||
@ -289,6 +291,7 @@ class Server implements CallbackListener {
|
||||
}
|
||||
|
||||
// Build file name
|
||||
$login = Player::parseLogin($login);
|
||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||
$gameMode = $this->getGameMode();
|
||||
$time = time();
|
||||
|
@ -210,12 +210,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
}
|
||||
|
||||
/**
|
||||
* Check stuff each 5 seconds
|
||||
*
|
||||
* @param $timer
|
||||
* @return bool
|
||||
* Check Stuff each 5 Seconds
|
||||
*/
|
||||
public function each5Seconds($timer) {
|
||||
public function each5Seconds() {
|
||||
// Empty shutdown
|
||||
if ($this->serverShutdownEmpty) {
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
|
@ -313,7 +313,7 @@ class StatisticManager {
|
||||
/**
|
||||
* Return the Stat Id
|
||||
*
|
||||
* @param $statName
|
||||
* @param string $statName
|
||||
* @return int
|
||||
*/
|
||||
private function getStatId($statName) {
|
||||
|
Reference in New Issue
Block a user