supernova-ws /
SuperNova
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
| 4 | |||
| 5 | if(sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG')) |
||
| 6 | { |
||
| 7 | define('BE_DEBUG', true); |
||
| 8 | } |
||
| 9 | |||
| 10 | require_once('includes/includes/coe_simulator_helpers.php'); |
||
| 11 | |||
| 12 | $replay = $_GET['replay'] ? $_GET['replay'] : $_POST['replay']; |
||
| 13 | $execute = intval($_GET['execute']); |
||
| 14 | $sym_defender = $_POST['defender'] ? $_POST['defender'] : array(); |
||
| 15 | $sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array(); |
||
| 16 | |||
| 17 | if($replay) |
||
| 18 | { |
||
| 19 | $unpacked = sn_ube_simulator_decode_replay($replay); |
||
| 20 | |||
| 21 | $sym_defender = $unpacked['D']; |
||
| 22 | $sym_attacker = $unpacked['A']; |
||
| 23 | } |
||
| 24 | else |
||
| 25 | { |
||
| 26 | $sym_defender = array(0 => $sym_defender); |
||
| 27 | $sym_attacker = array(1 => $sym_attacker); |
||
| 28 | } |
||
| 29 | |||
| 30 | if($_POST['submit'] || $execute) |
||
| 31 | { |
||
| 32 | $replay = sn_ube_simulator_encode_replay($sym_defender, 'D'); |
||
| 33 | $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A'); |
||
| 34 | |||
| 35 | require_once('classes/UBE/UBE.php'); |
||
| 36 | UBE::display_simulator($sym_attacker, $sym_defender); |
||
| 37 | } |
||
| 38 | else |
||
| 39 | { |
||
| 40 | $template = gettemplate('simulator', true); |
||
| 41 | $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL); |
||
| 42 | |||
| 43 | foreach($techs_and_officers as $tech_id) |
||
| 44 | { |
||
| 45 | if(!$sym_attacker[1][$tech_id]) |
||
| 46 | { |
||
| 47 | $sym_attacker[1][$tech_id] = mrc_get_level($user, null, $tech_id); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | $show_groups = array( |
||
| 52 | UNIT_TECHNOLOGIES => array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), |
||
| 53 | UNIT_MERCENARIES => array(MRC_ADMIRAL), |
||
| 54 | UNIT_SHIPS => classSupernova::$gc->groupFleet, |
||
| 55 | UNIT_RESOURCES => sn_get_groups('resources_loot'), |
||
| 56 | UNIT_GOVERNORS => array(MRC_FORTIFIER), |
||
| 57 | UNIT_DEFENCE => sn_get_groups('defense_active'), |
||
| 58 | ); |
||
| 59 | foreach($show_groups as $unit_group_id => $unit_group) |
||
| 60 | { |
||
| 61 | $template->assign_block_vars('simulator', array( |
||
| 62 | 'GROUP' => $unit_group_id, |
||
| 63 | 'NAME' => classLocale::$lang['tech'][$unit_group_id], |
||
| 64 | )); |
||
| 65 | |||
| 66 | foreach($unit_group as $unit_id) |
||
|
0 ignored issues
–
show
|
|||
| 67 | { |
||
| 68 | $tab++; |
||
| 69 | |||
| 70 | $value = mrc_get_level($user, $planetrow, $unit_id); |
||
| 71 | |||
| 72 | $template->assign_block_vars('simulator', array( |
||
| 73 | 'NUM' => $tab < 9 ? "0{$tab}" : $tab, |
||
| 74 | 'ID' => $unit_id, |
||
| 75 | 'GROUP' => $unit_group_id, |
||
| 76 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
||
| 77 | 'ATTACKER' => intval($sym_attacker[1][$unit_id]), |
||
| 78 | 'DEFENDER' => intval($sym_defender[0][$unit_id]), |
||
| 79 | 'VALUE' => $value, |
||
| 80 | )); |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 | $template->assign_vars(array( |
||
| 85 | 'BE_DEBUG' => BE_DEBUG, |
||
| 86 | 'UNIT_DEFENCE' => UNIT_DEFENCE, |
||
| 87 | 'UNIT_GOVERNORS' => UNIT_GOVERNORS, |
||
| 88 | )); |
||
| 89 | |||
| 90 | display($template, classLocale::$lang['coe_combatSimulator'], false); |
||
| 91 | } |
||
| 92 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.