Issues (1369)

classes/DBAL/DbMysqliResultIterator.php (2 issues)

1
<?php
2
/**
3
 * Created by Gorlum 17.10.2017 10:48
4
 */
5
6
namespace DBAL;
7
8
use \mysqli_result;
0 ignored issues
show
The type \mysqli_result 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...
9
10
/**
11
 * Class DbMysqliResultIterator
12
 *
13
 * Simplest implementation of DbAbstractResultIterator - getting result from constructor
14
 *
15
 * @package DBAL
16
 */
17
class DbMysqliResultIterator extends DbAbstractResultIterator {
18
  /**
19
   * DbMysqliResultIterator constructor.
20
   *
21
   * @param mysqli_result|bool $mysqli_result
22
   */
23
  public function __construct($mysqli_result) {
24
    $this->mysqli_result = $mysqli_result;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mysqli_result can also be of type boolean. However, the property $mysqli_result is declared as type \mysqli_result|false. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
25
26
    $this->rewind();
27
  }
28
29
}
30