DataMapperOutputNotValidException::getViolations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Thruster\Component\DataMapper\Exception;
4
5
use Symfony\Component\Validator\ConstraintViolationList;
6
use Symfony\Component\Validator\ConstraintViolationListInterface;
7
8
/**
9
 * Class DataMapperOutputNotValidException
10
 *
11
 * @package Thruster\Component\DataMapper\Exception
12
 * @author  Aurimas Niekis <[email protected]>
13
 */
14
class DataMapperOutputNotValidException extends \Exception
15
{
16
    /**
17
     * @var ConstraintViolationList
18
     */
19
    protected $violations;
20
21 2
    public function __construct(ConstraintViolationListInterface $violations)
22
    {
23 2
        $this->violations = $violations;
0 ignored issues
show
Documentation Bug introduced by
$violations is of type object<Symfony\Component...ViolationListInterface>, but the property $violations was declared to be of type object<Symfony\Component...onstraintViolationList>. 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...
24 2
    }
25
26
    /**
27
     * @return ConstraintViolationList
28
     */
29 1
    public function getViolations()
30
    {
31 1
        return $this->violations;
32
    }
33
}
34