Passed
Pull Request — master (#31)
by Marc
03:30
created

OrderByTest::testLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Query;
5
6
use TBolier\RethinkQL\Response\ResponseInterface;
7
8
class OrderByTest extends AbstractTableTest
9
{
10
    /**
11
     * @var array
12
     */
13
    private $array;
14
15
    /**
16
     * @return void
17
     * @throws \Exception
18
     */
19
    public function testLimit(): void
20
    {
21
        $this->insertDocument(5);
22
        $this->insertDocument(4);
23
        $this->insertDocument(3);
24
        $this->insertDocument(2);
25
        $this->insertDocument(1);
26
27
        /** @var ResponseInterface $res */
28
        $res = $this->r()
29
            ->table('tabletest')
30
            ->orderby('id')
31
            ->run();
32
33
        $this->array = $res->getData();
0 ignored issues
show
Documentation Bug introduced by
It seems like $res->getData() can also be of type string. However, the property $array is declared as type array. 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...
34
35
        $this->assertArraySubset(['id' => 1], $this->array[0]);
36
    }
37
}
38