phpstan support (#250)

* phpstan v1 + workflow

* Fix intend

* More fixes

* Update phpstan.neon

* phpstan level 2

* Move errors ignoring into phpstan.neon

* phpstan level 3

* Don't ignore templates folder

* Something from level 4

* Update phpstan.neon
This commit is contained in:
Slawomir Boczek
2024-02-18 14:59:25 +01:00
committed by GitHub
parent e23a749e4c
commit fe7ad61abe
21 changed files with 157 additions and 22 deletions

View File

@@ -418,7 +418,10 @@ function delete_guild($id)
if(count($rank_list) > 0) {
$rank_list->orderBy('level');
global $db, $ots;
global $db;
/**
* @var OTS_GuildRank $rank_in_guild
*/
foreach($rank_list as $rank_in_guild) {
if($db->hasTable('guild_members'))
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `guild_members`.`rank_id` as `rank_id` FROM `players`, `guild_members` WHERE `guild_members`.`rank_id` = ' . $rank_in_guild->getId() . ' AND `players`.`id` = `guild_members`.`player_id` ORDER BY `name`;');
@@ -710,11 +713,8 @@ function getSkillName($skillId, $suffix = true)
/**
* Performs flag check on the current logged in user.
* Table in database: accounts, field: website_flags
*
* @param int @flag Flag to be verified.
* @return bool If user got flag.
*/
function hasFlag($flag) {
function hasFlag(int $flag): bool {
global $logged, $logged_flags;
return ($logged && ($logged_flags & $flag) == $flag);
}

View File

@@ -55,7 +55,7 @@ elseif($action == 'step1' && $action_type == 'email')
</TD></TR></FORM></TABLE></TABLE>';
else
{
$insec = $account->getCustomField('email_next') - time();
$insec = (int)$account->getCustomField('email_next') - time();
$minutesleft = floor($insec / 60);
$secondsleft = $insec - ($minutesleft * 60);
$timeleft = $minutesleft.' minutes '.$secondsleft.' seconds';
@@ -118,7 +118,7 @@ elseif($action == 'sendcode')
}
else
{
$insec = $account->getCustomField('email_next') - time();
$insec = (int)$account->getCustomField('email_next') - time();
$minutesleft = floor($insec / 60);
$secondsleft = $insec - ($minutesleft * 60);
$timeleft = $minutesleft.' minutes '.$secondsleft.' seconds';

View File

@@ -23,9 +23,15 @@ $guilds_list = new OTS_Guilds_List();
$guilds_list->init();
if(count($guilds_list) > 0)
{
/**
* @var OTS_Guild $guild
*/
foreach($guilds_list as $guild)
{
$error = 0;
/**
* @var OTS_Player $leader
*/
$leader = $guild->getOwner();
if($leader->isLoaded())
{

View File

@@ -117,6 +117,9 @@ if(isset($todo) && $todo == 'save')
$ranks = $new_guild->getGuildRanksList();
$ranks->orderBy('level', POT::ORDER_DESC);
foreach($ranks as $rank) {
/**
* @var OTS_GuildRank $rank
*/
if($rank->getLevel() == 3) {
$player->setRank($rank);
}

View File

@@ -19,6 +19,9 @@ $guilds_list->orderBy("name");
$guilds = array();
if(count($guilds_list) > 0)
{
/**
* @var OTS_Guild $guild
*/
foreach ($guilds_list as $guild) {
$guild_logo = $guild->getCustomField('logo_name');
if (empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))

View File

@@ -39,13 +39,13 @@ else {
if($i == 1) {
if($count <= 4)
$killers_string .= 'killed';
else if($count > 4 and $count < 10)
else if($count < 10)
$killers_string .= 'slain';
else if($count > 9 and $count < 15)
else if($count < 15)
$killers_string .= 'crushed';
else if($count > 14 and $count < 20)
else if($count < 20)
$killers_string .= 'eliminated';
else if($count > 19)
else
$killers_string .= 'annihilated';
$killers_string .= ' at level <b>' . $death['level'] . '</b> ';
} else if($i == $count)

View File

@@ -236,7 +236,7 @@ else {
// parse for define PAGE
$tmp = BASE_DIR;
$uri = $_SERVER['REQUEST_URI'];
if (!empty($tmp)) {
if (strlen($tmp) > 0) {
$uri = str_replace(BASE_DIR . '/', '', $uri);
}

View File

@@ -25,7 +25,7 @@ class CsrfToken
*
* @access public
* @static true
* @return void
* @return string
**/
public static function create(bool $return = false): string {
$input = '<input type="hidden" name="csrf_token" value="' . self::get() . '" />';

View File

@@ -4,6 +4,14 @@ namespace MyAAC\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property int $type
* @property int $where
* @property string $body
* @property int $player_id
* @property int $date
*/
class Changelog extends Model {
protected $table = TABLE_PREFIX . 'changelog';

View File

@@ -3,6 +3,13 @@
namespace MyAAC\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $name
* @property string $title
* @property int $php
* @property int $hide
*/
class Pages extends Model {
protected $table = TABLE_PREFIX . 'pages';

View File

@@ -3,6 +3,11 @@
namespace MyAAC\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $name
* @property string $key
* @property string $value
*/
class Settings extends Model {
protected $table = TABLE_PREFIX . 'settings';

View File

@@ -141,8 +141,8 @@ class Validator
* Validate account password
* Name lenght must be 3-32 chars
*
* @param string $name Account name to check
* @return bool Is account name valid?
* @param string $password Password to check
* @return bool Is password valid?
*/
public static function password($password)
{

View File

@@ -102,6 +102,9 @@ if($status_interval && $status_timeout < $status_interval) {
$status_timeout = $status_interval;
}
/**
* @var int $status_timeout
*/
if($status['lastCheck'] + $status_timeout < time()) {
updateStatus();
}

View File

@@ -171,8 +171,6 @@ function get_template_menus() {
$new_menus = array();
/**
* @var array $configMenuCategories
* @var int $id
* @var array $options
*/
$configMenuCategories = config('menu_categories');
if($configMenuCategories === null) {