Skip to content

Commit

Permalink
Remove references from function arguments
Browse files Browse the repository at this point in the history
Objects are always "by reference", even without `&`.

See smrealms#317.
  • Loading branch information
hemberger committed Jun 2, 2019
1 parent 7f31ad6 commit fd70569
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion admin/Default/newsletter_send_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$mail->Subject = $_REQUEST['subject'];

function set_mail_body(&$mail, $newsletterHtml, $newsletterText, $salutation) {
function set_mail_body($mail, $newsletterHtml, $newsletterText, $salutation) {
// Prepend the salutation if one is given
if ($salutation) {
if (!empty($newsletterHtml)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Default/Menu.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class Menu {
array('Link'=>Globals::getBarBlackjackHREF(), 'Text'=>'BlackJack')));
}

static function news(&$template) {
static function news(Template $template) {
global $var;
$menuItems = array();
if (SmrSession::getGameID() == $var['GameID']) {
Expand All @@ -303,7 +303,7 @@ class Menu {
$template->assign('MenuItems', $menuItems);
}

static function navigation(&$template, &$player) {
static function navigation(Template $template, AbstractSmrPlayer $player) {
$menuItems = array();
$menuItems[] = array('Link'=>Globals::getPlotCourseHREF(), 'Text'=>'Plot A Course');
if (!$player->isLandedOnPlanet())
Expand Down
4 changes: 2 additions & 2 deletions lib/Default/Rankings.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Rankings {
private function __construct() {}

public static function &collectAllianceRankings(SmrMySqlDatabase &$db, AbstractSmrPlayer &$player, $rank) {
public static function &collectAllianceRankings(SmrMySqlDatabase $db, AbstractSmrPlayer $player, $rank) {
$rankings = array();
while ($db->nextRecord()) {
// increase rank counter
Expand All @@ -28,7 +28,7 @@ class Rankings {
return $rankings;
}

public static function &collectRankings(SmrMySqlDatabase &$db, AbstractSmrPlayer $player, $rank) {
public static function &collectRankings(SmrMySqlDatabase $db, AbstractSmrPlayer $player, $rank) {
$rankings = array();
while ($db->nextRecord()) {
// increase rank counter
Expand Down
2 changes: 1 addition & 1 deletion lib/Default/missions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const MISSIONS = array(
)
);

function checkMissionRequirements(&$values, array &$mission, AbstractSmrPlayer &$player, array &$requirements = null) {
function checkMissionRequirements(&$values, array &$mission, AbstractSmrPlayer $player, array &$requirements = null) {
if ($requirements == null) {
return checkMissionRequirements($values, $mission, $player, $mission['Task']['Detail']);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Default/news.functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ function getNewsItems(SmrMySqlDatabase $db) {
return $newsItems;
}

function doBreakingNewsAssign($gameID,&$template) {
function doBreakingNewsAssign($gameID, Template $template) {
$db = new SmrMySqlDatabase();
$db->query('SELECT * FROM news WHERE game_id = '.$db->escapeNumber($gameID).' AND type = \'breaking\' AND time > '.$db->escapeNumber(TIME - TIME_FOR_BREAKING_NEWS).' ORDER BY time DESC LIMIT 1');
if ($db->nextRecord()) {
$template->assign('BreakingNews',array('Time' => $db->getField('time'), 'Message' => bbifyMessage($db->getField('news_message'))));
}
}

function doLottoNewsAssign($gameID,&$template) {
function doLottoNewsAssign($gameID, Template $template) {
require_once(get_file_loc('bar.functions.inc'));
checkForLottoWinner($gameID);
$db = new SmrMySqlDatabase();
Expand Down
2 changes: 1 addition & 1 deletion lib/Default/shop_goods.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

function checkPortTradeable(&$port,&$player) {
function checkPortTradeable($port, $player) {
if($port->getSectorID()!=$player->getSectorID())
return 'That port is not in this sector!';

Expand Down
20 changes: 10 additions & 10 deletions tools/npc/npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function changeNPCLogin() {
throw new ForwardException;
}

function canWeUNO(AbstractSmrPlayer &$player, $oppurtunisticOnly) {
function canWeUNO(AbstractSmrPlayer $player, $oppurtunisticOnly) {
if($player->getCredits()<MINUMUM_RESERVE_CREDITS)
return false;
$ship = $player->getShip();
Expand Down Expand Up @@ -525,7 +525,7 @@ function doUNO($hardwareID,$amount) {
return create_container('shop_hardware_processing.php','',array('hardware_id'=>$hardwareID));
}

function tradeGoods($goodID,AbstractSmrPlayer &$player,SmrPort &$port) {
function tradeGoods($goodID, AbstractSmrPlayer $player, SmrPort $port) {
sleepNPC(); //We have an extra sleep at port to make the NPC more vulnerable.
$ship = $player->getShip();
$relations = $player->getRelation($port->getRaceID());
Expand All @@ -544,7 +544,7 @@ function tradeGoods($goodID,AbstractSmrPlayer &$player,SmrPort &$port) {
return create_container('shop_goods_processing.php','',array('offered_price'=>$offeredPrice,'ideal_price'=>$idealPrice,'amount'=>$amount,'good_id'=>$goodID,'bargain_price'=>$offeredPrice));
}

function dumpCargo(&$player) {
function dumpCargo($player) {
$ship = $player->getShip();
$cargo = $ship->getCargo();
debug('Ship Cargo',$cargo);
Expand All @@ -555,11 +555,11 @@ function dumpCargo(&$player) {
}
}

function plotToSector(&$player,$sectorID) {
function plotToSector($player, $sectorID) {
return create_container('course_plot_processing.php','',array('from'=>$player->getSectorID(),'to'=>$sectorID));
}

function plotToFed(&$player,$plotToHQ=false) {
function plotToFed($player, $plotToHQ=false) {
debug('Plotting To Fed',$plotToHQ);

if($plotToHQ === false && $player->getSector()->offersFederalProtection()) {
Expand All @@ -578,7 +578,7 @@ function plotToFed(&$player,$plotToHQ=false) {
// return plotToNearest($player,$plotToHQ===true?'HQ':'Fed');
}

function plotToNearest(AbstractSmrPlayer &$player, &$realX) {
function plotToNearest(AbstractSmrPlayer $player, $realX) {
debug('Plotting To: ',$realX); //TODO: Can we make the debug output a bit nicer?
if($player->getSector()->hasX($realX)) { //Check if current sector has what we're looking for before we attempt to plot and get error.
Expand All @@ -588,12 +588,12 @@ function plotToNearest(AbstractSmrPlayer &$player, &$realX) {

return create_container('course_plot_nearest_processing.php','',array('RealX'=>$realX));
}
function moveToSector(&$player,$targetSector) {
function moveToSector($player, $targetSector) {
debug('Moving from #'.$player->getSectorID().' to #'.$targetSector);
return create_container('sector_move_processing.php','',array('target_sector'=>$targetSector,'target_page'=>''));
}

function checkForShipUpgrade(AbstractSmrPlayer &$player) {
function checkForShipUpgrade(AbstractSmrPlayer $player) {
foreach(SHIP_UPGRADE_PATH[$player->getRaceID()] as $upgradeShipID) {
if($player->getShipTypeID()==$upgradeShipID) //We can't upgrade, only downgrade.
return false;
Expand All @@ -608,7 +608,7 @@ function checkForShipUpgrade(AbstractSmrPlayer &$player) {
return false;
}

function doShipUpgrade(AbstractSmrPlayer &$player,$upgradeShipID) {
function doShipUpgrade(AbstractSmrPlayer $player,$upgradeShipID) {
$plotNearest = plotToNearest($player,AbstractSmrShip::getBaseShip(Globals::getGameType($player->getGameID()),$upgradeShipID));

if($plotNearest == true) { //We're already there!
Expand Down Expand Up @@ -667,7 +667,7 @@ function leaveAlliance() {
return create_container('alliance_leave_processing.php','',array('action'=>'YES'));
}

function &findRoutes(&$player) {
function &findRoutes($player) {
debug('Finding Routes');

$tradeGoods = array(GOOD_NOTHING => false);
Expand Down

0 comments on commit fd70569

Please sign in to comment.