Completed
Push — work-fleets ( 22b5bc...08ace7 )
by SuperNova.WS
06:13
created

db.php ➔ sn_db_field_set_is_safe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @version 2015-04-11 11:47:49 39b14.2
5
 * @copyright 2008-2015 Gorlum for Project "SuperNova.WS"
6
 */
7
8
defined('INSIDE') || die();
9
10
require_once('db/db_queries.php');
11
12
// TODO: THIS FUNCTION IS OBSOLETE AND SHOULD BE REPLACED!
13
// TODO - ТОЛЬКО ДЛЯ РЕСУРСОВ
14
// $unit_list should have unique entrances! Recompress non-uniq entrances before pass param!
15
/**
16
 * @param       $user
17
 * @param       $planet
18
 * @param array $unit_list
19
 * @param null  $query
0 ignored issues
show
Bug introduced by
There is no parameter named $query. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
20
 */
21
function db_change_resources(&$user, &$planet, $unit_list) {
22
  $group = sn_get_groups('resources_loot');
23
  reset($unit_list);
24
  $locationType = sys_get_unit_location($user, $planet, key($unit_list));
25
26
  $resourcesChange = array();
27
  foreach($unit_list as $unit_id => $unit_amount) {
28
    if(!in_array($unit_id, $group)) {
29
      // TODO - remove later
30
      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_resources() вызван для не-ресурсов!</h1>');
31
      pdump(debug_backtrace());
32
      die('db_change_resources() вызван для не-ресурсов!');
33
    }
34
35
    if(empty($unit_amount)) {
36
      continue;
37
    }
38
39
    $resourcesChange[pname_resource_name($unit_id)] += $unit_amount;
40
  }
41
42
  if($locationType == LOC_USER) {
43
    $locationId = $user['id'];
44
  } else {
45
    $locationId = $planet['id'];
46
  }
47
48
  if (!empty($locationId) && !empty($resourcesChange)) {
49
    classSupernova::$gc->cacheOperator->db_upd_record_by_id(
0 ignored issues
show
Bug introduced by
The method db_upd_record_by_id does only exist in SnDbCachedOperator, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
50
      $locationType,
51
      $locationId,
52
      array(),
53
      $resourcesChange
54
    );
55
  }
56
57
}
58
59
function sn_db_transaction_check($transaction_should_be_started = null) {
60
  return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started);
0 ignored issues
show
Bug introduced by
The method getTransaction does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
61
}
62
function sn_db_transaction_start($level = '') {
63
  return classSupernova::$gc->db->getTransaction()->start($level);
0 ignored issues
show
Bug introduced by
The method getTransaction does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
64
}
65
function sn_db_transaction_commit() {
66
  return classSupernova::$gc->db->getTransaction()->commit();
0 ignored issues
show
Bug introduced by
The method getTransaction does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
67
}
68
function sn_db_transaction_rollback() {
69
  return classSupernova::$gc->db->getTransaction()->rollback();
0 ignored issues
show
Bug introduced by
The method getTransaction does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
70
}
71
72
73
74
function db_fetch(&$query) {
75
  return classSupernova::$gc->db->db_fetch($query);
0 ignored issues
show
Bug introduced by
The method db_fetch does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
76
}
77
function db_escape($unescaped_string) {
78
  return classSupernova::$gc->db->db_escape($unescaped_string);
0 ignored issues
show
Bug introduced by
The method db_escape does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
79
}
80