Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 4a0a24b

Browse files
fix phpstan
1 parent c9b906b commit 4a0a24b

11 files changed

Lines changed: 23 additions & 21 deletions

src/FactionMasterAdminTools.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function onLoad(): void {
7272
$this->saveResource('fr_FR.yml');
7373
$this->saveResource('en_EN.yml');
7474
$this->saveResource('config.yml');
75-
$this->config = new Config($this->getDataFolder() . "config.yml");
76-
ConfigUpdater::checkUpdate($this, $this->config, "file-version", 1);
75+
$this->reloadConfig();
76+
ConfigUpdater::checkUpdate($this, $this->getConfig(), "file-version", 1);
7777
ConfigUpdater::checkUpdate($this, new Config($this->getDataFolder() . "fr_FR.yml", Config::YAML), "file-version", 2);
7878
ConfigUpdater::checkUpdate($this, new Config($this->getDataFolder() . "en_EN.yml", Config::YAML), "file-version", 2);
7979
$this->langConfig = [

src/Route/AdminToolsMain.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
namespace ShockedPlot7560\FactionMasterAdminTools\Route;
3434

3535
use pocketmine\player\Player;
36-
use ShockedPlot7560\FactionMaster\Button\Collection\Collection;
3736
use ShockedPlot7560\FactionMaster\Button\Collection\CollectionFactory;
3837
use ShockedPlot7560\FactionMaster\Database\Entity\UserEntity;
3938
use ShockedPlot7560\FactionMaster\libs\Vecnavium\FormsUI\SimpleForm;
@@ -47,11 +46,6 @@
4746
class AdminToolsMain extends RouteBase {
4847
const SLUG = "adminToolsMain";
4948

50-
/** @var UserEntity */
51-
private $UserEntity;
52-
/** @var Collection */
53-
private $Collection;
54-
5549
public function getSlug(): string {
5650
return self::SLUG;
5751
}

src/Route/ClaimSelect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public function call() : callable {
102102
return;
103103
}
104104
if (!$this->menuActive) {
105-
return Utils::processMenu($this->getBackRoute(), $player);
105+
Utils::processMenu($this->getBackRoute(), $player);
106+
return;
106107
}
107108
call_user_func($this->getCallable(), $this->getTargetFaction(), $this->optionsBis[$data[0]]->id);
108109
};

src/Route/DeleteClaim.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function call() : callable {
7979
return;
8080
}
8181
$userEntity = $this->getUserEntity();
82-
return Utils::processMenu(RouterFactory::get(ClaimSelect::SLUG), $player, [
82+
Utils::processMenu(RouterFactory::get(ClaimSelect::SLUG), $player, [
8383
$data[1],
8484
function (string $factionName, int $factionClaim) use ($player, $userEntity) {
8585
FactionMasterAdminTools::getInstance()->getServer()->getAsyncPool()->submitTask(

src/Route/DeleteHome.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function call() : callable {
7676
if ($data === null) {
7777
return;
7878
}
79-
return Utils::processMenu(RouterFactory::get(HomeSelect::SLUG), $player, [
79+
Utils::processMenu(RouterFactory::get(HomeSelect::SLUG), $player, [
8080
$data[1],
8181
function (string $factionName, string $homeName) use ($player) {
8282
MainAPI::removeHome($factionName, $homeName);

src/Route/DeleteInvitation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use ShockedPlot7560\FactionMaster\Task\MenuSendTask;
4545
use ShockedPlot7560\FactionMaster\Utils\Utils;
4646
use ShockedPlot7560\FactionMasterAdminTools\PermissionConstant;
47+
use function count;
4748

4849
class DeleteInvitation extends RouteBase {
4950
const SLUG = "deleteInvitationPanel";
@@ -86,9 +87,10 @@ public function call() : callable {
8687
if (isset($invitation[0]) && $invitation[0] instanceof InvitationEntity) {
8788
$invitation = $invitation[0];
8889
MainAPI::removeInvitation($invitation->getSenderString(), $invitation->getReceiverString(), $invitation->getType());
90+
$count = count(MainAPI::getInvitationsBySender($invitation->getSenderString(), $invitation->getType()));
8991
Utils::newMenuSendTask(new MenuSendTask(
90-
function () use ($invitation) {
91-
return !MainAPI::getInvitationsBySender($invitation->getSenderString(), $invitation->getType()) instanceof InvitationEntity;
92+
function () use ($invitation, $count) {
93+
return count(MainAPI::getInvitationsBySender($invitation->getSenderString(), $invitation->getType())) === $count - 1;
9294
},
9395
function () use ($player, $invitation) {
9496
(new InvitationDeleteEvent($player, $invitation, true))->call();

src/Route/HomeSelect.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ public function __invoke(Player $player, UserEntity $userEntity, array $userPerm
101101
throw new InvalidArgumentException("Third parameter of params must be an instance of Route");
102102
}
103103
if ($this->getTargetFaction() === "") {
104-
return Utils::processMenu($this->getBackRoute(), $player);
104+
Utils::processMenu($this->getBackRoute(), $player);
105+
return;
105106
}
106107
if (isset($params[0]) && $params[0] == "") {
107-
return Utils::processMenu($this->getBackRoute(), $player);
108+
Utils::processMenu($this->getBackRoute(), $player);
109+
return;
108110
}
109111
$player->sendForm($this->getForm());
110112
}
@@ -115,7 +117,8 @@ public function call() : callable {
115117
return;
116118
}
117119
if (!$this->isMenuActive() || $data[0] === "") {
118-
return Utils::processMenu($this->getBackRoute(), $player);
120+
Utils::processMenu($this->getBackRoute(), $player);
121+
return;
119122
}
120123
call_user_func($this->getCallable(), $this->getTargetFaction(), $this->optionsBis[$data[0]]);
121124
};

src/Route/TpClaim.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function call() : callable {
7676
if ($data === null) {
7777
return;
7878
}
79-
return Utils::processMenu(RouterFactory::get(ClaimSelect::SLUG), $player, [
79+
Utils::processMenu(RouterFactory::get(ClaimSelect::SLUG), $player, [
8080
$data[1],
8181
function (string $factionName, int $factionClaim) use ($player) {
8282
$targetClaim = null;

src/Route/TpHome.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function call() : callable {
7676
if ($data === null) {
7777
return;
7878
}
79-
return Utils::processMenu(RouterFactory::get(HomeSelect::SLUG), $player, [
79+
Utils::processMenu(RouterFactory::get(HomeSelect::SLUG), $player, [
8080
$data[1],
8181
function (string $factionName, string $homeName) use ($player) {
8282
$home = MainAPI::getFactionHome($factionName, $homeName);

src/Route/UpdateFaction.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ public function __invoke(Player $player, UserEntity $userEntity, array $userPerm
9494
throw new InvalidArgumentException("Third parameter of params must be an instance of Route");
9595
}
9696
if ($this->getTargetFaction() === "") {
97-
return Utils::processMenu($this->getBackRoute(), $player);
97+
Utils::processMenu($this->getBackRoute(), $player);
98+
return;
9899
}
99100
if (!MainAPI::getFaction($this->getTargetFaction()) instanceof FactionEntity) {
100-
return Utils::processMenu($this->getBackRoute(), $player, [Utils::getText($player->getName(), "FACTION_DONT_EXIST")]);
101+
Utils::processMenu($this->getBackRoute(), $player, [Utils::getText($player->getName(), "FACTION_DONT_EXIST")]);
102+
return;
101103
}
102104
$player->sendForm($this->getForm());
103105
}

0 commit comments

Comments
 (0)