Completed
Push — trunk ( 58ab44...e5589f )
by SuperNova.WS
05:02
created

dbUpdateUsersCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 31 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
4
use Fleet\MissionExplore;
5
6
require_once('general_math.php');
7
require_once('general_compatibility.php');
8
require_once('general_params.php');
9
require_once('general_nickRender.php');
10
require_once('general_formatters.php');
11
require_once('general_validators.php');
12
require_once('general_unitFunctions.php');
13
require_once('general_playerFunctions.php');
14
require_once('general_planetFunctions.php');
15
require_once('general_urlAndHttp.php');
16
17
require_once('general_pname.php');
18
19
// HOOKS AND HANDLERS ----------------------------------------------------------------------------------------------------------------
20
/**
21
 * Function wrapping
22
 *
23
 * Due glitch in PHP 5.3.1 SuperNova is incompatible with this version
24
 * Reference: https://bugs.php.net/bug.php?id=50394
25
 *
26
 * @param string $func_name
27
 * @param array  $func_arg
28
 *
29
 * @return mixed
30
 */
31
function sn_function_call($func_name, $func_arg = array()) {
32
  global $functions; // All data in $functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>')
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
33
34
  if (is_array($functions[$func_name]) && !is_callable($functions[$func_name])) {
35
    // Chain-callable functions should be made as following:
36
    // 1. Never use incomplete calls with parameters "by default"
37
    // 2. Reserve last parameter for cumulative result
38
    // 3. Use same format for original value and cumulative result (if there is original value)
39
    // 4. Honor cumulative result
40
    // 5. Return cumulative result
41
    foreach ($functions[$func_name] as $func_chain_name) {
42
      // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту
43
      // Но для старых модулей...
44
      if (is_callable($func_chain_name)) {
45
        $result = call_user_func_array($func_chain_name, $func_arg);
46
      }
47
    }
48
  } else {
49
    // TODO: This is left for backward compatibility. Appropriate code should be rewrote!
50
    $func_name = isset($functions[$func_name]) && is_callable($functions[$func_name]) ? $functions[$func_name] : ('sn_' . $func_name);
51
    if (is_callable($func_name)) {
52
      $result = call_user_func_array($func_name, $func_arg);
53
    }
54
  }
55
56
  return $result;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $result does not seem to be defined for all execution paths leading up to this point.
Loading history...
57
}
58
59
/**
60
 * @param        $hook_list
61
 * @param        $template
62
 * @param string $hook_type - тип хука 'model' или 'view'
63
 * @param string $page_name - имя страницы, для которого должен был быть выполнен хук
64
 */
65
function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) {
66
  if (!empty($hook_list)) {
67
    foreach ($hook_list as $hook) {
68
      if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
69
        $template = call_user_func($hook_call, $template, $hook_type, $page_name);
70
      }
71
    }
72
  }
73
}
74
75
function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') {
76
  if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) {
77
    foreach ($handler_list as $function_name => $function_data) {
78
      sys_handler_add_one($functions, $function_name, $function_data, $class_module_name, $sub_type);
79
    }
80
  }
81
}
82
83
/**
84
 * Adding one handler for specific function name
85
 *
86
 * @param callable[]   $functions
87
 * @param string       $function_name
88
 * @param string|array $function_data
89
 * @param string       $class_module_name
90
 * @param string       $sub_type
91
 */
92
function sys_handler_add_one(&$functions, $function_name, $function_data, $class_module_name, $sub_type) {
93
  if (is_string($function_data)) {
94
    $override_with = &$function_data;
95
  } elseif (isset($function_data['callable'])) {
96
    $override_with = &$function_data['callable'];
97
  }
98
99
  $overwrite = $override_with[0] == '*';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $override_with does not seem to be defined for all execution paths leading up to this point.
Loading history...
100
  if ($overwrite) {
101
    $override_with = substr($override_with, 1);
102
  }
103
104
  if (($point_position = strpos($override_with, '.')) === false && $class_module_name) {
105
    $override_with = array($class_module_name, $override_with);
106
  } elseif ($point_position == 0) {
107
    $override_with = substr($override_with, 1);
108
  } elseif ($point_position > 0) {
109
    $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1));
110
  }
111
112
  if ($overwrite) {
113
    $functions[$function_name] = array();
114
  } elseif (!isset($functions[$function_name])) {
115
    $functions[$function_name] = array();
116
    $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : '');
117
    //if(is_callable($sn_function_name))
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
118
    {
119
      $functions[$function_name][] = $sn_function_name;
120
    }
121
  }
122
123
  $functions[$function_name][] = $function_data;
124
}
125
126
127
// FLEET FUNCTIONS -----------------------------------------------------------------------------------------------------
128
/**
129
 * @param MissionExplore $result
130
 *
131
 * @return MissionExplore
132
 */
133
function flt_mission_explore_addon_object($result) { return sn_function_call('flt_mission_explore_addon_object', [$result]); }
134
135
/**
136
 * @param MissionExplore $result
137
 *
138
 * @return MissionExplore
139
 */
140
function sn_flt_mission_explore_addon_object($result) {
141
  return $result;
142
}
143
144
// FILE FUNCTIONS ----------------------------------------------------------------------------------------------------------------
145
function sys_file_read($filename) {
146
  return @file_get_contents($filename);
147
}
148
149
function sys_file_write($filename, $content) {
150
  return @file_put_contents($filename, $content, FILE_APPEND);
151
}
152
153
function sn_sys_load_php_files($dir_name, $load_extension = 'php') {
154
  if (file_exists($dir_name)) {
155
    $dir = opendir($dir_name);
156
    while (($file = readdir($dir)) !== false) {
0 ignored issues
show
Bug introduced by
It seems like $dir can also be of type false; however, parameter $dir_handle of readdir() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

156
    while (($file = readdir(/** @scrutinizer ignore-type */ $dir)) !== false) {
Loading history...
157
      if ($file == '..' || $file == '.') {
158
        continue;
159
      }
160
161
      $full_filename = $dir_name . $file;
162
      $extension = substr($full_filename, -strlen($load_extension));
163
      if ($extension == $load_extension) {
164
        require_once($full_filename);
165
      }
166
    }
167
  }
168
}
169
170
171
// GLOBAL DATA FUNCTIONS -----------------------------------------------------------------------------------------------
172
/**
173
 * Simple wrapper to get base or calculated value for supplied unitSnId
174
 *
175
 * @param int  $unitSnId
176
 * @param bool $plain
177
 *
178
 * @return float|int
179
 */
180
function getValueFromStorage($unitSnId, $plain = false) {
181
  $valueObject = SN::$gc->valueStorage->getValueObject($unitSnId);
182
183
  return $plain ? $valueObject->base : $valueObject->getValue();
184
}
185
186
/**
187
 * Get game resource multiplier aka mining speed
188
 *
189
 * @param bool $plain
190
 *
191
 * @return float|int
192
 */
193
function game_resource_multiplier($plain = false) {
194
  return getValueFromStorage(UNIT_SERVER_SPEED_MINING, $plain);
0 ignored issues
show
Bug introduced by
UNIT_SERVER_SPEED_MINING of type string is incompatible with the type integer expected by parameter $unitSnId of getValueFromStorage(). ( Ignorable by Annotation )

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

194
  return getValueFromStorage(/** @scrutinizer ignore-type */ UNIT_SERVER_SPEED_MINING, $plain);
Loading history...
195
}
196
197
/**
198
 * Get game speed aka manufacturing speed
199
 *
200
 * @param bool $plain
201
 *
202
 * @return float|int
203
 */
204
function get_game_speed($plain = false) {
205
  return getValueFromStorage(UNIT_SERVER_SPEED_BUILDING, $plain);
0 ignored issues
show
Bug introduced by
UNIT_SERVER_SPEED_BUILDING of type string is incompatible with the type integer expected by parameter $unitSnId of getValueFromStorage(). ( Ignorable by Annotation )

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

205
  return getValueFromStorage(/** @scrutinizer ignore-type */ UNIT_SERVER_SPEED_BUILDING, $plain);
Loading history...
206
}
207
208
/**
209
 * Get fleet flying speed aka... hmph... fleet flying speed
210
 *
211
 * @param bool $plain
212
 *
213
 * @return float|int
214
 */
215
function flt_server_flight_speed_multiplier($plain = false) {
216
  return getValueFromStorage(UNIT_SERVER_SPEED_FLEET, $plain);
0 ignored issues
show
Bug introduced by
UNIT_SERVER_SPEED_FLEET of type string is incompatible with the type integer expected by parameter $unitSnId of getValueFromStorage(). ( Ignorable by Annotation )

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

216
  return getValueFromStorage(/** @scrutinizer ignore-type */ UNIT_SERVER_SPEED_FLEET, $plain);
Loading history...
217
}
218
219
220
/**
221
 * Получение стоимости ММ в валюте сервера
222
 *
223
 * @param bool|false $plain
224
 *
225
 * @return mixed
226
 */
227
function get_mm_cost($plain = false) {
228
  $result = null;
229
230
  return sn_function_call('get_mm_cost', array($plain, &$result));
231
}
232
233
function sn_get_mm_cost($plain = false, &$result) {
234
  return $result = SN::$config->payment_currency_exchange_mm_ ? SN::$config->payment_currency_exchange_mm_ : 20000;
235
}
236
237
/**
238
 * Получение курса обмены валюты в серверную валюту
239
 *
240
 * @param $currency_symbol
241
 *
242
 * @return float
243
 */
244
function get_exchange_rate($currency_symbol) {
245
  $currency_symbol = strtolower($currency_symbol);
246
  $config_field = 'payment_currency_exchange_' . $currency_symbol;
247
248
  // Заворачиваем получение стоимости ММ через перекрываемую процедуру
249
  $exchange_rate = floatval($currency_symbol == 'mm_' ? get_mm_cost() : SN::$config->$config_field);
250
251
  return $exchange_rate;
252
}
253
254
function sys_stat_get_user_skip_list() {
255
  $result = array();
256
257
  $user_skip_list = array();
258
259
  if (SN::$config->stats_hide_admins) {
260
    $user_skip_list[] = '`authlevel` > ' . AUTH_LEVEL_REGISTERED;
261
  }
262
263
  if (SN::$config->stats_hide_player_list) {
264
    $temp = explode(',', SN::$config->stats_hide_player_list);
265
    foreach ($temp as $user_id) {
266
      if ($user_id = floatval($user_id)) {
267
        $user_skip_list[] = '`id` = ' . $user_id;
268
      }
269
    }
270
  }
271
272
  if (!empty($user_skip_list)) {
273
    $user_skip_list = implode(' OR ', $user_skip_list);
274
    $user_skip_query = db_user_list($user_skip_list);
0 ignored issues
show
Deprecated Code introduced by
The function db_user_list() has been deprecated. ( Ignorable by Annotation )

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

274
    $user_skip_query = /** @scrutinizer ignore-deprecated */ db_user_list($user_skip_list);
Loading history...
275
    if (!empty($user_skip_query)) {
276
      foreach ($user_skip_query as $user_skip_row) {
277
        $result[$user_skip_row['id']] = $user_skip_row['id'];
278
      }
279
    }
280
  }
281
282
  return $result;
283
}
284
285
function market_get_autoconvert_cost() {
286
  return SN::$config->rpg_cost_exchange ? SN::$config->rpg_cost_exchange * 3 : 3000;
0 ignored issues
show
Bug Best Practice introduced by
The property rpg_cost_exchange does not exist on classConfig. Since you implemented __get, consider adding a @property annotation.
Loading history...
287
}
288
289
function sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false) {
290
  $result = null;
291
292
  return sn_function_call('sn_powerup_get_price_matrix', array($powerup_id, $powerup_unit, $level_max, $plain, &$result));
293
}
294
295
function sn_sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false, &$result) {
296
  global $sn_powerup_buy_discounts;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
297
298
  $result = array();
299
300
  $powerup_data = get_unit_param($powerup_id);
301
  $is_upgrade = !empty($powerup_unit) && $powerup_unit;
302
303
  $level_current = $term_original = $time_left = 0;
304
  if ($is_upgrade) {
305
    $time_finish = strtotime($powerup_unit['unit_time_finish']);
306
    $time_left = max(0, $time_finish - SN_TIME_NOW);
307
    if ($time_left > 0) {
308
      $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']);
309
      $level_current = $powerup_unit['unit_level'];
310
    }
311
  }
312
313
  $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK];
314
  $original_cost = 0;
315
  for ($i = 1; $i <= $level_max; $i++) {
316
    $base_cost = eco_get_total_cost($powerup_id, $i);
317
    $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER];
318
    foreach ($sn_powerup_buy_discounts as $period => $discount) {
319
      $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH);
320
      $result[$i][$period] = $upgrade_price;
321
      $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost;
322
    }
323
  }
324
325
  if ($is_upgrade && $time_left) {
326
    $term_original = round($term_original / PERIOD_DAY);
327
    $time_left = min(floor($time_left / PERIOD_DAY), $term_original);
328
    $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;
329
330
    array_walk_recursive($result, function (&$value) use ($cost_left) {
331
      $value -= $cost_left;
332
    });
333
  }
334
335
  return $result;
336
}
337
338
/**
339
 * @param $price_matrix_plain
340
 * @param $price_matrix_original
341
 * @param $price_matrix_upgrade
342
 * @param $user_dark_matter
343
 *
344
 * @return array
345
 *
346
 * Used in player_premium and interface_batch_operation modules
347
 */
348
function price_matrix_templatize(&$price_matrix_plain, &$price_matrix_original, &$price_matrix_upgrade, $user_dark_matter) {
349
  $prices = array();
350
  foreach ($price_matrix_original as $level_num => $level_data) {
351
    $price_per_period = array();
352
    foreach ($level_data as $period => $price) {
353
      $price_per_period[$period] = array(
354
        'PERIOD'             => $period,
355
        'PRICE_ORIGIN'       => $price,
356
        'PRICE_ORIGIN_TEXT'  => HelperString::numberFloorAndFormat($price),
357
        'PRICE_ORIGIN_CLASS' => prettyNumberGetClass($price, $user_dark_matter),
358
        'PRICE_UPGRADE'      => $price_matrix_upgrade[$level_num][$period],
359
        'PRICE_UPGRADE_TEXT' => HelperString::numberFloorAndFormat($price_matrix_upgrade[$level_num][$period]),
360
      );
361
      if (isset($price_matrix_plain[$level_num][$period])) {
362
        $price_per_period[$period] += array(
363
          'PRICE_PLAIN_PERCENT' => ceil(100 - ($price / $price_matrix_plain[$level_num][$period]) * 100),
364
          'PRICE_PLAIN'         => $price_matrix_plain[$level_num][$period],
365
          'PRICE_PLAIN_TEXT'    => HelperString::numberFloorAndFormat($price_matrix_plain[$level_num][$period]),
366
        );
367
      }
368
    }
369
370
    $prices[$level_num] = array(
371
      '.'     => array('period' => $price_per_period),
372
      'LEVEL' => $level_num,
373
    );
374
  }
375
376
  return $prices;
377
}
378
379
380
// TOOLS & UTILITIES ----------------------------------------------------------------------------------------------------------------
381
/**
382
 * Generates random string of $length symbols from $allowed_chars charset
383
 *
384
 * @param int    $length
385
 * @param string $allowed_chars
386
 *
387
 * @return string
388
 */
