From b25171657c88deb233f157ffca113e8c71972c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 24 Oct 2014 20:20:12 +0200 Subject: [PATCH] phpdoc & formatting improvements --- core/Admin/AdminLists.php | 4 +- .../Structures/ArmorEmptyStructure.php | 35 +++++++++++---- .../Callbacks/Structures/CaptureStructure.php | 20 +++++++-- .../Structures/NearMissStructure.php | 45 ++++++++++++------- .../Structures/PlayerHitStructure.php | 39 +++++++++++----- core/Callbacks/Structures/Weapons.php | 2 +- core/ManiaExchange/ManiaExchangeList.php | 4 +- 7 files changed, 104 insertions(+), 45 deletions(-) diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index bcf0812d..61396086 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -236,7 +236,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { /** * Closes the widget * - * @param \ManiaControl\Players\Player $player + * @param Player $player */ public function closeWidget(Player $player) { unset($this->adminListShown[$player->login]); @@ -246,7 +246,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { * Unset the player if he opened another Main Widget * * @param Player $player - * @param $openedWidget + * @param string $openedWidget */ public function handleWidgetOpened(Player $player, $openedWidget) { //unset when another main widget got opened diff --git a/core/Callbacks/Structures/ArmorEmptyStructure.php b/core/Callbacks/Structures/ArmorEmptyStructure.php index eb9babab..09108816 100644 --- a/core/Callbacks/Structures/ArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ArmorEmptyStructure.php @@ -2,11 +2,13 @@ namespace ManiaControl\Callbacks\Structures; - use ManiaControl\ManiaControl; use ManiaControl\Players\Player; class ArmorEmptyStructure { + /* + * Private properties + */ private $shooter; private $victim; private $damage; @@ -15,8 +17,14 @@ class ArmorEmptyStructure { /** @var ManiaControl $maniaControl */ private $maniaControl; - public function __construct(ManiaControl $maniaControl, $data) { - $this->maniaControl = $maniaControl; + /** + * Construct a new Armor Empty Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, array $data) { + $this->maniaControl = $maniaControl; $this->shooter = $data[0]; $this->victim = $data[1]; $this->damage = $data[2]; @@ -25,22 +33,26 @@ class ArmorEmptyStructure { } /** + * Get the shooter + * * @return Player */ public function getShooter() { - $shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter); - return $shooter; + return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter); } /** + * Get the victim + * * @return Player */ public function getVictim() { - $victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim); - return $victim; + return $this->maniaControl->getPlayerManager()->getPlayer($this->victim); } /** + * Get the damage + * * @return int */ public function getDamage() { @@ -48,6 +60,8 @@ class ArmorEmptyStructure { } /** + * Get the shooter points + * * @return int */ public function getShooterPoints() { @@ -55,9 +69,12 @@ class ArmorEmptyStructure { } /** + * Get the weapon + * * @return int */ - public function getWeapon() { //TODO any way of returning type "Weapon?" + public function getWeapon() { + // TODO: any way of returning type "Weapon?" return $this->weapon; } -} \ No newline at end of file +} diff --git a/core/Callbacks/Structures/CaptureStructure.php b/core/Callbacks/Structures/CaptureStructure.php index 1ece8802..12925fab 100644 --- a/core/Callbacks/Structures/CaptureStructure.php +++ b/core/Callbacks/Structures/CaptureStructure.php @@ -2,28 +2,40 @@ namespace ManiaControl\Callbacks\Structures; - use ManiaControl\ManiaControl; use ManiaControl\Players\Player; class CaptureStructure { + /* + * Private properties + */ private $playerArray; /** @var ManiaControl $maniaControl */ private $maniaControl; - public function __construct(ManiaControl $maniaControl, $data) { + /** + * Construct a new Capture Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, array $data) { $this->maniaControl = $maniaControl; $this->playerArray = $data; } /** - * @return mixed + * Get the logins + * + * @return array */ public function getLoginArray() { return $this->playerArray; } /** + * Get the players + * * @return Player[] */ public function getPlayerArray() { @@ -33,4 +45,4 @@ class CaptureStructure { } return $playerArray; } -} \ No newline at end of file +} diff --git a/core/Callbacks/Structures/NearMissStructure.php b/core/Callbacks/Structures/NearMissStructure.php index 12b0dac4..67f5cc94 100644 --- a/core/Callbacks/Structures/NearMissStructure.php +++ b/core/Callbacks/Structures/NearMissStructure.php @@ -2,55 +2,68 @@ namespace ManiaControl\Callbacks\Structures; - use ManiaControl\ManiaControl; use ManiaControl\Players\Player; class NearMissStructure { + /* + * Private properties + */ private $shooter; private $victim; private $distance; private $weapon; - /** @var ManiaControl $maniaControl */ private $maniaControl; - public function __construct(ManiaControl $maniaControl, $data) { + /** + * Construct a new Near Miss Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, array $data) { $this->maniaControl = $maniaControl; - $this->shooter = $data[0]; - $this->victim = $data[1]; - $this->weapon = $data[2]; - $this->distance = $data[3]; + $this->shooter = $data[0]; + $this->victim = $data[1]; + $this->weapon = $data[2]; + $this->distance = $data[3]; } /** - * @return Player|null + * Get the shooter + * + * @return Player */ public function getShooter() { - $shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter); - return $shooter; + return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter); } /** - * @return Player|null + * Get the victim + * + * @return Player */ public function getVictim() { - $victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim); - return $victim; + return $this->maniaControl->getPlayerManager()->getPlayer($this->victim); } /** - * @return mixed + * Get the distance + * + * @return float */ public function getDistance() { return $this->distance; } /** - * @return mixed + * Get the weapon + * + * @return int */ public function getWeapon() { return $this->weapon; } -} \ No newline at end of file +} diff --git a/core/Callbacks/Structures/PlayerHitStructure.php b/core/Callbacks/Structures/PlayerHitStructure.php index 8df14a38..84b281b5 100644 --- a/core/Callbacks/Structures/PlayerHitStructure.php +++ b/core/Callbacks/Structures/PlayerHitStructure.php @@ -2,11 +2,13 @@ namespace ManiaControl\Callbacks\Structures; - use ManiaControl\ManiaControl; use ManiaControl\Players\Player; class PlayerHitStructure { + /* + * Private properties + */ private $shooter; private $victim; private $damage; @@ -15,8 +17,14 @@ class PlayerHitStructure { /** @var ManiaControl $maniaControl */ private $maniaControl; - public function __construct(ManiaControl $maniaControl, $data) { - $this->maniaControl = $maniaControl; + /** + * Construct new Player Hit Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, array $data) { + $this->maniaControl = $maniaControl; $this->shooter = $data[0]; $this->victim = $data[1]; $this->damage = $data[2]; @@ -25,22 +33,26 @@ class PlayerHitStructure { } /** - * @return Player|null + * Get the shooter + * + * @return Player */ public function getShooter() { - $shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter); - return $shooter; + return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter); } /** - * @return Player|null + * Get the victim + * + * @return Player */ public function getVictim() { - $victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim); - return $victim; + return $this->maniaControl->getPlayerManager()->getPlayer($this->victim); } /** + * Get the damage + * * @return int */ public function getDamage() { @@ -48,6 +60,8 @@ class PlayerHitStructure { } /** + * Get the shooter points + * * @return int */ public function getShooterPoints() { @@ -55,9 +69,12 @@ class PlayerHitStructure { } /** + * Get the weapon + * * @return int */ - public function getWeapon() { //TODO any way of returning type "Weapon?" + public function getWeapon() { + // TODO: any way of returning type "Weapon?" return $this->weapon; } -} \ No newline at end of file +} diff --git a/core/Callbacks/Structures/Weapons.php b/core/Callbacks/Structures/Weapons.php index 1e92bea1..b82e4d39 100644 --- a/core/Callbacks/Structures/Weapons.php +++ b/core/Callbacks/Structures/Weapons.php @@ -14,4 +14,4 @@ interface Weapons { const ROCKET = 2; const NUCLEUS = 3; const ARROW = 5; -} \ No newline at end of file +} diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index 29d33246..87e5bb70 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -81,7 +81,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $action = $actionArray[0] . '.' . $actionArray[1]; $login = $callback[1][1]; $player = $this->maniaControl->getPlayerManager()->getPlayer($login); - $mapId = (int)$actionArray[2]; + $mapId = (int) $actionArray[2]; switch ($action) { case self::ACTION_GET_MAPS_FROM_AUTHOR: @@ -353,4 +353,4 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener unset($this->mapListShown[$player->login]); } -} \ No newline at end of file +}