1 | <?php |
||
15 | trait Componentable |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * The registered components. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected static $components = []; |
||
28 | |||
29 | /* ----------------------------------------------------------------- |
||
30 | | Main Methods |
||
31 | | ----------------------------------------------------------------- |
||
32 | */ |
||
33 | |||
34 | /** |
||
35 | * Register a custom component. |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @param string $view |
||
39 | * @param array $signature |
||
40 | */ |
||
41 | 12 | public static function component(string $name, string $view, array $signature) |
|
45 | |||
46 | /** |
||
47 | * Check if a component is registered. |
||
48 | * |
||
49 | * @param string $name |
||
50 | * |
||
51 | * @return bool |
||
52 | */ |
||
53 | 18 | public static function hasComponent(string $name): bool |
|
57 | |||
58 | /* ----------------------------------------------------------------- |
||
59 | | Other Methods |
||
60 | | ----------------------------------------------------------------- |
||
61 | */ |
||
62 | |||
63 | /** |
||
64 | * Render a custom component. |
||
65 | * |
||
66 | * @param string $name |
||
67 | * @param array $arguments |
||
68 | * |
||
69 | * @return \Illuminate\Support\HtmlString |
||
70 | */ |
||
71 | 6 | protected function renderComponent(string $name, array $arguments): HtmlString |
|
80 | |||
81 | /** |
||
82 | * Prepare the component data, while respecting provided defaults. |
||
83 | * |
||
84 | * @param array $signature |
||
85 | * @param array $arguments |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | 6 | protected function getComponentData(array $signature, array $arguments): array |
|
106 | |||
107 | /** |
||
108 | * Dynamically handle calls to the class. |
||
109 | * |
||
110 | * @param string $method |
||
111 | * @param array $parameters |
||
112 | * |
||
113 | * @return \Illuminate\Support\HtmlString|mixed |
||
114 | * |
||
115 | * @throws \BadMethodCallException |
||
116 | */ |
||
117 | 12 | public function __call($method, $parameters) |
|
124 | } |
||
125 |
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: