1 | <?php |
||
2 | |||
3 | namespace CMEN\GoogleChartsBundle\GoogleCharts\Charts\Diff; |
||
4 | |||
5 | use CMEN\GoogleChartsBundle\GoogleCharts\Charts\ScatterChart; |
||
6 | use CMEN\GoogleChartsBundle\GoogleCharts\Options\ChartOptionsInterface; |
||
7 | use CMEN\GoogleChartsBundle\GoogleCharts\Options\Diff\DiffScatterChart\DiffScatterChartOptions; |
||
8 | |||
9 | /** |
||
10 | * @author Christophe Meneses |
||
11 | */ |
||
12 | class DiffScatterChart extends ScatterChart implements DiffChart |
||
13 | { |
||
14 | /** |
||
15 | * @var DiffScatterChartOptions |
||
16 | */ |
||
17 | protected ChartOptionsInterface $options; |
||
18 | |||
19 | public function __construct(private readonly ScatterChart $oldChart, private readonly ScatterChart $newChart) |
||
20 | { |
||
21 | parent::__construct(); |
||
22 | |||
23 | $this->options = new DiffScatterChartOptions(); |
||
24 | } |
||
25 | |||
26 | public function getOptions(): DiffScatterChartOptions |
||
27 | { |
||
28 | return $this->options; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param DiffScatterChartOptions $options |
||
33 | */ |
||
34 | public function setOptions(ChartOptionsInterface $options): DiffScatterChart |
||
35 | { |
||
36 | $this->options = $options; |
||
0 ignored issues
–
show
$options is of type CMEN\GoogleChartsBundle\...s\ChartOptionsInterface , but the property $options was declared to be of type CMEN\GoogleChartsBundle\...DiffScatterChartOptions . 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;
}
![]() |
|||
37 | |||
38 | return $this; |
||
39 | } |
||
40 | |||
41 | public function getOldChart(): ScatterChart |
||
42 | { |
||
43 | return $this->oldChart; |
||
44 | } |
||
45 | |||
46 | public function getNewChart(): ScatterChart |
||
47 | { |
||
48 | return $this->newChart; |
||
49 | } |
||
50 | } |
||
51 |