1 | <?php |
||
2 | |||
3 | namespace CMEN\GoogleChartsBundle\GoogleCharts\Charts; |
||
4 | |||
5 | use CMEN\GoogleChartsBundle\GoogleCharts\Chart; |
||
6 | use CMEN\GoogleChartsBundle\GoogleCharts\EventType; |
||
7 | use CMEN\GoogleChartsBundle\GoogleCharts\Options\AnnotationChart\AnnotationChartOptions; |
||
8 | use CMEN\GoogleChartsBundle\GoogleCharts\Options\ChartOptionsInterface; |
||
9 | |||
10 | /** |
||
11 | * @author Christophe Meneses |
||
12 | */ |
||
13 | class AnnotationChart extends Chart |
||
14 | { |
||
15 | /** |
||
16 | * @var AnnotationChartOptions |
||
17 | */ |
||
18 | protected ChartOptionsInterface $options; |
||
19 | |||
20 | 1 | public function __construct() |
|
21 | { |
||
22 | 1 | parent::__construct(); |
|
23 | |||
24 | 1 | $this->options = new AnnotationChartOptions(); |
|
25 | } |
||
26 | |||
27 | 1 | public function getType(): string |
|
28 | { |
||
29 | 1 | return 'AnnotationChart'; |
|
30 | } |
||
31 | |||
32 | 1 | public function getPackage(): string |
|
33 | { |
||
34 | 1 | return 'annotationchart'; |
|
35 | } |
||
36 | |||
37 | public function getAvailableEventTypes(): array |
||
38 | { |
||
39 | return [ |
||
40 | EventType::RANGE_CHANGE, |
||
41 | EventType::READY, |
||
42 | EventType::SELECT, |
||
43 | ]; |
||
44 | } |
||
45 | |||
46 | 1 | public function getOptions(): AnnotationChartOptions |
|
47 | { |
||
48 | 1 | return $this->options; |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param AnnotationChartOptions $options |
||
53 | */ |
||
54 | public function setOptions(ChartOptionsInterface $options): AnnotationChart |
||
55 | { |
||
56 | $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\...\AnnotationChartOptions . 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;
}
![]() |
|||
57 | |||
58 | return $this; |
||
59 | } |
||
60 | } |
||
61 |