1 | <?php declare(strict_types = 1); |
||
13 | class Route implements RouteContract |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $domain = ''; |
||
19 | |||
20 | /** |
||
21 | * Host to apply route to. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $host = ''; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $input = ''; |
||
31 | |||
32 | /** |
||
33 | * Route allowed methods. |
||
34 | * |
||
35 | * @var string[] |
||
36 | */ |
||
37 | private $methods = []; |
||
38 | |||
39 | /** |
||
40 | * List of middleware class names. |
||
41 | * |
||
42 | * @var string[] |
||
43 | */ |
||
44 | private $middlewares = []; |
||
45 | |||
46 | /** |
||
47 | * Route name. |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | private $name = ''; |
||
52 | |||
53 | /** |
||
54 | * Route path |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | private $path = ''; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | private $responder; |
||
64 | |||
65 | /** |
||
66 | * Scheme to apply route to. |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | private $scheme = ''; |
||
71 | |||
72 | /** |
||
73 | * Route variables. |
||
74 | * |
||
75 | * @var string[] |
||
76 | */ |
||
77 | private $variables = []; |
||
78 | |||
79 | /** |
||
80 | * Route constructor. |
||
81 | * |
||
82 | * @param string[] $methods |
||
83 | * @param string $path |
||
84 | * @param string $responder |
||
85 | */ |
||
86 | 17 | public function __construct(array $methods, string $path, string $responder) |
|
92 | |||
93 | /** |
||
94 | * @param string $path |
||
95 | * @param callable|string $responder |
||
96 | * @return Route |
||
97 | */ |
||
98 | public static function any(string $path, $responder): Route |
||
102 | |||
103 | /** |
||
104 | * @param string $path |
||
105 | * @param callable|string $responder |
||
106 | * @return Route |
||
107 | */ |
||
108 | public static function delete(string $path, $responder): Route |
||
112 | |||
113 | /** |
||
114 | * @param string $path |
||
115 | * @param callable|string $responder |
||
116 | * @return Route |
||
117 | */ |
||
118 | public static function get(string $path, $responder): Route |
||
122 | |||
123 | /** |
||
124 | * @param string $path |
||
125 | * @param callable|string $responder |
||
126 | * @return Route |
||
127 | */ |
||
128 | public static function head(string $path, $responder): Route |
||
132 | |||
133 | /** |
||
134 | * @param string $path |
||
135 | * @param callable|string $responder |
||
136 | * @return Route |
||
137 | */ |
||
138 | public static function options(string $path, $responder): Route |
||
142 | |||
143 | /** |
||
144 | * @param string $path |
||
145 | * @param callable|string $responder |
||
146 | * @return Route |
||
147 | */ |
||
148 | public static function patch(string $path, $responder): Route |
||
152 | |||
153 | /** |
||
154 | * @param string $path |
||
155 | * @param callable|string $responder |
||
156 | * @return Route |
||
157 | */ |
||
158 | public static function post(string $path, $responder): Route |
||
162 | |||
163 | /** |
||
164 | * @param string $path |
||
165 | * @param callable|string $responder |
||
166 | * @return Route |
||
167 | */ |
||
168 | public static function put(string $path, $responder): Route |
||
172 | |||
173 | /** |
||
174 | * @inheritDoc |
||
175 | */ |
||
176 | 3 | public function compilePath(array $variables = []): string |
|
221 | |||
222 | /** |
||
223 | * @inheritDoc |
||
224 | */ |
||
225 | 2 | public function domain(): string |
|
226 | { |
||
227 | 2 | return $this->domain; |
|
228 | } |
||
229 | |||
230 | /** |
||
231 | * @inheritDoc |
||
232 | */ |
||
233 | 7 | public function host(): string |
|
234 | { |
||
235 | 7 | return $this->host; |
|
236 | } |
||
237 | |||
238 | /** |
||
239 | * @inheritDoc |
||
240 | */ |
||
241 | 2 | public function input(): string |
|
242 | { |
||
243 | 2 | return $this->input; |
|
244 | } |
||
245 | |||
246 | /** |
||
247 | * @inheritDoc |
||
248 | */ |
||
249 | 1 | public function methods(): array |
|
250 | { |
||
251 | 1 | return $this->methods; |
|
252 | } |
||
253 | |||
254 | /** |
||
255 | * @inheritDoc |
||
256 | */ |
||
257 | 1 | public function middlewares(): array |
|
258 | { |
||
259 | 1 | return $this->middlewares; |
|
260 | } |
||
261 | |||
262 | /** |
||
263 | * @inheritDoc |
||
264 | */ |
||
265 | 2 | public function name(): string |
|
266 | { |
||
267 | 2 | return $this->name; |
|
268 | } |
||
269 | |||
270 | /** |
||
271 | * @inheritDoc |
||
272 | */ |
||
273 | 9 | public function path(): string |
|
274 | { |
||
275 | 9 | return $this->path; |
|
276 | } |
||
277 | |||
278 | /** |
||
279 | * @inheritDoc |
||
280 | */ |
||
281 | 1 | public function responder(): string |
|
282 | { |
||
283 | 1 | return $this->responder; |
|
284 | } |
||
285 | |||
286 | /** |
||
287 | * @inheritDoc |
||
288 | */ |
||
289 | 7 | public function scheme(): string |
|
290 | { |
||
291 | 7 | return $this->scheme; |
|
292 | } |
||
293 | |||
294 | /** |
||
295 | * @inheritDoc |
||
296 | */ |
||
297 | public function variables(): array |
||
298 | { |
||
299 | return $this->variables; |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * @inheritDoc |
||
304 | */ |
||
305 | 3 | public function secure(): RouteContract |
|
312 | |||
313 | /** |
||
314 | * @inheritDoc |
||
315 | */ |
||
316 | 1 | public function withDomain(string $domainClass): RouteContract |
|
323 | |||
324 | /** |
||
325 | * @inheritDoc |
||
326 | */ |
||
327 | 3 | public function withHost(string $host): RouteContract |
|
334 | |||
335 | /** |
||
336 | * @inheritDoc |
||
337 | */ |
||
338 | 1 | public function withInput(string $inputClass): RouteContract |
|
345 | |||
346 | /** |
||
347 | * @inheritDoc |
||
348 | */ |
||
349 | 1 | public function withMiddleware(string $middleware): RouteContract |
|
356 | |||
357 | /** |
||
358 | * @inheritDoc |
||
359 | */ |
||
360 | 1 | public function withName(string $name): RouteContract |
|
367 | |||
368 | /** |
||
369 | * @inheritDoc |
||
370 | */ |
||
371 | 5 | public function withPath(string $path): RouteContract |
|
378 | |||
379 | /** |
||
380 | * @inheritDoc |
||
381 | */ |
||
382 | public function withVariables(array $variables): RouteContract |
||
389 | |||
390 | } |
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: