DeferredResult::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * This file is a part of GraphQL project.
4
 *
5
 * @author Philipp Melab <[email protected]>
6
 * created: 7/25/17 12:34 PM
7
 */
8
9
namespace Youshido\GraphQL\Execution;
10
11
12
/**
13
 * Wrapper class for deferred resolvers during execution process.
14
 * Not part of the public API.
15
 *
16
 * @internal
17
 */
18
class DeferredResult implements DeferredResolverInterface {
19
20
    /** @var \Youshido\GraphQL\Execution\DeferredResolver */
21
    private $resolver;
22
23
    /** @var callable */
24
    protected $callback;
25
26
    /** @var  mixed */
27
    public $result;
28
29 4
    public function __construct(DeferredResolverInterface $resolver, callable $callback)
30
    {
31 4
        $this->resolver = $resolver;
0 ignored issues
show
Documentation Bug introduced by
$resolver is of type object<Youshido\GraphQL\...erredResolverInterface>, but the property $resolver was declared to be of type object<Youshido\GraphQL\...ution\DeferredResolver>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof 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 given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
32 4
        $this->callback = $callback;
33 4
    }
34
35 4
    public function resolve() {
36 4
        $this->result = call_user_func($this->callback, $this->resolver->resolve());
37
    }
38
}