Total Complexity | 3 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | * @internal |
||
16 | */ |
||
17 | #[Package('core')] |
||
18 | class FinishController extends AbstractController |
||
19 | { |
||
20 | #[Route('/finish', name: 'finish', defaults: ['step' => 3])] |
||
21 | public function default(Request $request, #[Autowire('%kernel.cache_dir%')] string $cacheDir): Response |
||
22 | { |
||
23 | // @codeCoverageIgnoreStart |
||
24 | if ($request->getMethod() === Request::METHOD_POST) { |
||
25 | if ($request->hasSession()) { |
||
26 | $request->getSession()->invalidate(); |
||
27 | } |
||
28 | |||
29 | $self = $_SERVER['SCRIPT_FILENAME']; |
||
30 | \assert(\is_string($self)); |
||
31 | |||
32 | $redirectUrl = $request->getBasePath() . '/admin'; |
||
33 | |||
34 | // Cleanup our generated cache dir in system temporary directory |
||
35 | $fs = new Filesystem(); |
||
36 | $fs->remove($cacheDir); |
||
37 | |||
38 | // Below this line call only php native functions as we deleted our own files already |
||
39 | unlink($self); |
||
40 | |||
41 | header('Content-Type: text/html; charset=utf-8'); |
||
42 | echo '<script>window.location.href = "' . $redirectUrl . '" </script>'; |
||
50 |
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: