From a2c8e2b2aeef2e9970acaa75ba5644a7f414e8ce Mon Sep 17 00:00:00 2001 From: slawkens Date: Wed, 31 Jan 2024 00:36:15 +0100 Subject: [PATCH] phpstan: level 1 passed --- admin/pages/accounts.php | 2 +- admin/pages/news.php | 4 ++-- admin/pages/players.php | 2 +- system/pages/bans.php | 2 +- system/pages/guilds/add_rank.php | 8 ++------ system/pages/houses.php | 2 +- system/src/Commands/CronjobInstallCommand.php | 2 +- system/src/CreateCharacter.php | 2 +- system/src/Models/Account.php | 8 ++++++-- system/src/Models/Player.php | 7 +++++++ 10 files changed, 23 insertions(+), 16 deletions(-) diff --git a/admin/pages/accounts.php b/admin/pages/accounts.php index 4d410f11..34b3941b 100644 --- a/admin/pages/accounts.php +++ b/admin/pages/accounts.php @@ -291,7 +291,7 @@ else if (isset($_REQUEST['search'])) {
-
+
diff --git a/admin/pages/news.php b/admin/pages/news.php index ab57a7f3..d74d6405 100644 --- a/admin/pages/news.php +++ b/admin/pages/news.php @@ -146,8 +146,8 @@ foreach ($query as $_news) { 'archive_link' => getLink('news') . '/archive/' . $_news['id'], 'title' => $_news['title'], 'date' => $_news['date'], - 'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '', - 'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '', + 'player_name' => $_player->isLoaded() ? $_player->getName() : '', + 'player_link' => $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '', ); } diff --git a/admin/pages/players.php b/admin/pages/players.php index 1fa3bf19..4febcdb5 100644 --- a/admin/pages/players.php +++ b/admin/pages/players.php @@ -375,7 +375,7 @@ else if (isset($_REQUEST['search'])) {
- +
diff --git a/system/pages/bans.php b/system/pages/bans.php index d2a69f47..349bebda 100644 --- a/system/pages/bans.php +++ b/system/pages/bans.php @@ -27,7 +27,7 @@ $configBans = []; $configBans['hasType'] = false; $configBans['hasReason'] = false; -$limit = 'LIMIT ' . ($configBansPerPage + 1) . (isset($offset) ? ' OFFSET ' . $offset : ''); +$limit = 'LIMIT ' . ($configBansPerPage + 1) . ' OFFSET ' . $offset; if ($db->hasTable('account_bans')) { $bansQuery = $db->query('SELECT * FROM `account_bans` ORDER BY `banned_at` DESC ' . $limit); } diff --git a/system/pages/guilds/add_rank.php b/system/pages/guilds/add_rank.php index acb65aea..0c510bb1 100644 --- a/system/pages/guilds/add_rank.php +++ b/system/pages/guilds/add_rank.php @@ -67,13 +67,9 @@ if(empty($errors)) { } else { - if(!empty($errors)) { - $twig->display('error_box.html.twig', array('errors' => $errors)); + $twig->display('error_box.html.twig', array('errors' => $errors)); - $twig->display('guilds.back_button.html.twig', array( + $twig->display('guilds.back_button.html.twig', array( 'new_line' => true )); - } } - -?> diff --git a/system/pages/houses.php b/system/pages/houses.php index f548d23b..6e948d51 100644 --- a/system/pages/houses.php +++ b/system/pages/houses.php @@ -101,7 +101,7 @@ if(isset($_GET['page']) && $_GET['page'] == 'view' && isset($_REQUEST['house'])) 'houseSize' => isset($house['size']) ? $house['size'] : null, 'houseRent' => isset($house['rent']) ? $house['rent'] : null, 'owner' => isset($owner) ? $owner : null, - 'rentType' => isset($rentType) ? $rentType : null + 'rentType' => $rentType )); if (count($errors) > 0) { diff --git a/system/src/Commands/CronjobInstallCommand.php b/system/src/Commands/CronjobInstallCommand.php index b8d48505..adcf8b20 100644 --- a/system/src/Commands/CronjobInstallCommand.php +++ b/system/src/Commands/CronjobInstallCommand.php @@ -47,7 +47,7 @@ class CronjobInstallCommand extends Command { exec('crontab -l', $crontab); - if(isset($crontab) && is_array($crontab)) { + if(is_array($crontab)) { $crontab = array_flip($crontab); if(isset($crontab[$command])){ diff --git a/system/src/CreateCharacter.php b/system/src/CreateCharacter.php index 62168f23..446ed160 100644 --- a/system/src/CreateCharacter.php +++ b/system/src/CreateCharacter.php @@ -73,7 +73,7 @@ class CreateCharacter * @param array $errors * @return bool */ - public function check($name, $sex, &$vocation, &$town, &$errors) + public function check($name, $sex, ?int &$vocation, ?int &$town, &$errors) { $this->checkName($name, $errors); diff --git a/system/src/Models/Account.php b/system/src/Models/Account.php index f26f9700..613b3029 100644 --- a/system/src/Models/Account.php +++ b/system/src/Models/Account.php @@ -4,6 +4,10 @@ namespace MyAAC\Models; use Illuminate\Database\Eloquent\Model; +/** + * @property integer $lastday + * @property integer $premdays + */ class Account extends Model { protected $table = 'accounts'; @@ -46,8 +50,8 @@ class Account extends Model { return 65535; } - $ret = ceil($this->premdays - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday))); - return $ret > 0 ? $ret : 0; + $ret = ceil($this->premdays - ((int)date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday))); + return max($ret, 0); } public function getIsPremiumAttribute() diff --git a/system/src/Models/Player.php b/system/src/Models/Player.php index 2e49b678..0f8811d1 100644 --- a/system/src/Models/Player.php +++ b/system/src/Models/Player.php @@ -2,7 +2,14 @@ namespace MyAAC\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasOne; +/** + * @property int $level + * @property int $vocation + * @property int $online + * @property hasOne $onlineTable + */ class Player extends Model { protected $table = 'players';