1 | <?php |
||
9 | class RouterInjectable |
||
10 | { |
||
11 | /** |
||
12 | * Properties |
||
13 | * |
||
14 | */ |
||
15 | private $routes = []; // All the routes |
||
16 | private $internalRoutes = []; // All internal routes |
||
17 | private $lastRoute = null; // Last route that was callbacked |
||
18 | |||
19 | |||
20 | |||
21 | /** |
||
22 | * Get all routes. |
||
23 | * |
||
24 | * @return array with all routes. |
||
25 | */ |
||
26 | public function getAll() |
||
30 | |||
31 | |||
32 | |||
33 | /** |
||
34 | * Get all internal routes. |
||
35 | * |
||
36 | * @return array with internal routes. |
||
37 | */ |
||
38 | public function getInternal() |
||
42 | |||
43 | |||
44 | |||
45 | /** |
||
46 | * Add a route to the router. |
||
47 | * |
||
48 | * @param string $rule for this route |
||
49 | * @param mixed $action null, string or callable to implement a |
||
50 | * controller for the route |
||
51 | * |
||
52 | * @return class as new route |
||
53 | */ |
||
54 | 7 | public function add($rule, $action = null) |
|
58 | |||
59 | |||
60 | |||
61 | /** |
||
62 | * Add aroute to the router with specific request method. |
||
63 | * |
||
64 | * @param array $method as array of strings of request methods |
||
65 | * @param string $rule for this route |
||
66 | * @param mixed $action null, string or callable to implement a |
||
67 | * controller for the route |
||
68 | * |
||
69 | * @return class as new route |
||
70 | */ |
||
71 | 9 | public function any($method, $rule, $action = null) |
|
79 | |||
80 | |||
81 | |||
82 | /** |
||
83 | * Add a GET route to the router. |
||
84 | * |
||
85 | * @param string $rule for this route |
||
86 | * @param mixed $action null, string or callable to implement a |
||
87 | * controller for the route |
||
88 | * |
||
89 | * @return class as new route |
||
90 | */ |
||
91 | 1 | public function get($rule, $action = null) |
|
95 | |||
96 | |||
97 | |||
98 | /** |
||
99 | * Add a POST route to the router. |
||
100 | * |
||
101 | * @param string $rule for this route |
||
102 | * @param mixed $action null, string or callable to implement a |
||
103 | * controller for the route |
||
104 | * |
||
105 | * @return class as new route |
||
106 | */ |
||
107 | 1 | public function post($rule, $action = null) |
|
111 | |||
112 | |||
113 | |||
114 | /** |
||
115 | * Add a PUT route to the router. |
||
116 | * |
||
117 | * @param string $rule for this route |
||
118 | * @param mixed $action null, string or callable to implement a |
||
119 | * controller for the route |
||
120 | * |
||
121 | * @return class as new route |
||
122 | */ |
||
123 | 1 | public function put($rule, $action = null) |
|
127 | |||
128 | |||
129 | |||
130 | /** |
||
131 | * Add a DELETE route to the router. |
||
132 | * |
||
133 | * @param string $rule for this route |
||
134 | * @param mixed $action null, string or callable to implement a |
||
135 | * controller for the route |
||
136 | * |
||
137 | * @return class as new route |
||
138 | */ |
||
139 | 1 | public function delete($rule, $action = null) |
|
143 | |||
144 | |||
145 | |||
146 | /** |
||
147 | * Add an internal (not exposed to url-matching) route to the router. |
||
148 | * |
||
149 | * @param string $rule for this route |
||
150 | * @param mixed $action null, string or callable to implement a controller for the route |
||
151 | * |
||
152 | * @return class as new route |
||
153 | */ |
||
154 | 3 | public function addInternal($rule, $action = null) |
|
161 | |||
162 | |||
163 | |||
164 | /** |
||
165 | * Add an internal (not exposed to url-matching) route to the router. |
||
166 | * |
||
167 | * @param string $rule for this route |
||
168 | * @param mixed $action null, string or callable to implement a |
||
169 | * controller for the route |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | 4 | public function handleInternal($rule) |
|
182 | |||
183 | |||
184 | |||
185 | /** |
||
186 | * Get the route for the last route that was handled. |
||
187 | * |
||
188 | * @return mixed |
||
189 | */ |
||
190 | public function getLastRoute() |
||
194 | |||
195 | |||
196 | |||
197 | /** |
||
198 | * Handle the routes and match them towards the request, dispatch them |
||
199 | * when a match is made. Each route handler may throw exceptions that |
||
200 | * may redirect to an internal route for error handling. |
||
201 | * Several routes can match and if the routehandler does not break |
||
202 | * execution flow, the route matching will carry on. |
||
203 | * Only the last routehandler will get its return value returned further. |
||
204 | * |
||
205 | * @param string $query the query/route to match a handler for. |
||
206 | * @param string $method the request method to match. |
||
207 | * |
||
208 | * @return mixed content returned from route. |
||
209 | */ |
||
210 | 10 | public function handle($query, $method = null) |
|
236 | } |
||
237 |
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: