added, fixed & improved PHPDoc & Type Hints

This commit is contained in:
Steffen Schröder 2014-05-02 16:13:45 +02:00
parent 7469d97712
commit 212517d290
32 changed files with 157 additions and 89 deletions

View File

@ -72,6 +72,7 @@ else {
* Log and echo the given text
*
* @param string $message
* @param bool $eol
*/
function logMessage($message, $eol = true) {
$date = date("d.M y H:i:s");

View File

@ -227,7 +227,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
/**
* Reopen the widget on Map Begin, MapListChanged, etc.
*
* @param array $callback
* @param Player $player
*/
public function updateWidget(Player $player) {
foreach($this->adminListShown as $login => $shown) {

View File

@ -28,9 +28,9 @@ class AuthCommands implements CommandListener {
$this->maniaControl = $maniaControl;
// Register for commands
$this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',true, 'Adds player to adminlist as SuperAdmin.');
$this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin',true, 'Adds player to adminlist as Admin.');
$this->maniaControl->commandManager->registerCommandListener('addmod', $this, 'command_AddModerator',true, 'Add player to adminlist as Moderator.');
$this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',true, 'Add Player to the AdminList as SuperAdmin.');
$this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin',true, 'Add Player to the AdminList as Admin.');
$this->maniaControl->commandManager->registerCommandListener('addmod', $this, 'command_AddModerator',true, 'Add Player to the AdminList as Moderator.');
}
/**

View File

@ -17,7 +17,7 @@ class BillData {
public $function = null;
public $pay = false;
public $player = null;
public $receiverLogin = false;
public $receiverLogin = null;
public $amount = 0;
public $creationTime = -1;
@ -26,10 +26,10 @@ class BillData {
* @param mixed $function
* @param Player $player
* @param int $amount
* @param string $pay
* @param bool $pay
* @param string $receiverLogin
*/
public function __construct($function, $player, $amount, $pay = false, $receiverLogin = false) {
public function __construct($function, Player $player, $amount, $pay = false, $receiverLogin = null) {
$this->function = $function;
$this->player = $player;
$this->amount = $amount;

View File

@ -5,6 +5,13 @@ namespace ManiaControl\Callbacks;
use ManiaControl\ManiaControl;
/**
* Class managing & converting LibXmlRpc Callbacks
*
* @author ManiaControl Team
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class LibXmlRpcCallbackManager implements CallbackListener {
/*
* Private Properties
@ -15,6 +22,7 @@ class LibXmlRpcCallbackManager implements CallbackListener {
* Create a new LibXmlRpc Callbacks Instance
*
* @param ManiaControl $maniaControl
* @param CallbackManager $callbackManager
*/
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
$this->maniaControl = $maniaControl;
@ -24,10 +32,10 @@ class LibXmlRpcCallbackManager implements CallbackListener {
/**
* Handle Script Callbacks
*
* @param $name
* @param $data
* @param string $name
* @param array $data
*/
public function handleScriptCallbacks($name, $data) {
public function handleScriptCallbacks($name, array $data) {
switch($name) {
case 'LibXmlRpc_BeginMatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
@ -76,9 +84,9 @@ class LibXmlRpcCallbackManager implements CallbackListener {
/**
* Triggers the Ranking of a Player
*
* @param $data
* @param array $data
*/
private function triggerPlayerRanking($data) {
private function triggerPlayerRanking(array $data) {
$player = $this->maniaControl->playerManager->getPlayer($data[1]);
$this->maniaControl->callbackManager->triggerCallback(Callbacks::PLAYERRANKING, $player, $data[0], $data[6], $data[5]);
}

View File

@ -29,6 +29,7 @@ class ShootManiaCallbacks implements CallbackListener {
* Create a new ShootMania Callbacks Instance
*
* @param ManiaControl $maniaControl
* @param CallbackManager $callbackManager
*/
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
$this->maniaControl = $maniaControl;

View File

@ -55,11 +55,12 @@ class TimerManager {
}
/**
* Register a Timing Listening, note < 10ms it can get inaccurate
* Register a Timer Listening, note < 10ms it can get inaccurate
*
* @param TimerListener $listener
* @param $method
* @param $time
* @param string $method
* @param float $time
* @param bool $oneTime
* @return bool
*/
public function registerTimerListening(TimerListener $listener, $method, $time, $oneTime = false) {

View File

@ -131,14 +131,14 @@ class Chat {
/**
* Send the Exception Information to the Chat
*
* @param Exception $exception
* @param \Exception $exception
* @param string $login
* @return bool
*/
public function sendException(\Exception $exception, $login = null) {
$message = "Exception occurred: '{$exception->getMessage()}' ({$exception->getCode()})";
$this->maniaControl->errorHandler->triggerDebugNotice($message);
$this->sendError($message, $login);
return $this->sendError($message, $login);
}
/**

View File

@ -103,6 +103,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
* Handle Config Admin Command
*
* @param array $callback
* @param Player $player
*/
public function handleConfigCommand(array $callback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)) {
@ -123,11 +124,12 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
}
/**
* Reopens the Menu
* Reopen the Menu
*
* @param array $callback
* @param Player $player
* @param int $menuId
*/
public function reopenMenu($player, $menuId = 0) {
public function reopenMenu(Player $player, $menuId = 0) {
$this->showMenu($player, $menuId);
}
@ -240,10 +242,10 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
}
/**
* Build menu manialink if necessary
* Build Menu ManiaLink if necessary
*
* @param int $menuIdShown
* @internal param bool $forceBuild
* @param Player $player
* @return \FML\ManiaLink
*/
private function buildManialink($menuIdShown = 0, Player $player) {

View File

@ -399,7 +399,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
*
* @param array $newSettings
* @param Player $player
* @param bool
* @return bool
*/
private function applyNewScriptSettings(array $newSettings, Player $player) {
if (!$newSettings) {

View File

@ -43,9 +43,9 @@ class ErrorHandler {
/**
* ManiaControl ExceptionHandler
* ManiaControl Shuts down after exception
*
* @param \Exception $ex
* @param bool $shutdown
*/
public function exceptionHandler(\Exception $ex, $shutdown = true) {
// Log exception

View File

@ -55,8 +55,9 @@ class AsynchronousFileReader {
* Load a remote file
*
* @param string $url
* @param $function
* @param callable $function
* @param string $contentType
* @param int $keepAlive
* @return bool
*/
public function loadFile($url, $function, $contentType = 'UTF-8', $keepAlive = 0) {
@ -118,10 +119,10 @@ class AsynchronousFileReader {
/**
* Send Data via POST Method
*
* @param $url
* @param $function
* @param $content
* @param string $compression
* @param string $url
* @param callable $function
* @param string $content
* @param bool $compression
* @param string $contentType
* @return bool
*/

View File

@ -167,6 +167,7 @@ class ManiaControl implements CommandListener, TimerListener {
* Print a message to console and log
*
* @param string $message
* @param bool $stripCodes
*/
public function log($message, $stripCodes = false) {
if ($stripCodes) {

View File

@ -312,6 +312,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
}
}
/**
* Handle ManialinkPageAnswer Callback
*
* @param array $callback
*/
public function handleManialinkPageAnswer(array $callback) {
$actionId = $callback[1][2];
@ -357,7 +362,12 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
}
}
private function showMapListAuthor($author, $player) {
/**
* Show the Player a List of Maps from the given Author
* @param string $author
* @param Player $player
*/
private function showMapListAuthor($author, Player $player) {
$maps = $this->maniaControl->mapManager->getMaps();
$mapList = array();
/** @var Map $map */
@ -375,7 +385,13 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$this->maniaControl->mapManager->mapList->showMapList($player, $mapList);
}
private function showMapListKarma($best, $player) {
/**
* Show a Karma based MapList
*
* @param bool $best
* @param Player $player
*/
private function showMapListKarma($best, Player $player) {
/** @var \MCTeam\KarmaPlugin $karmaPlugin */
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(MapList::DEFAULT_KARMA_PLUGIN);
if($karmaPlugin) {
@ -418,15 +434,28 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
}
}
/**
* Helper Function to sort Maps by Karma
*
* @param Map $a
* @param Map $b
* @return mixed
*/
private function sortByKarma($a, $b) {
return $a->karma - $b->karma;
return ($a->karma - $b->karma);
}
private function showMapListDate($newest, $player) {
/**
* Show a Date based MapList
*
* @param bool $newest
* @param Player $player
*/
private function showMapListDate($newest, Player $player) {
$maps = $this->maniaControl->mapManager->getMaps();
usort($maps, function($a, $b) {
return $a->index - $b->index;
return ($a->index - $b->index);
});
if($newest) {

View File

@ -170,14 +170,17 @@ class MapManager implements CallbackListener {
}
/**
* Updates the Timestamp of a map
* Update the Timestamp of a Map
*
* @param $map
* @param string $uid
* @return bool
*/
private function updateMapTimestamp($uid) {
$mysqli = $this->maniaControl->database->mysqli;
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET mxid = 0, changed = NOW() WHERE 'uid' = ?";
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
mxid = 0,
changed = NOW()
WHERE 'uid' = ?";
$mapStatement = $mysqli->prepare($mapQuery);
if ($mysqli->error) {
@ -196,17 +199,16 @@ class MapManager implements CallbackListener {
}
/**
* Updates a Map from Mania Exchange
* Update a Map from Mania Exchange
*
* @param Player $admin
* @param $mxId
* @param $uid
* @param string $uid
*/
public function updateMap(Player $admin, $uid) {
$this->updateMapTimestamp($uid);
if (!isset($uid) || !isset($this->maps[$uid])) {
trigger_error("Error while updating Map, unkown UID: " . $uid);
trigger_error("Error while updating Map, unknown UID: " . $uid);
$this->maniaControl->chat->sendError("Error while updating Map.", $admin->login);
return;
}
@ -560,6 +562,8 @@ class MapManager implements CallbackListener {
/**
* Get all Maps
*
* @param int $offset
* @param int $length
* @return array
*/
public function getMaps($offset = null, $length = null) {

View File

@ -203,7 +203,6 @@ class PlayerActions {
*
* @param string $adminLogin
* @param string $targetLogin
* @param int $spectatorState
*/
public function unMutePlayer($adminLogin, $targetLogin) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
@ -236,7 +235,6 @@ class PlayerActions {
*
* @param string $adminLogin
* @param string $targetLogin
* @param int $spectatorState
*/
public function mutePlayer($adminLogin, $targetLogin) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);

View File

@ -167,8 +167,8 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
* @param array $chatCallback
* @param Player $player
*/
public function command_Warn(array $chat, Player $player) {
$params = explode(' ', $chat[1][2], 3);
public function command_Warn(array $chatCallback, Player $player) {
$params = explode(' ', $chatCallback[1][2], 3);
if (count($params) <= 1) {
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
return;

View File

@ -116,16 +116,16 @@ class PlayerDataManager {
/**
* Gets the Player Data
*
* @param $object
* @param $dataName
* @param mixed $object
* @param string $dataName
* @param Player $player
* @param $serverIndex
* @param int $serverIndex
* @return mixed|null
*/
public function getPlayerData($object, $statName, Player $player, $serverIndex = -1) {
public function getPlayerData($object, $dataName, Player $player, $serverIndex = -1) {
$className = $this->getClassName($object);
$meta = $this->metaData[$className . $statName];
$meta = $this->metaData[$className . $dataName];
//Check if data is already in the ram
if (isset($this->storedData[$player->index])) {
@ -152,7 +152,7 @@ class PlayerDataManager {
}
$dataStatement->store_result();
if ($dataStatement->num_rows <= 0) {
$this->setPlayerData($object, $statName, $player, $meta->defaultValue, $serverIndex);
$this->setPlayerData($object, $dataName, $player, $meta->defaultValue, $serverIndex);
return $meta->default;
}
$dataStatement->bind_result($value);
@ -172,11 +172,11 @@ class PlayerDataManager {
/**
* Set a PlayerData to a specific defined statMetaData
*
* @param $object
* @param $statName
* @param mixed $object
* @param string $dataName
* @param Player $player
* @param $value
* @param $serverIndex (let it empty if its global)
* @param mixed $value
* @param int $serverIndex (let it empty if its global)
* @return bool
*/
public function setPlayerData($object, $dataName, Player $player, $value, $serverIndex = -1) {
@ -225,7 +225,8 @@ class PlayerDataManager {
/**
* Return the Id of the MetaData
*
* @param $statName
* @param string $className
* @param string $statName
* @return int
*/
private function getMetaDataId($className, $statName) {

View File

@ -14,6 +14,7 @@ use ManiaControl\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Statistics\StatisticManager;
use Maniaplanet\DedicatedServer\Structures\Player;
/**
* Player Detailed Page
@ -48,8 +49,14 @@ class PlayerDetailed {
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
}
/**
* Show a Frame with detailed Information about the Target Player
*
* @param Player $player
* @param string $targetLogin
*/
public function showPlayerDetailed(Player $player, $targetLogin) {
/** @var Player $target */
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
//Create ManiaLink
@ -209,7 +216,13 @@ class PlayerDetailed {
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'PlayerDetailed');
}
public function statisticsFrame($player) {
/**
* Build a Frame with Statistics about the given Player
*
* @param Player $player
* @return Frame
*/
public function statisticsFrame(Player $player) {
$frame = new Frame();
$playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player);

View File

@ -2,6 +2,7 @@
namespace ManiaControl\Players;
use Maniaplanet\DedicatedServer\Structures\Player;
use MCTeam\CustomVotesPlugin;
use FML\Controls\Control;
use FML\Controls\Frame;
@ -412,10 +413,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
/**
* Extra window with special actions on players like warn,kick, ban, authorization levels...
*
* @param $login
* @param Player $admin
* @param string $login
* @return Frame
*/
public function showAdvancedPlayerWidget($admin, $login) {
public function showAdvancedPlayerWidget(Player $admin, $login) {
$player = $this->maniaControl->playerManager->getPlayer($login);
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();

View File

@ -306,7 +306,7 @@ class PlayerManager implements CallbackListener, TimerListener {
*
* @param string $login
* @param bool $connectedPlayersOnly
* @return Player|null
* @return Player
*/
public function getPlayer($login, $connectedPlayersOnly = false) {
if (!isset($this->players[$login])) {
@ -390,10 +390,10 @@ class PlayerManager implements CallbackListener, TimerListener {
/**
* Get's a Player out of the database
* Get a Player from the Database
*
* @param $playerIndex
* @return Player $player
* @param string $playerLogin
* @return Player
*/
private function getPlayerFromDatabaseByLogin($playerLogin) {
$mysqli = $this->maniaControl->database->mysqli;

View File

@ -58,6 +58,7 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
* @param float $width
* @param float $height
* @param Script $script
* @param Player $player
* @return \FML\Controls\Frame
*/
public function getMenu($width, $height, Script $script, Player $player) {

View File

@ -396,7 +396,7 @@ class PluginManager {
/**
* Get the Class of the Object
*
* @param mixed $pluginClass
* @param mixed $object
* @return string
*/
private static function getClass($object) {

View File

@ -190,9 +190,10 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
}
/**
* Breaks the current game
* Pause the current game
*
* @param array $callback
* @param Player $player
*/
public function setPause(array $callback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_SET_PAUSE)) {

View File

@ -440,7 +440,8 @@ class SettingManager implements CallbackListener {
/**
* Get all Setting Classes
*
*
* @param bool $hidePluginClasses
* @return array
*/
public function getSettingClasses($hidePluginClasses = false) {

View File

@ -113,9 +113,10 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
/**
* Show the PlayerList Widget to the Player
* Show the StatsList Widget to the Player
*
* @param Player $player
* @param string $order
*/
public function showStatsList(Player $player, $order = PlayerManager::STAT_SERVERTIME) {
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();

View File

@ -122,9 +122,10 @@ class StatisticCollector implements CallbackListener {
}
/**
* Handle Player Shoots
* Handle Player Shots
*
* @param $login
* @param string $login
* @param int $weaponNumber
*/
private function handleOnShoot($login, $weaponNumber) {
if (!isset($this->onShootArray[$login])) {
@ -165,9 +166,10 @@ class StatisticCollector implements CallbackListener {
}
/**
* Gets the Weapon stat
* Get the Weapon stat
*
* @param $weaponNumber
* @param int $weaponNumber
* @param bool $shot
* @return string
*/
private function getWeaponStat($weaponNumber, $shot = true) {

View File

@ -41,7 +41,7 @@ class PluginUpdateData {
}
/**
* Check if the Plugin Update Data is newer than the given Plugin Versin
* Check if the Plugin Update Data is newer than the given Plugin Version
*
* @param float $version
* @return bool

View File

@ -322,6 +322,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
*
* @param PluginUpdateData $pluginUpdateData
* @param Player $player
* @param bool $update
*/
private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) {
$self = $this;

View File

@ -453,6 +453,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* Check if ManiaControl is running the Nightly Update Channel
*
* @param string $updateChannel
* @return bool
*/
public function isNightlyUpdateChannel($updateChannel = null) {
if (!$updateChannel) {

View File

@ -70,7 +70,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
//do nothing
}
/**
* @see \ManiaControl\Plugins\Plugin::load()
*/
@ -153,9 +152,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
}
/**
* Handle ManiaControl OnStartup
*
* @param array $callback
* Display the Widget
*/
public function displayWidget() {
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
@ -323,12 +320,15 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
}
/**
* Handles a Player Donate
* Handle a Player Donation
*
* @param Player $player
* @param $value
* @param int $amount
* @param string $receiver
* @param string $receiverName
* @return bool
*/
private function handleDonation(Player $player, $amount, $receiver = '', $receiverName = false) {
private function handleDonation(Player $player, $amount, $receiver = '', $receiverName = null) {
if (!$receiverName) {
$serverName = $this->maniaControl->client->getServerName();

View File

@ -149,9 +149,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
}
/**
* Displays the Widgets onLoad
*
* @param array $callback
* Display the Widgets
*/
private function displayWidgets() {
// Display Map Widget
@ -168,11 +166,11 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
}
/**
* Displays the Map Widget
* Display the Map Widget
*
* @param String $login
* @param string $login
*/
public function displayMapWidget($login = false) {
public function displayMapWidget($login = null) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_WIDTH);
@ -280,11 +278,11 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
}
/**
* Displays the Server Info Widget
* Display the Server Info Widget
*
* @param String $login
* @param string $login
*/
public function displayServerInfoWidget($login = false) {
public function displayServerInfoWidget($login = null) {
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH);