Skip to content

Commit

Permalink
PHPStan fixes & README fix
Browse files Browse the repository at this point in the history
- PHPStan fixes
- Fixed README link
  • Loading branch information
Shock95 committed Sep 8, 2020
1 parent 4336f72 commit f21ea9e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ AuctionHouse allows players to list their items for sale and purchase items that
- And more coming soon!
---
## Download
Check the [releases tab](https://github.com/Shock95x/AuctionHouse/releases) or [PoggitCI](https://poggit.pmmp.io/ci/Shock95x/AuctionHouse/AuctionHouse/)
Download the plugin from [Poggit](https://poggit.pmmp.io/p/AuctionHouse) or [GitHub releases](https://github.com/Shock95x/AuctionHouse/releases)

---
## Config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

final class BinaryStringParser{

public static function fromDatabase(string $type) : BinaryStringParserInstance{
public static function fromDatabase(string $type) : ?BinaryStringParserInstance {
switch($type){
case "mysql":
return new MySQLBinaryStringParser();
case "sqlite":
return new SQLiteBinaryStringParser();
default:
return null;
}
}
}
14 changes: 8 additions & 6 deletions src/shock95x/auctionhouse/economy/EconomyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

namespace shock95x\auctionhouse\economy;

use pocketmine\Player;

interface EconomyProvider {

/**
* @param $player
* @param int $amount
* @param string|Player $player
* @param int|float $amount
*/
public function addMoney($player, int $amount): void;

/**
* @param $player
* @param int $amount
* @param string|Player $player
* @param int|float $amount
*/
public function subtractMoney($player, int $amount): void;

/**
* @param $player
* @param string|Player $player
*
* @return int
* @return int|float
*/
public function getMoney($player): int;

Expand Down
15 changes: 7 additions & 8 deletions src/shock95x/auctionhouse/economy/EconomySProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace shock95x\auctionhouse\economy;

use onebone\economyapi\EconomyAPI;
use pocketmine\Player;
use ReflectionException;

class EconomySProvider implements EconomyProvider {
Expand All @@ -17,18 +18,16 @@ public function __construct() {
}

/**
* @param $player
* @param int $amount
*
* @throws ReflectionException
* @param string|Player $player
* @param int|float $amount
*/
public function addMoney($player, int $amount): void {
$this->economyAPI->addMoney($player, $amount);
}

/**
* @param $player
* @param int $amount
* @param string|Player $player
* @param int|float $amount
*
* @throws ReflectionException
*/
Expand All @@ -37,9 +36,9 @@ public function subtractMoney($player, int $amount): void {
}

/**
* @param $player
* @param string|Player $player
*
* @return int
* @return int|float
*/
public function getMoney($player): int {
return $this->economyAPI->myMoney($player);
Expand Down
2 changes: 1 addition & 1 deletion src/shock95x/auctionhouse/menu/AHMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Player $player, bool $returnMain = false, bool $pagi
if(PlayerManager::get($player) !== null) {
$menu = PlayerManager::get($player)->getCurrentMenu();
// workaround for inventory bug
if($menu !== null) {
if($menu !== null && $menu instanceof AHMenu) {
if($menu->getInventory()->getSize() < $type->getSize()) {
$player->removeWindow($menu->getInventory());
$this->createNewInventory($type);
Expand Down
7 changes: 4 additions & 3 deletions src/shock95x/auctionhouse/utils/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ public static function loadLanguages(String $dataFolder) {
* Gets messages from lang files
*
* @param Player|null $sender
* @param $key
* @param string $key
* @param bool $return
* @param bool $prefix
* @return mixed|string
*
* @return string|string[]|bool
*/
public static function getMessage(?Player $sender, $key, bool $return = false, $prefix = true) {
public static function getMessage(?Player $sender, string $key, bool $return = false, $prefix = true) {
$locale = Settings::getDefaultLang();
if(isset(self::$translation[strtolower($sender->getLocale())])) {
$locale = $sender->getLocale();
Expand Down

0 comments on commit f21ea9e

Please sign in to comment.