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