Skip to content

Commit

Permalink
PHPCS fixes, and phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thekabal committed Apr 9, 2020
1 parent 88d5d14 commit e5ddaf1
Show file tree
Hide file tree
Showing 103 changed files with 375 additions and 324 deletions.
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
{
$button_main = true;
$module_name = substr($filename[$i]['file'], 0, -4);
include_once './admin/'. $filename[$i]['file'];
include_once './admin/' . $filename[$i]['file'];
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin/bans_editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@
"<td><font size=2 color=white>" . $langvars['l_admin_ip_only'] . ": " . $ip . "</td>" .
"<tr><td>" .
"<input type=radio name=class value=A>" .
"<td><font size=2 color=white>" . $langvars['l_admin_class_a'] . ": " . $ipparts[0].$ipparts[1].$ipparts[2] . ".*</td>" .
"<td><font size=2 color=white>" . $langvars['l_admin_class_a'] . ": " . $ipparts[0] . $ipparts[1] . $ipparts[2] . ".*</td>" .
"<tr><td>" .
"<input type=radio name=class value=B>" .
"<td><font size=2 color=white>" . $langvars['l_admin_class_b'] . ": " . $ipparts[0].$ipparts[1] . ".*</td>" .
"<td><font size=2 color=white>" . $langvars['l_admin_class_b'] . ": " . $ipparts[0] . $ipparts[1] . ".*</td>" .
"<tr><td><td><br><input type=submit value=" . $langvars['l_admin_ban'] . ">" .
"</table>" .
"</form>";
Expand Down
2 changes: 1 addition & 1 deletion attack.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

require_once './common.php';

$login = new Tki\Login;
$login = new Tki\Login();
$login->checkLogin($pdo_db, $lang, $tkireg, $template);

$title = $langvars['l_att_title'];
Expand Down
2 changes: 1 addition & 1 deletion beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

echo "<h1>" . $title . "</h1>\n";

$login = new Tki\Login;
$login = new Tki\Login();
$login->checkLogin($pdo_db, $lang, $tkireg, $template);

// Get playerinfo from database
Expand Down
4 changes: 2 additions & 2 deletions bounty.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

require_once './common.php';

$login = new Tki\Login;
$login = new Tki\Login();
$login->checkLogin($pdo_db, $lang, $tkireg, $template);

// Database driven language entries
Expand Down Expand Up @@ -376,7 +376,7 @@
$stmt->execute();
$details = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<tr bgcolor=\"$color\">";
echo "<td><a href=bounty.php?bounty_on=" . $bounties[$i]['bounty_on'] . "&response=display>". $details['character_name'] . "</a></td>";
echo "<td><a href=bounty.php?bounty_on=" . $bounties[$i]['bounty_on'] . "&response=display>" . $details['character_name'] . "</a></td>";
echo "<td>" . $bounties[$i]['total_bounty'] . "</td>";
echo "</tr>";

Expand Down
4 changes: 2 additions & 2 deletions check_mines.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@
$resx = $db->Execute("UPDATE {$db->prefix}ships SET hull=0, engines=0, power=0, sensors=0, computer=0, beams=0, torp_launchers=0, torps=0, armor=0, armor_pts=100, cloak=0, shields=0, sector=1, ship_organics=0, ship_ore=0, ship_goods=0, ship_energy=?, ship_colonists=0, ship_fighters=100, dev_warpedit=0, dev_genesis=0, dev_beacon=0, dev_emerwarp=0, dev_escapepod='N', dev_fuelscoop='N', dev_minedeflector=0, on_planet='N', rating=?, cleared_defenses=' ', dev_lssd='N' WHERE ship_id=?", array(100, $rating, $playerinfo['ship_id']));
Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__);

