Issues (1369)

market.php (13 issues)

1
<?php
2
3
/**
4
 * market.php
5
 *
6
 * Black market
7
 *
8
 * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws
9
 *
10
 */
11
12
require_once('common.' . substr(strrchr(__FILE__, '.'), 1));
13
14
define('SN_IN_MARKET', true);
15
16
lng_include('market');
17
lng_include('fleet');
18
19
$mode = sys_get_param_int('mode');
20
$action = sys_get_param_int('action');
21
$shipList = $_POST['ships'];
22
23
$page_title = "{$lang['eco_mrk_title']}";
24
25
$stock = sys_unit_str2arr(SN::$config->eco_stockman_fleet);
0 ignored issues
show
Bug Best Practice introduced by
The property eco_stockman_fleet does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
$newstock = $stock;
27
$intError = MARKET_DEAL;
28
29
switch($mode)
30
{
31
  case MARKET_RESOURCES: // Resource trader
32
    require('includes/includes/market_trader.inc');
33
    $template = eco_mrk_trader($user, $planetrow);
0 ignored issues
show
Are you sure the assignment to $template is correct as eco_mrk_trader($user, $planetrow) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
  break;
35
36
  case MARKET_SCRAPPER: // Fleet scraper
37
    $rpg_cost = SN::$config->rpg_cost_scraper;
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_scraper does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
38
    $submode = 'scraper';
39
    $error_no_stock = MARKET_NO_SHIPS;
40
    $error_zero_res = MARKET_ZERO_RES;
0 ignored issues
show
The constant MARKET_ZERO_RES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41
42
    $config_rpg_scrape_metal     = SN::$config->rpg_scrape_metal;
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_scrape_metal does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
    $config_rpg_scrape_crystal   = SN::$config->rpg_scrape_crystal;
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_scrape_crystal does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
44
    $config_rpg_scrape_deuterium = SN::$config->rpg_scrape_deuterium;
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_scrape_deuterium does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
45
46
    $array = sn_get_groups('fleet');
47
48
    require('includes/includes/market_fleeter.inc');
49
  break;
50
51
  case MARKET_STOCKMAN: // S/H ship seller
52
    $rpg_cost = SN::$config->rpg_cost_stockman;
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_stockman does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
53
    $submode = 'stockman';
54
    $error_no_stock = MARKET_NO_STOCK;
55
    $error_zero_res = MARKET_ZERO_RES_STOCK;
56
57
    $config_rpg_scrape_metal     = 1 / SN::$config->rpg_scrape_metal;
58
    $config_rpg_scrape_crystal   = 1 / SN::$config->rpg_scrape_crystal;
59
    $config_rpg_scrape_deuterium = 1 / SN::$config->rpg_scrape_deuterium;
60
61
    $array = &$stock;
62
63
    require('includes/includes/market_fleeter.inc');
64
  break;
65
66
  case MARKET_INFO: // Infotrader
67
    require('includes/includes/market_info.inc');
68
  break;
69
70
  case MARKET_EXCHANGE: // Cross-player resource exchange
71
  break;
72
73
  case MARKET_BANKER: // Banker
74
  break;
75
76
  case MARKET_PAWNSHOP: // Pawnshop
77
  break;
78
79
  default:
80
    $template = SnTemplate::gettemplate('market', true);
0 ignored issues
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

80
    $template = SnTemplate::gettemplate('market', /** @scrutinizer ignore-type */ true);
Loading history...
81
  break;
82
}
83
84
$message_id = sys_get_param_int('message');
85
if($message_id != MARKET_NOTHING)
86
{
87
  $template->assign_block_vars('result', array('MESSAGE' => $lang['eco_mrk_errors'][$message_id]));
88
}
89
90
if($message)
91
{
92
  $template->assign_block_vars('result', array('MESSAGE' => $message));
93
}
94
95
$template->assign_vars(array(
96
  'rpg_cost_trader'   => SN::$config->rpg_cost_trader,
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_trader does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
97
  'rpg_cost_scraper'  => SN::$config->rpg_cost_scraper,
98
  'rpg_cost_stockman' => SN::$config->rpg_cost_stockman,
99
  'rpg_cost_info'     => SN::$config->rpg_cost_info,
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_info does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
100
101
  'rpg_cost_banker'   => SN::$config->rpg_cost_banker,
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_banker does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
102
  'rpg_cost_exchange' => SN::$config->rpg_cost_exchange,
103
  'rpg_cost_pawnshop' => SN::$config->rpg_cost_pawnshop,
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_pawnshop does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
104
105
//  'message' => $message,
106
  'MODE' => $mode
107
));
108
109
SnTemplate::display($template, $page_title);
110