TransportAwareTrait::setTransport()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * @author Jean Silva <[email protected]>
4
 * @license MIT
5
 */
6
namespace Jeancsil\FlightSpy\Api\Http;
7
8
trait TransportAwareTrait
9
{
10
    /**
11
     * @var Transport
12
     */
13
    private $transport;
14
15
    /**
16
     * @param TransportInterface $transport
17
     */
18
    public function setTransport(TransportInterface $transport)
19
    {
20
        $this->transport = $transport;
0 ignored issues
show
Documentation Bug introduced by
$transport is of type object<Jeancsil\FlightSp...ttp\TransportInterface>, but the property $transport was declared to be of type object<Jeancsil\FlightSpy\Api\Http\Transport>. 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...
21
    }
22
}
23