Test Setup Failed
Push — develop ( dc2cdb...883a72 )
by Stone
04:31
created

AppEvent::getEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Event;
4
5
use App\Entity\AppEntity;
6
use App\Entity\Trick;
7
use Symfony\Component\EventDispatcher\Event;
8
9
abstract class AppEvent extends Event
10
{
11
    const NAME = 'defineMe';
12
13
    /**
14
     * @var Trick
15
     */
16
    protected $entity;
17
18
    public function __construct(AppEntity $entity)
19
    {
20
        $this->entity = $entity;
0 ignored issues
show
Documentation Bug introduced by
$entity is of type App\Entity\AppEntity, but the property $entity was declared to be of type App\Entity\Trick. 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
    /**
24
     * @return Trick
25
     */
26
    public function getEntity(): AppEntity
27
    {
28
        return $this->entity;
29
    }
30
}