389
function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) {
390
  $allowed_length = strlen($allowed_chars);
391
392
  $random_string = '';
393
  for ($i = 0; $i < $length; $i++) {
394
    $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)];
395
  }
396
397
  return $random_string;
398
}
399
400
function array_merge_recursive_numeric($array1, $array2) {
401
  if (!empty($array2) && is_array($array2)) {
402
    foreach ($array2 as $key => $value) {
403
      $array1[$key] = !isset($array1[$key]) || !is_array($array1[$key]) ? $value : array_merge_recursive_numeric($array1[$key], $value);
404
    }
405
  }
406
407
  return $array1;
408
}
409
410
function sn_sys_array_cumulative_sum(&$array) {
411
  $accum = 0;
412
  foreach ($array as &$value) {
413
    $accum += $value;
414
    $value = $accum;
415
  }
416
}
417
418
function print_rr($var, $capture = false) {
419
  $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>';
420
  if ($capture) {
421
    return $print;
422
  } else {
423
    print($print);
424
  }
425
}
426
427
/**
428
 * Returns unique string ID for total fleets on planet
429
 *
430
 * @param array $planetTemplatized
431
 *
432
 * @return int|string
433
 */
434
function getUniqueFleetId($planetTemplatized) {
435
  return empty($planetTemplatized['id']) ? 0 : sprintf(FLEET_ID_TEMPLATE, $planetTemplatized['id']);
436
}
437
438
/**
439
 * @param array $context
440
 *
441
 * @return array
442
 */
443
function getLocationFromContext($context = []) {
444
  if (!empty($context[LOC_FLEET])) {
445
    return [LOC_FLEET, $context[LOC_FLEET]['fleet_id']];
446
  } elseif (!empty($context[LOC_PLANET])) {
447
    return [LOC_PLANET, $context[LOC_PLANET]['id']];
448
  } elseif (!empty($context[LOC_USER])) {
449
    return [LOC_USER, $context[LOC_USER]['id']];
450
  } else {
451
    return [LOC_SERVER, 0];
452
  }
453
454
}
455
456
457
//
458
459
460
// MAIL ----------------------------------------------------------------------------------------------------------------
461
function mymail($email_unsafe, $title, $body, $from = '', $html = false) {
462
  $from = trim($from ? $from : SN::$config->game_adminEmail);
463
464
  $head = '';
465
  $head .= "Content-Type: text/" . ($html ? 'html' : 'plain') . "; charset=utf-8 \r\n";
466
  $head .= "Date: " . date('r') . " \r\n";
467
  $head .= "Return-Path: " . SN::$config->game_adminEmail . " \r\n";
468
  $head .= "From: {$from} \r\n";
469
  $head .= "Sender: {$from} \r\n";
470
  $head .= "Reply-To: {$from} \r\n";
471
//  $head .= "Organization: {$org} \r\n";
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
472
  $head .= "X-Sender: {$from} \r\n";
473
  $head .= "X-Priority: 3 \r\n";
474
475
  $body = str_replace("\r\n", "\n", $body);
476
  $body = str_replace("\n", "\r\n", $body);
477
478
  if ($html) {
479
    $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>';
480
  }
481
482
  $title = '=?UTF-8?B?' . base64_encode($title) . '?=';
483
484
  return @mail($email_unsafe, $title, $body, $head);
485
}
486
487
488
// VERSION FUNCTIONS ----------------------------------------------------------------------------------------------------------------
489
function sn_version_compare_extra($version) {
490
  static $version_regexp = '#(\d+)([a-f])(\d+)(?:\.(\d+))*#';
491
  preg_match($version_regexp, $version, $version);
492
  unset($version[0]);
493
  $version[2] = ord($version[2]) - ord('a');
494
495
  return implode('.', $version);
496
}
497
498
function sn_version_compare($ver1, $ver2) {
499
  return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2));
500
}
501
502
503
// MODULES FUNCTIONS ---------------------------------------------------------------------------------------------------
504
/**
505
 * Return Award module or NULL
506
 *
507
 * For typecasting
508
 *
509
 * @return null|player_award
0 ignored issues
show
Bug introduced by
The type player_award was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
510
 */
511
function moduleAward() {
512
  return SN::$gc->modules->getModule('player_award');
0 ignored issues
show
Bug Best Practice introduced by
The expression return SN::gc->modules->getModule('player_award') also could return the type Modules\sn_module which is incompatible with the documented return type null|player_award.
Loading history...
513
}
514
515
/**
516
 * Return Captain module or NULL
517
 *
518
 * For typecasting
519
 *
520
 * @return null|unit_captain
0 ignored issues
show
Bug introduced by
The type unit_captain was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
521
 */
522
function moduleCaptain() {
523
  return SN::$gc->modules->getModule('unit_captain');
0 ignored issues
show
Bug Best Practice introduced by
The expression return SN::gc->modules->getModule('unit_captain') also could return the type Modules\sn_module which is incompatible with the documented return type unit_captain|null.
Loading history...
524
}
525
526
/**
527
 * Updates users online count
528
 *
529
 * We should move this to separate function due to ambiguency of pass() method
530
 *
531
 * @param $usersOnline
532
 */
533
function dbUpdateUsersOnline($usersOnline) {
534
  SN::$config->pass()->var_online_user_count = $usersOnline;
535
}
536
537
/**
538
 * Updates total user count
539
 *
540
 * We should move this to separate function due to ambiguency of pass() method
541
 *
542
 * @param $userCount
543
 */
544
function dbUpdateUsersCount($userCount) {
545
  SN::$config->pass()->users_amount = $userCount;
546
}
547