Conditions | 7 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace Mcamara\LaravelLocalization\Middleware; |
||
17 | public function handle($request, Closure $next) { |
||
18 | // If the URL of the request is in exceptions. |
||
19 | if ($this->shouldIgnore($request)) { |
||
20 | return $next($request); |
||
21 | } |
||
22 | |||
23 | $params = explode('/', $request->path()); |
||
24 | $locale = $request->cookie('locale', false); |
||
|
|||
25 | |||
26 | if (\count($params) > 0 && app('laravellocalization')->checkLocaleInSupportedLocales($params[0])) { |
||
27 | return $next($request)->withCookie(cookie()->forever('locale', $params[0])); |
||
28 | } |
||
29 | |||
30 | if ($locale && app('laravellocalization')->checkLocaleInSupportedLocales($locale) && !(app('laravellocalization')->isHiddenDefault($locale))) { |
||
31 | $redirection = app('laravellocalization')->getLocalizedURL($locale); |
||
32 | $redirectResponse = new RedirectResponse($redirection, 302, ['Vary' => 'Accept-Language']); |
||
33 | |||
34 | return $redirectResponse->withCookie(cookie()->forever('locale', $params[0])); |
||
35 | } |
||
36 | |||
37 | return $next($request); |
||
38 | } |
||
39 | } |
||
40 |
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: