1 | <?php |
||
23 | class Calculator implements CalculatorInterface, ServerTariffCalculatorInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var Model[]|CalculableModelInterface[] |
||
27 | */ |
||
28 | protected $models; |
||
29 | |||
30 | /** |
||
31 | * @var Calculation[] |
||
32 | */ |
||
33 | protected $calculations; |
||
34 | |||
35 | /** |
||
36 | * TariffCalculator constructor. |
||
37 | * @param Model[] $models |
||
38 | */ |
||
39 | public function __construct($models) |
||
43 | |||
44 | /** |
||
45 | * Gets [[Calculation]] for the $id. |
||
46 | * |
||
47 | * @param integer $id |
||
48 | * @return Calculation |
||
49 | */ |
||
50 | public function getCalculation($id) |
||
51 | { |
||
52 | if ($this->calculations === null) { |
||
53 | $this->execute(); |
||
54 | } |
||
55 | |||
56 | return $this->calculations[$id] ?? null; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return Calculation[] |
||
61 | */ |
||
62 | public function getCalculations() |
||
70 | |||
71 | /** |
||
72 | * @throws UnprocessableEntityHttpException |
||
73 | * @return \hipanel\modules\finance\models\Calculation[] |
||
74 | */ |
||
75 | public function execute() |
||
93 | |||
94 | /** |
||
95 | * @return array |
||
96 | */ |
||
97 | protected function collectData() |
||
107 | |||
108 | /** |
||
109 | * @param $rows |
||
110 | * @return \hipanel\modules\finance\models\Calculation[] |
||
111 | */ |
||
112 | private function createCalculations($rows) |
||
122 | } |
||
123 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: