1 | <?php |
||
26 | trait ControllerCollectorTrait |
||
27 | { |
||
28 | |||
29 | abstract public function getWildcards(); |
||
31 | |||
32 | /** |
||
33 | * Define how controller actions names will be joined to form the route pattern. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | |||
38 | protected $controllerActionJoin = "/"; |
||
39 | |||
40 | /** |
||
41 | * Maps all the controller methods that begins with a HTTP method, and maps the rest of |
||
42 | * name as a path. The path will be the method name with slashes before every camelcased |
||
43 | * word and without the HTTP method prefix, and the controller name will be used to prefix |
||
44 | * the route pattern. e.g. ArticlesController::getCreate will generate a route to: GET articles/create |
||
45 | * |
||
46 | * @param string $controller The controller name |
||
47 | * @param string $prefix |
||
48 | * |
||
49 | * @throws \ReflectionException |
||
50 | * @return Group |
||
51 | */ |
||
52 | |||
53 | 5 | public function controller($controller, $prefix = null) |
|
60 | |||
61 | /** |
||
62 | * Maps several controllers at same time. |
||
63 | * |
||
64 | * @param string[] $controllers Controllers name. |
||
65 | * @throws \ReflectionException |
||
66 | * @return Group |
||
67 | */ |
||
68 | |||
69 | 1 | public function controllers(array $controllers) |
|
70 | { |
||
71 | 1 | $group = new Group; |
|
72 | 1 | foreach ($controllers as $controller) |
|
73 | 1 | $group->set($this->controller($controller)); |
|
74 | 1 | return $group; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Alias for Collector::controller but maps a controller without using the controller name as prefix. |
||
79 | * |
||
80 | * @param string $controller The controller name |
||
81 | * @throws \ReflectionException |
||
82 | * @return Group |
||
83 | */ |
||
84 | |||
85 | 2 | public function controllerWithoutPrefix($controller) |
|
91 | |||
92 | /** |
||
93 | * Alias for Collector::controllers but maps a controller without using the controller name as prefix. |
||
94 | * |
||
95 | * @param string[] $controllers |
||
96 | * @throws \ReflectionException |
||
97 | * @return Group |
||
98 | */ |
||
99 | |||
100 | 1 | public function controllersWithoutPrefix(array $controllers) |
|
101 | { |
||
102 | 1 | $group = new Group; |
|
103 | 1 | foreach ($controllers as $controller) |
|
104 | 1 | $group->set($this->controllerWithoutPrefix($controller)); |
|
105 | 1 | return $group; |
|
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param ReflectionClass $controller |
||
110 | * @param string[] $methods |
||
111 | * @param string $prefix |
||
112 | * |
||
113 | * @return Group |
||
114 | */ |
||
115 | |||
116 | 7 | protected function collectControllerRoutes(ReflectionClass $controller, array $methods, $prefix) |
|
145 | |||
146 | /** |
||
147 | * @param ReflectionClass $controller |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | |||
152 | 4 | protected function getControllerPrefix(ReflectionClass $controller) |
|
157 | |||
158 | /** |
||
159 | * @param \ReflectionMethod |
||
160 | * @return string |
||
161 | */ |
||
162 | |||
163 | 7 | protected function getMethodConstraints(ReflectionMethod $method) |
|
183 | |||
184 | /** |
||
185 | * @param ReflectionParameter $parameter |
||
186 | * @param string[] $types |
||
187 | * @return string |
||
188 | */ |
||
189 | |||
190 | 7 | protected function getPathConstraint(ReflectionParameter $parameter, $types) |
|
196 | |||
197 | /** |
||
198 | * @param ReflectionMethod $method |
||
199 | * @return string[] |
||
200 | */ |
||
201 | |||
202 | 7 | protected function getParamsConstraint(ReflectionMethod $method) |
|
215 | |||
216 | /** |
||
217 | * @param ReflectionClass|ReflectionMethod $reflector |
||
218 | * @return string|null |
||
219 | */ |
||
220 | |||
221 | 7 | protected function getAnnotatedStrategy($reflector) |
|
226 | |||
227 | /** |
||
228 | * Define how controller actions names will be joined to form the route pattern. |
||
229 | * Defaults to "/" so actions like "getMyAction" will be "/my/action". If changed to |
||
230 | * "-" the new pattern will be "/my-action". |
||
231 | * |
||
232 | * @param string $join |
||
233 | */ |
||
234 | |||
235 | 1 | public function setControllerActionJoin($join) |
|
239 | |||
240 | /** |
||
241 | * @return string |
||
242 | */ |
||
243 | |||
244 | public function getControllerActionJoin() |
||
248 | |||
249 | } |
||
250 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: