phpdoc improvements

This commit is contained in:
Steffen Schröder 2014-10-24 20:08:21 +02:00
parent 30459811c0
commit 1a8c6ad036
9 changed files with 194 additions and 122 deletions

View File

@ -17,8 +17,10 @@ class Database implements TimerListener {
/* /*
* Public properties * Public properties
*/ */
/** @var \mysqli $mysqli */ /** @var \mysqli $mysqli
/** @deprecated see getMysqli() */ * @deprecated
* @see Database::getMysqli()
*/
public $mysqli = null; public $mysqli = null;
/* /*
@ -76,28 +78,28 @@ class Database implements TimerListener {
if (!$hostElements) { if (!$hostElements) {
$this->maniaControl->quit("Invalid database configuration (Host).", true); $this->maniaControl->quit("Invalid database configuration (Host).", true);
} }
$host = (string)$hostElements[0]; $host = (string) $hostElements[0];
// Port // Port
$portElements = $databaseElement->xpath('port'); $portElements = $databaseElement->xpath('port');
if (!$portElements) { if (!$portElements) {
$this->maniaControl->quit("Invalid database configuration (Port).", true); $this->maniaControl->quit("Invalid database configuration (Port).", true);
} }
$port = (string)$portElements[0]; $port = (string) $portElements[0];
// User // User
$userElements = $databaseElement->xpath('user'); $userElements = $databaseElement->xpath('user');
if (!$userElements) { if (!$userElements) {
$this->maniaControl->quit("Invalid database configuration (User).", true); $this->maniaControl->quit("Invalid database configuration (User).", true);
} }
$user = (string)$userElements[0]; $user = (string) $userElements[0];
// Pass // Pass
$passElements = $databaseElement->xpath('pass'); $passElements = $databaseElement->xpath('pass');
if (!$passElements) { if (!$passElements) {
$this->maniaControl->quit("Invalid database configuration (Pass).", true); $this->maniaControl->quit("Invalid database configuration (Pass).", true);
} }
$pass = (string)$passElements[0]; $pass = (string) $passElements[0];
// Name // Name
$nameElements = $databaseElement->xpath('name'); $nameElements = $databaseElement->xpath('name');
@ -107,7 +109,7 @@ class Database implements TimerListener {
if (!$nameElements) { if (!$nameElements) {
$this->maniaControl->quit("Invalid database configuration (Name).", true); $this->maniaControl->quit("Invalid database configuration (Name).", true);
} }
$name = (string)$nameElements[0]; $name = (string) $nameElements[0];
// Create config object // Create config object
$config = new Config($host, $port, $user, $pass, $name); $config = new Config($host, $port, $user, $pass, $name);
@ -117,6 +119,15 @@ class Database implements TimerListener {
$this->config = $config; $this->config = $config;
} }
/**
* Return the mysqli instance
*
* @return \mysqli
*/
public function getMysqli() {
return $this->mysqli;
}
/** /**
* Connect to the defined Database * Connect to the defined Database
* *
@ -186,15 +197,6 @@ class Database implements TimerListener {
return true; return true;
} }
/**
* Return the mysqli instance
*
* @return \mysqli
*/
public function getMysqli() {
return $this->mysqli;
}
/** /**
* Return the database config * Return the database config
* *
@ -217,9 +219,7 @@ class Database implements TimerListener {
* Check whether the Database Connection is still open * Check whether the Database Connection is still open
*/ */
public function checkConnection() { public function checkConnection() {
if (!$this->getMysqli() if (!$this->getMysqli() || !$this->getMysqli()->ping()) {
|| !$this->getMysqli()->ping()
) {
$this->maniaControl->quit('The MySQL Server has gone away!', true); $this->maniaControl->quit('The MySQL Server has gone away!', true);
} }
} }

View File

@ -54,87 +54,108 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
* Public properties * Public properties
*/ */
/** @var ActionsMenu $actionsMenu /** @var ActionsMenu $actionsMenu
* @deprecated see getActionsMenu() * @deprecated
* @see getActionsMenu()
*/ */
public $actionsMenu = null; public $actionsMenu = null;
/** @var AuthenticationManager $authenticationManager /** @var AuthenticationManager $authenticationManager
* @deprecated see getAuthenticationManager() * @deprecated
* @see getAuthenticationManager()
*/ */
public $authenticationManager = null; public $authenticationManager = null;
/** @var CallbackManager $callbackManager /** @var CallbackManager $callbackManager
* @deprecated see getCallbackManager() * @deprecated
* @see getCallbackManager()
*/ */
public $callbackManager = null; public $callbackManager = null;
/** @var Chat $chat /** @var Chat $chat
* @deprecated see getChat() * @deprecated
* @see getChat()
*/ */
public $chat = null; public $chat = null;
/** @var \SimpleXMLElement $config /** @var \SimpleXMLElement $config
* @deprecated see getConfig() * @deprecated
* @see getConfig()
*/ */
public $config = null; public $config = null;
/** @var Configurator $configurator /** @var Configurator $configurator
* @deprecated see getConfigurator() * @deprecated
* @see getConfigurator()
*/ */
public $configurator = null; public $configurator = null;
/** @var Connection $client /** @var Connection $client
* @deprecated see getClient() * @deprecated
* @see getClient()
*/ */
public $client = null; public $client = null;
/** @var CommandManager $commandManager /** @var CommandManager $commandManager
* @deprecated see getCommandManager() * @deprecated
* @see getCommandManager()
*/ */
public $commandManager = null; public $commandManager = null;
/** @var Database $database /** @var Database $database
* @deprecated see getDatabase() * @deprecated
* @see getDatabase()
*/ */
public $database = null; public $database = null;
/** @var ManialinkManager $manialinkManager /** @var ManialinkManager $manialinkManager
* @deprecated see getManialinkManager * @deprecated
* @see getManialinkManager
*/ */
public $manialinkManager = null; public $manialinkManager = null;
/** @var MapManager $mapManager /** @var MapManager $mapManager
* @deprecated see getMapManager() * @deprecated
* @see getMapManager()
*/ */
public $mapManager = null; public $mapManager = null;
/** @var PlayerManager $playerManager /** @var PlayerManager $playerManager
* @deprecated see getPlayerManager() * @deprecated
* @see getPlayerManager()
*/ */
public $playerManager = null; public $playerManager = null;
/** @var PluginManager $pluginManager /** @var PluginManager $pluginManager
* @deprecated see getPluginManager() * @deprecated
* @see getPluginManager()
*/ */
public $pluginManager = null; public $pluginManager = null;
/** @var Server $server /** @var Server $server
* @deprecated see getServer() * @deprecated
* @see getServer()
*/ */
public $server = null; public $server = null;
/** @var SettingManager $settingManager /** @var SettingManager $settingManager
* @deprecated see getSettingManager() * @deprecated
* @see getSettingManager()
*/ */
public $settingManager = null; public $settingManager = null;
/** @var StatisticManager $statisticManager /** @var StatisticManager $statisticManager
* @deprecated see getStatisticManager() * @deprecated
* @see getStatisticManager()
*/ */
public $statisticManager = null; public $statisticManager = null;
/** @var UpdateManager $updateManager /** @var UpdateManager $updateManager
* @deprecated see getUpdateManager() * @deprecated
* @see getUpdateManager()
*/ */
public $updateManager = null; public $updateManager = null;
/** @var ErrorHandler $errorHandler /** @var ErrorHandler $errorHandler
* @deprecated see getErrorHandler() * @deprecated
* @see getErrorHandler()
*/ */
public $errorHandler = null; public $errorHandler = null;
/** @var TimerManager $timerManager /** @var TimerManager $timerManager
* @deprecated see getTimerManager() * @deprecated
* @see getTimerManager()
*/ */
public $timerManager = null; public $timerManager = null;
/** @var AsynchronousFileReader $fileReader /** @var AsynchronousFileReader $fileReader
* @deprecated see getFileReader() * @deprecated
* @see getFileReader()
*/ */
public $fileReader = null; public $fileReader = null;
/** @var BillManager $billManager /** @var BillManager $billManager
* @deprecated see getBillManager() * @deprecated
* @see getBillManager()
*/ */
public $billManager = null; public $billManager = null;
@ -612,7 +633,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
// Yield for next tick // Yield for next tick
$loopEnd = microtime(true); $loopEnd = microtime(true);
$loopDuration = $loopEnd - $loopStart; $loopDuration = $loopEnd - $loopStart;
$sleepTime = (int)(2500 - $loopDuration * 1000000); $sleepTime = (int) (2500 - $loopDuration * 1000000);
if ($sleepTime > 0) { if ($sleepTime > 0) {
usleep($sleepTime); usleep($sleepTime);
} }

View File

@ -33,13 +33,19 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
* Public properties * Public properties
*/ */
/** @var StyleManager $styleManager */ /** @var StyleManager $styleManager */
/** @deprecated see getStyleManager() */ /** @deprecated
* @see getStyleManager()
*/
public $styleManager = null; public $styleManager = null;
/** @var CustomUIManager $customUIManager */ /** @var CustomUIManager $customUIManager */
/** @deprecated see getCustomUIManager() */ /** @deprecated
* @see getCustomUIManager()
*/
public $customUIManager = null; public $customUIManager = null;
/** @var IconManager $iconManager */ /** @var IconManager $iconManager */
/** @deprecated see getIconManager() */ /** @deprecated
* @see getIconManager()
*/
public $iconManager = null; public $iconManager = null;
/* /*
@ -48,7 +54,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
private $maniaControl = null; private $maniaControl = null;
// TODO: use listening class // TODO: use listening class
private $pageAnswerListeners = array(); private $pageAnswerListeners = array();
private $pageAnswerRegexListener = array(); private $pageAnswerRegexListener = array();
/** /**
@ -225,7 +231,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
* @return bool * @return bool
*/ */
public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) { public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) {
$manialinkText = (string)$manialinkText; $manialinkText = (string) $manialinkText;
if (!$manialinkText) { if (!$manialinkText) {
return true; return true;

View File

@ -51,26 +51,40 @@ class MapManager implements CallbackListener {
/* /*
* Public properties * Public properties
*/ */
/** @var MapQueue $mapQueue */ /** @var MapQueue $mapQueue
/** @deprecated see getMapQueue() */ * @deprecated
* @see getMapQueue()
*/
public $mapQueue = null; public $mapQueue = null;
/** @var MapCommands $mapCommands */ /** @var MapCommands $mapCommands
/** @deprecated see getMapCommands() */ * @deprecated
* @see getMapCommands()
*/
public $mapCommands = null; public $mapCommands = null;
/** @var MapActions $mapActions */ /** @var MapActions $mapActions
/** @deprecated see getMapActions() */ * @deprecated
* @see getMapActions()
*/
public $mapActions = null; public $mapActions = null;
/** @var MapList $mapList */ /** @var MapList $mapList
/** @deprecated see getMapList() */ * @deprecated
* @see getMapList()
*/
public $mapList = null; public $mapList = null;
/** @var DirectoryBrowser $directoryBrowser */ /** @var DirectoryBrowser $directoryBrowser
/** @deprecated see getDirectoryBrowser() */ * @deprecated
* @see getDirectoryBrowser()
*/
public $directoryBrowser = null; public $directoryBrowser = null;
/** @var ManiaExchangeList $mxList */ /** @var ManiaExchangeList $mxList
/** @deprecated see getMXList() */ * @deprecated
* @see getMXList()
*/
public $mxList = null; public $mxList = null;
/** @var ManiaExchangeManager $mxManager */ /** @var ManiaExchangeManager $mxManager
/** @deprecated see getMXManager() */ * @deprecated
* @see getMXManager()
*/
public $mxManager = null; public $mxManager = null;
/* /*
@ -82,8 +96,8 @@ class MapManager implements CallbackListener {
private $maps = array(); private $maps = array();
/** @var Map $currentMap */ /** @var Map $currentMap */
private $currentMap = null; private $currentMap = null;
private $mapEnded = false; private $mapEnded = false;
private $mapBegan = false; private $mapBegan = false;
/** /**
* Construct a new map manager instance * Construct a new map manager instance

View File

@ -515,9 +515,13 @@ class PlayerActions {
/** /**
* Check if a Player is muted * Check if a Player is muted
* *
* @deprecated see Player/isMuted() * @deprecated
* @see Player::isMuted()
*/ */
public function isPlayerMuted($login) { public function isPlayerMuted($login) {
return $this->maniaControl->getPlayerManager()->getPlayer($login)->isMuted(); if ($player = $this->maniaControl->getPlayerManager()->getPlayer($login)) {
return $player->isMuted();
}
return false;
} }
} }

View File

@ -37,23 +37,35 @@ class PlayerManager implements CallbackListener, TimerListener {
/* /*
* Public properties * Public properties
*/ */
/** @var PlayerActions $playerActions */ /** @var PlayerActions $playerActions
/** @deprecated see getPlayerActions() */ * @deprecated
* @see getPlayerActions()
*/
public $playerActions = null; public $playerActions = null;
/** @var PlayerCommands $playerCommands */ /** @var PlayerCommands $playerCommands
/** @deprecated see getPlayerCommands() */ * @deprecated
* @see getPlayerCommands()
*/
public $playerCommands = null; public $playerCommands = null;
/** @var PlayerDetailed $playerDetailed */ /** @var PlayerDetailed $playerDetailed
/** @deprecated see getPlayerDetailed() */ * @deprecated
* @see getPlayerDetailed()
*/
public $playerDetailed = null; public $playerDetailed = null;
/** @var PlayerDataManager $playerDataManager */ /** @var PlayerDataManager $playerDataManager
/** @deprecated see getPlayerDataManager() */ * @deprecated
* @see getPlayerDataManager()
*/
public $playerDataManager = null; public $playerDataManager = null;
/** @var PlayerList $playerList */ /** @var PlayerList $playerList
/** @deprecated see getPlayerList() */ * @deprecated
* @see getPlayerList()
*/
public $playerList = null; public $playerList = null;
/** @var AdminLists $adminLists */ /** @var AdminLists $adminLists
/** @deprecated see getAdminLists() */ * @deprecated
* @see getAdminLists()
*/
public $adminLists = null; public $adminLists = null;
/* /*
@ -154,15 +166,6 @@ class PlayerManager implements CallbackListener, TimerListener {
return $this->playerDetailed; return $this->playerDetailed;
} }
/**
* Return the player data manager
*
* @return PlayerDataManager
*/
public function getPlayerDataManager() {
return $this->playerDataManager;
}
/** /**
* Return the player list * Return the player list
* *
@ -386,6 +389,15 @@ class PlayerManager implements CallbackListener, TimerListener {
return $count; return $count;
} }
/**
* Return the player data manager
*
* @return PlayerDataManager
*/
public function getPlayerDataManager() {
return $this->playerDataManager;
}
/** /**
* Update PlayerInfo * Update PlayerInfo
* *

View File

@ -28,27 +28,37 @@ class Server implements CallbackListener {
* Public properties * Public properties
*/ */
/** @var Config $config */ /** @var Config $config */
public $config = null; public $config = null;
public $index = -1; public $index = -1;
public $ip = null; public $ip = null;
public $port = -1; public $port = -1;
public $p2pPort = -1; public $p2pPort = -1;
public $login = null; public $login = null;
public $titleId = null; public $titleId = null;
/** @var Directory $directory */ /** @var Directory $directory
/** @deprecated see getDirectory() */ * @deprecated
* @see getDirectory()
*/
public $directory = null; public $directory = null;
/** @var Commands $commands */ /** @var Commands $commands
/** @deprecated see getCommands() */ * @deprecated
* @see getCommands()
*/
public $commands = null; public $commands = null;
/** @var UsageReporter $usageReporter */ /** @var UsageReporter $usageReporter
/** @deprecated see getUsageReporter() */ * @deprecated
* @see getUsageReporter()
*/
public $usageReporter = null; public $usageReporter = null;
/** @var RankingManager $rankingManager */ /** @var RankingManager $rankingManager
/** @deprecated see getRankingManager() */ * @deprecated
* @see getRankingManager()
*/
public $rankingManager = null; public $rankingManager = null;
/** @var ScriptManager $scriptManager */ /** @var ScriptManager $scriptManager
/** @deprecated see getScriptManager() */ * @deprecated
* @see getScriptManager()
*/
public $scriptManager = null; public $scriptManager = null;
/* /*
@ -56,7 +66,7 @@ class Server implements CallbackListener {
*/ */
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
private $maniaControl = null; private $maniaControl = null;
private $teamMode = null; private $teamMode = null;
/** /**
* Construct a new Server * Construct a new Server
@ -113,15 +123,6 @@ class Server implements CallbackListener {
return $this->config; return $this->config;
} }
/**
* Return the server directory
*
* @return Directory
*/
public function getDirectory() {
return $this->directory;
}
/** /**
* Return the server commands * Return the server commands
* *
@ -335,6 +336,15 @@ class Server implements CallbackListener {
return $ghostReplay; return $ghostReplay;
} }
/**
* Return the server directory
*
* @return Directory
*/
public function getDirectory() {
return $this->directory;
}
/** /**
* Check if ManiaControl has Access to the given Directory * Check if ManiaControl has Access to the given Directory
* *
@ -422,7 +432,7 @@ class Server implements CallbackListener {
*/ */
public function setTeamMode($teamMode = true) { public function setTeamMode($teamMode = true) {
$oldStatus = $this->teamMode; $oldStatus = $this->teamMode;
$this->teamMode = (bool)$teamMode; $this->teamMode = (bool) $teamMode;
// Trigger callback // Trigger callback
if ($oldStatus !== $this->teamMode | $oldStatus === null) { if ($oldStatus !== $this->teamMode | $oldStatus === null) {

View File

@ -22,7 +22,7 @@ class StatisticManager {
const STAT_TYPE_TIME = '1'; const STAT_TYPE_TIME = '1';
const STAT_TYPE_FLOAT = '2'; const STAT_TYPE_FLOAT = '2';
const SPECIAL_STAT_KD_RATIO = 'Kill Death Ratio'; //TODO dynamic later const SPECIAL_STAT_KD_RATIO = 'Kill Death Ratio'; //TODO dynamic later
const SPECIAL_STAT_HITS_PH = 'Hits Per Hour'; const SPECIAL_STAT_HITS_PH = 'Hits Per Hour';
const SPECIAL_STAT_LASER_ACC = 'Laser Accuracy'; const SPECIAL_STAT_LASER_ACC = 'Laser Accuracy';
const SPECIAL_STAT_NUCLEUS_ACC = 'Nucleus Accuracy'; const SPECIAL_STAT_NUCLEUS_ACC = 'Nucleus Accuracy';
@ -32,11 +32,15 @@ class StatisticManager {
/* /*
* Public properties * Public properties
*/ */
/** @var StatisticCollector $statisticCollector */ /** @var StatisticCollector $statisticCollector
/** @deprecated see getStatisticCollector() */ * @deprecated
* @see getStatisticCollector()
*/
public $statisticCollector = null; public $statisticCollector = null;
/** @var SimpleStatsList $simpleStatsList */ /** @var SimpleStatsList $simpleStatsList
/** @deprecated see getSimpleStatsList() */ * @deprecated
* @see getSimpleStatsList()
*/
public $simpleStatsList = null; public $simpleStatsList = null;
/* /*
@ -44,7 +48,7 @@ class StatisticManager {
*/ */
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
private $maniaControl = null; private $maniaControl = null;
private $stats = array(); private $stats = array();
private $specialStats = array(); private $specialStats = array();
/** /**
@ -343,7 +347,7 @@ class StatisticManager {
private function getStatId($statName) { private function getStatId($statName) {
if (isset($this->stats[$statName])) { if (isset($this->stats[$statName])) {
$stat = $this->stats[$statName]; $stat = $this->stats[$statName];
return (int)$stat->index; return (int) $stat->index;
} }
return null; return null;
} }
@ -429,7 +433,7 @@ class StatisticManager {
if (!$shots) { if (!$shots) {
continue; continue;
} }
$playerStats[$stat->name] = array($stat, (float)($hits / $shots)); $playerStats[$stat->name] = array($stat, (float) ($hits / $shots));
break; break;
} }
} }

View File

@ -40,7 +40,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* Public properties * Public properties
*/ */
/** @var PluginUpdateManager $pluginUpdateManager /** @var PluginUpdateManager $pluginUpdateManager
* @deprecated see getPluginUpdateManager() * @deprecated
* @see getPluginUpdateManager()
*/ */
public $pluginUpdateManager = null; public $pluginUpdateManager = null;
@ -48,7 +49,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* Private properties * Private properties
*/ */
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
private $maniaControl = null; private $maniaControl = null;
private $currentBuildDate = null; private $currentBuildDate = null;
/** @var UpdateData $coreUpdateData */ /** @var UpdateData $coreUpdateData */
private $coreUpdateData = null; private $coreUpdateData = null;
@ -403,7 +404,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
*/ */
public function setBuildDate($date) { public function setBuildDate($date) {
$nightlyBuildDateFile = MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . self::BUILD_DATE_FILE_NAME; $nightlyBuildDateFile = MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . self::BUILD_DATE_FILE_NAME;
$success = (bool)file_put_contents($nightlyBuildDateFile, $date); $success = (bool) file_put_contents($nightlyBuildDateFile, $date);
$this->currentBuildDate = $date; $this->currentBuildDate = $date;
return $success; return $success;
} }