$bounty = new Tki\Bounty;
$bounty = new Tki\Bounty();
$bounty->cancel($pdo_db, $playerinfo['ship_id']);
}
else
{
// Or they lose!
$bounty = new Tki\Bounty;
$bounty = new Tki\Bounty();
$bounty->cancel($pdo_db, $playerinfo['ship_id']);

$character_object = new Tki\Character();
Expand Down
2 changes: 1 addition & 1 deletion classes/Bases.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function buildBase(\PDO $pdo_db, array $langvars, int $planet_id, int $se
}

// Build a base
$rs_move = new \Tki\Realspace;
$rs_move = new \Tki\Realspace();
$rs_move->realSpaceMove($pdo_db, $langvars, $sector_id, $tkireg);
echo "<br>";
echo str_replace("[here]", "<a href='planet.php?planet_id=$planet_id'>" .
Expand Down
2 changes: 1 addition & 1 deletion classes/BigBang.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class BigBang
{
public function findStep(string $current_file) : array
public function findStep(string $current_file): array
{
$num_files = 0;

Expand Down
6 changes: 3 additions & 3 deletions classes/CalcLevels.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function energy(int $level_power, Reg $tkireg): float
return $result;
}

public static function planetBeams(\PDO $pdo_db, array $ownerinfo, Reg $tkireg, array $planetinfo) : int
public static function planetBeams(\PDO $pdo_db, array $ownerinfo, Reg $tkireg, array $planetinfo): int
{
$base_factor = ($planetinfo['base'] == 'Y') ? $tkireg->base_defense : 0;
$planetbeams = self::abstractLevels($ownerinfo['beams'] + $base_factor, $tkireg->level_factor);
Expand Down Expand Up @@ -63,7 +63,7 @@ public static function planetBeams(\PDO $pdo_db, array $ownerinfo, Reg $tkireg,
return (int) $planetbeams;
}

public static function planetShields(\PDO $pdo_db, array $ownerinfo, Reg $tkireg, array $planetinfo) : int
public static function planetShields(\PDO $pdo_db, array $ownerinfo, Reg $tkireg, array $planetinfo): int
{
$base_factor = ($planetinfo['base'] == 'Y') ? $tkireg->base_defense : 0;
$planetshields = self::abstractLevels($ownerinfo['shields'] + $base_factor, $tkireg->level_factor);
Expand Down Expand Up @@ -92,7 +92,7 @@ public static function planetShields(\PDO $pdo_db, array $ownerinfo, Reg $tkireg
return (int) $planetshields;
}

public static function planetTorps(\PDO $pdo_db, array $ownerinfo, array $planetinfo, Reg $tkireg) : int
public static function planetTorps(\PDO $pdo_db, array $ownerinfo, array $planetinfo, Reg $tkireg): int
{
$base_factor = ($planetinfo['base'] == 'Y') ? $tkireg->base_defense : 0;
$torp_launchers = round(pow($tkireg->level_factor, ($ownerinfo['torp_launchers']) + $base_factor)) * 10;
Expand Down
4 changes: 2 additions & 2 deletions classes/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function kill(\PDO $pdo_db, int $ship_id, array $langvars, Reg $tkireg, b
$stmt->execute();
$name = $stmt->fetch(\PDO::FETCH_ASSOC);

$headline = $name['character_name'] .' '. $langvars['l_killheadline'];
$headline = $name['character_name'] . ' ' . $langvars['l_killheadline'];
$newstext = str_replace('[name]', $name['character_name'], $langvars['l_news_killed']);

$sql = "INSERT INTO ::prefix::news (headline, newstext, user_id, date, news_type) " .
Expand All @@ -97,7 +97,7 @@ public function kill(\PDO $pdo_db, int $ship_id, array $langvars, Reg $tkireg, b
$stmt->execute();
}

public function getInsignia(\PDO $pdo_db, string $a_username, array $langvars) : string
public function getInsignia(\PDO $pdo_db, string $a_username, array $langvars): string
{
// Lookup players score.
$players_gateway = new Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
Expand Down
2 changes: 1 addition & 1 deletion classes/Combat.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public static function shipToShip(\PDO $pdo_db, array $langvars, int $ship_id, R
else
{
\Tki\PlayerLog::writeLog($pdo_db, $targetinfo['ship_id'], LogEnums::ATTACK_LOSE, "$playerinfo[character_name]|N");
$character_object = new Character;
$character_object = new Character();
$character_object->kill($pdo_db, $targetinfo['ship_id'], $langvars, $tkireg, false);
\Tki\Bounty::collect($pdo_db, $langvars, $playerinfo['ship_id'], $targetinfo['ship_id']);
}
Expand Down
8 changes: 4 additions & 4 deletions classes/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class Db
{
public static function isActive(\PDO $pdo_db) : bool
public static function isActive(\PDO $pdo_db): bool
{
// Get the config_values from the DB
$results = $pdo_db->query("SELECT * FROM ::prefix::gameconfig LIMIT 1");
Expand Down Expand Up @@ -82,7 +82,7 @@ public function initDb(string $db_layer)
// However ADOdb's postgres driver returns null if postgres insn't installed.
if ($db_init_result === false || $db_init_result === 0)
{
throw new \Exception;
throw new \Exception();
}
else
{
Expand All @@ -97,7 +97,7 @@ public function initDb(string $db_layer)
{
// We need to display the error message onto the screen.
$err_msg = 'The Kabal Invasion - General error: Unable to connect to the ' . $db_type .
' Database. <br>Database Error: '. $db->ErrorNo();
' Database. <br>Database Error: ' . $db->ErrorNo();
throw new \Exception($err_msg);
}

Expand Down Expand Up @@ -127,7 +127,7 @@ public function initDb(string $db_layer)
catch (\PDOException $e)
{
$err_msg = 'The Kabal Invasion - General error: Unable to connect to the ' . $db_type .
' Database. <br>Database Error: '. $e->getMessage();
' Database. <br>Database Error: ' . $e->getMessage();
throw new \Exception($err_msg);
}

Expand Down
8 changes: 4 additions & 4 deletions classes/Defense.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static function defenseVsDefense(\PDO $pdo_db, int $ship_id, array $langv
$stmt->bindParam(':defense_id', $tmp_defense['sector_id'], \PDO::PARAM_INT);
$stmt->execute();

PlayerLog::writeLog($pdo_db, $tmp_other_defense['ship_id'], LogEnums::DEFS_DESTROYED, $tmp_other_defense['quantity'] .'|'. $targetdeftype .'|'. $tmp_defense['sector_id']);
PlayerLog::writeLog($pdo_db, $tmp_defense['ship_id'], LogEnums::DEFS_DESTROYED, $tmp_other_defense['quantity'] .'|'. $deftype .'|'. $tmp_defense['sector_id']);
PlayerLog::writeLog($pdo_db, $tmp_other_defense['ship_id'], LogEnums::DEFS_DESTROYED, $tmp_other_defense['quantity'] . '|' . $targetdeftype . '|' . $tmp_defense['sector_id']);
PlayerLog::writeLog($pdo_db, $tmp_defense['ship_id'], LogEnums::DEFS_DESTROYED, $tmp_other_defense['quantity'] . '|' . $deftype . '|' . $tmp_defense['sector_id']);
}
else
{
Expand All @@ -81,8 +81,8 @@ public static function defenseVsDefense(\PDO $pdo_db, int $ship_id, array $langv
$stmt->bindParam(':defense_id', $tmp_other_defense['defense_id'], \PDO::PARAM_INT);
$stmt->execute();

PlayerLog::writeLog($pdo_db, $tmp_other_defense['ship_id'], LogEnums::DEFS_DESTROYED, $qty .'|'. $targetdeftype .'|'. $tmp_defense['sector_id']);
PlayerLog::writeLog($pdo_db, $tmp_defense['ship_id'], LogEnums::DEFS_DESTROYED, $qty .'|'. $deftype .'|'. $tmp_defense['sector_id']);
PlayerLog::writeLog($pdo_db, $tmp_other_defense['ship_id'], LogEnums::DEFS_DESTROYED, $qty . '|' . $targetdeftype . '|' . $tmp_defense['sector_id']);
PlayerLog::writeLog($pdo_db, $tmp_defense['ship_id'], LogEnums::DEFS_DESTROYED, $qty . '|' . $deftype . '|' . $tmp_defense['sector_id']);
$qty = 0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class File
{
public static function iniToDb(\PDO $pdo_db, string $ini_file, string $ini_table, string $section, Reg $tkireg) : bool
public static function iniToDb(\PDO $pdo_db, string $ini_file, string $ini_table, string $section, Reg $tkireg): bool
{
// This is a loop, that reads a ini file, of the type variable = value.
// It will loop thru the list of the ini variables, and push them into the db.
Expand Down Expand Up @@ -119,7 +119,7 @@ public static function iniToDb(\PDO $pdo_db, string $ini_file, string $ini_table

// Very close to a drop-in replacement for parse_ini_file, although without the second parameter
// This defaults to the equivalent of "true" for the second param of parse_ini, ie, process sections
public static function betterParseIni(string $file) : array
public static function betterParseIni(string $file): array
{
$ini = file($file, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);

Expand Down
2 changes: 1 addition & 1 deletion classes/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function isGameClosed(
string $lang,
Smarty $template,
array $langvars
) : bool
): bool
{
if ($tkireg->game_closed)
{
Expand Down
2 changes: 1 addition & 1 deletion classes/IbankConsolidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static function third(\PDO $pdo_db, array $langvars, array $playerinfo, R
number_format($tcost, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']) . "</td>" .
"<tr valign=bottom>" .
"<td><a href='ibank.php?command=login'>" . $langvars['l_ibank_back'] .
"</a></td><td align=right>&nbsp;<br><a href=\"main.php\">" . $langvars['l_ibank_logout ']. "</a></td>" .
"</a></td><td align=right>&nbsp;<br><a href=\"main.php\">" . $langvars['l_ibank_logout '] . "</a></td>" .
"</tr>";

if ($minimum != 0)
Expand Down
2 changes: 1 addition & 1 deletion classes/IbankDeposit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function before(\PDO $pdo_db, string $lang, array $account, array
"</td></tr>" .
"<tr>" .
" <td height=30 colspan=2 align=left>" .
" <span style='color:\"#00ff00\";'>You can deposit only ". number_format($credit_space, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']) . " credits.</span><br>" .
" <span style='color:\"#00ff00\";'>You can deposit only " . number_format($credit_space, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']) . " credits.</span><br>" .
" </td>" .
"</tr>" .
"<tr valign=bottom>" .
Expand Down
2 changes: 1 addition & 1 deletion classes/KabalToPlanet.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function planet(\PDO $pdo_db, $db, int $planet_id, Reg $tkireg, ar
$ownerinfo = $stmt->fetch(\PDO::FETCH_ASSOC);

$base_factor = ($planetinfo['base'] == 'Y') ? $tkireg->base_defense : 0;
$character_object = new Character;
$character_object = new Character();

// Planet beams
$targetbeams = \Tki\CalcLevels::abstractLevels($ownerinfo['beams'] + $base_factor, $tkireg);
Expand Down
6 changes: 3 additions & 3 deletions classes/KabalToSecDef.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class KabalToSecDef
{
public static function secDef(\PDO $pdo_db, array $langvars, array $playerinfo, int $targetlink, Reg $tkireg): void
{
$character_object = new Character;
$character_object = new Character();

// Check for sector defenses
if ($targetlink > 0)
Expand Down Expand Up @@ -197,7 +197,7 @@ public static function secDef(\PDO $pdo_db, array $langvars, array $playerinfo,
$langvars['l_sf_sendlog2'] = str_replace("[sector]", (string) $targetlink, $langvars['l_sf_sendlog2']);
\Tki\SectorDefense::messageDefenseOwner($pdo_db, $targetlink, $langvars['l_sf_sendlog2']);

$bounty = new \Tki\Bounty;
$bounty = new \Tki\Bounty();
$bounty->cancel($pdo_db, $playerinfo['ship_id']);
$character_object->kill($pdo_db, $playerinfo['ship_id'], $langvars, $tkireg, false);
return;
Expand Down Expand Up @@ -246,7 +246,7 @@ public static function secDef(\PDO $pdo_db, array $langvars, array $playerinfo,
\Tki\SectorDefense::messageDefenseOwner($pdo_db, $targetlink, $langvars['l_chm_hewasdestroyedbyyourmines']);

// Actually kill the Kabal now
$bounty = new \Tki\Bounty;
$bounty = new \Tki\Bounty();
$bounty->cancel($pdo_db, $playerinfo['ship_id']);
$character_object->kill($pdo_db, $playerinfo['ship_id'], $langvars, $tkireg, false);

Expand Down
2 changes: 1 addition & 1 deletion classes/KabalToShip.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function ship(\PDO $pdo_db, int $ship_id, Reg $tkireg, array $play
{
$armor_lost = null;
$fighters_lost = null;
$character_object = new Character;
$character_object = new Character();

// Lookup target details
$sql = "SELECT * FROM ::prefix::ships WHERE ship_id=:ship_id";
Expand Down
2 changes: 1 addition & 1 deletion classes/Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class Languages
{
public static function listAvailable(\PDO $pdo_db, string $lang) : array
public static function listAvailable(\PDO $pdo_db, string $lang): array
{
// Get a list of supported languages
$sql = "SELECT section, name, value FROM ::prefix::languages WHERE " .
Expand Down
10 changes: 5 additions & 5 deletions classes/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class Log
{
public static function logParse(array $langvars, array $entry) : array
public static function logParse(array $langvars, array $entry): array
{
$log_list = array();
$retvalue = array();
Expand Down Expand Up @@ -351,14 +351,14 @@ public static function getLogInfo(array $log_list, ?int $log_id = null, ?string

if ($log_id < count($log_list))
{
if (array_key_exists("l_log_title_". $log_list[$log_id], $GLOBALS))
if (array_key_exists("l_log_title_" . $log_list[$log_id], $GLOBALS))
{
$title = $GLOBALS["l_log_title_". $log_list[$log_id]];
$title = $GLOBALS["l_log_title_" . $log_list[$log_id]];
}

if (array_key_exists("l_log_text_". $log_list[$log_id], $GLOBALS))
if (array_key_exists("l_log_text_" . $log_list[$log_id], $GLOBALS))
{
$text = $GLOBALS["l_log_text_". $log_list[$log_id]];
$text = $GLOBALS["l_log_text_" . $log_list[$log_id]];
}
}
}
Expand Down
Loading

0 comments on commit e5ddaf1

Please sign in to comment.