| 1 | <?php |
||
| 2 | |||
| 3 | namespace Spatie\DemoMode; |
||
| 4 | |||
| 5 | use Illuminate\Http\RedirectResponse; |
||
| 6 | use Illuminate\Http\Request; |
||
| 7 | |||
| 8 | class DemoModeController extends \Illuminate\Routing\Controller |
||
| 9 | { |
||
| 10 | public function grantAccess(): RedirectResponse |
||
| 11 | { |
||
| 12 | session()->put('demo_access_route_visited', true); |
||
| 13 | |||
| 14 | return new RedirectResponse( |
||
| 15 | config('demo-mode.redirect_authorized_users_to_url') |
||
| 16 | ); |
||
| 17 | } |
||
| 18 | |||
| 19 | public function catchFallback(Request $request): RedirectResponse |
||
| 20 | { |
||
| 21 | if (!config('demo-mode.enabled')) { |
||
| 22 | abort(404); |
||
| 23 | } |
||
| 24 | |||
| 25 | if (!app(DemoGuard::class)->hasDemoAccess($request)) { |
||
| 26 | return new RedirectResponse( |
||
| 27 | config('demo-mode.redirect_unauthorized_users_to_url') |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | abort(404); |
||
|
0 ignored issues
–
show
|
|||
| 32 | } |
||
| 33 | } |
||
| 34 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: