1 | <?php |
||
8 | abstract class BaseWidget |
||
9 | { |
||
10 | public $template = null; |
||
11 | public $minifyOutput = true; |
||
12 | public $cacheLifeTime = 'env_default'; |
||
13 | public $contextAs = '$data'; |
||
14 | public $presenter = 'default'; |
||
15 | public $controller = null; |
||
16 | public $cacheTags = null; |
||
17 | public $html; |
||
18 | private $viewData; |
||
19 | private $policies; |
||
20 | |||
21 | /** |
||
22 | * BaseWidget constructor. |
||
23 | */ |
||
24 | public function __construct() |
||
29 | |||
30 | /** |
||
31 | * This method is called when you try to invoke the object like a function in blade files. |
||
32 | * like this : {!! $myWidgetObj('param1') !!} |
||
33 | * @param array $args |
||
34 | * @return string |
||
35 | */ |
||
36 | public function __invoke(...$args) |
||
40 | |||
41 | /** |
||
42 | * @param array $args |
||
43 | * @return string |
||
44 | */ |
||
45 | private function renderWidget(...$args) |
||
54 | |||
55 | /** |
||
56 | * It tries to get the html from cache if possible, otherwise generates it. |
||
57 | * @param array ...$args |
||
58 | * @return string |
||
59 | */ |
||
60 | private function generateHtml(...$args) |
||
77 | |||
78 | /** |
||
79 | * @param $args |
||
80 | * @return null |
||
81 | */ |
||
82 | private function prepareDataForView($args) |
||
95 | |||
96 | private function renderTemplate() |
||
112 | |||
113 | /** |
||
114 | * @param $arg |
||
115 | * @return string |
||
116 | */ |
||
117 | private function makeCacheKey($arg) |
||
121 | |||
122 | /** |
||
123 | * This method is called when you try to print the object like an string in blade files. |
||
124 | * like this : {!! $myWidgetObj !!} |
||
125 | */ |
||
126 | public function __toString() |
||
130 | } |
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: