Issues (1369)

classes/Fleet/FleetStatic.php (2 issues)

1
<?php
2
/**
3
 * Created by Gorlum 21.03.2018 13:27
4
 */
5
6
namespace Fleet;
7
8
use SN;
9
use Common\EmptyCountableIterator;
10
use \DBAL\DbMysqliResultIterator;
0 ignored issues
show
The type \DBAL\DbMysqliResultIterator 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...
11
12
class FleetStatic {
13
14
  /**
15
   * @param array $planetIds
16
   * @param int   $time
17
   *
18
   * @return DbMysqliResultIterator|EmptyCountableIterator
19
   */
20
  public static function dbFleetsOnHoldOnPlanetsByIds($planetIds, $time = SN_TIME_NOW) {
21
    if(empty($planetIds) || !is_array($planetIds)) {
22
      return new EmptyCountableIterator();
23
    }
24
25
    return SN::$db->selectIterator("SELECT `{{fleets}}`.*
0 ignored issues
show
Bug Best Practice introduced by
The expression return SN::db->selectIte... . ' FOR UPDATE') returns the type DBAL\DbMysqliResultIterator which is incompatible with the documented return type Common\EmptyCountableIte...\DbMysqliResultIterator.
Loading history...
26
      FROM `{{fleets}}`
27
        LEFT JOIN `{{users}}` ON id = fleet_owner
28
      WHERE
29
        fleet_end_planet_id IN (" . implode(',', $planetIds) . ")
30
        AND fleet_mess = 0
31
        AND fleet_start_time <= " . $time . "
32
        AND fleet_end_stay >= " . $time . "
33
      FOR UPDATE");
34
  }
35
36
  public static function flt_fleet_speed($user, $fleet, $shipData = []) {
37
    if (!is_array($fleet)) {
38
      $fleet = array($fleet => 1);
39
    }
40
41
    $speeds = array();
42
    if (!empty($fleet)) {
43
      foreach ($fleet as $ship_id => $amount) {
44
        if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile',]))) {
45
          $single_ship_data = !empty($shipData[$ship_id]) ? $shipData[$ship_id] : get_ship_data($ship_id, $user);
46
          $speeds[]         = $single_ship_data['speed'];
47
        }
48
      }
49
    }
50
51
    return empty($speeds) ? 0 : min($speeds);
52
  }
53
54
}
55