1 | <?php |
||
2 | |||
3 | use Core\Services\Globals\Globals; |
||
4 | |||
5 | define('ROOT', dirname(__DIR__)); |
||
6 | |||
7 | require ROOT . '/app/App.php'; |
||
8 | App::load(); |
||
9 | $globals = new Globals; |
||
10 | |||
11 | $page = ($globals->getGET('p')) ?? 'home.index'; |
||
12 | |||
13 | $page = explode('.', $page); |
||
14 | if ($page[0] === 'admin') { |
||
15 | $controller = '\App\Controller\Admin\\' . ucfirst($page[1]) . 'Controller'; |
||
16 | $action = $page[2]; |
||
17 | $id = (!empty($page[3]) && ($page[2] !== 'index' && $page[2] !== 'add')) ? $page[3] : null; |
||
18 | } else { |
||
19 | $controller = '\App\Controller\\' . ucfirst($page[0]) . 'Controller'; |
||
20 | $action = $page[1]; |
||
21 | $id = $page[2] ?? null; |
||
22 | $paging = $page[3] ?? null; |
||
23 | } |
||
24 | |||
25 | if (!class_exists($controller)) { |
||
26 | return \header('Location: index.php'); |
||
0 ignored issues
–
show
|
|||
27 | } |
||
28 | |||
29 | $controller = new $controller; |
||
30 | |||
31 | try { |
||
32 | if (!empty($id) && !empty($paging)) { |
||
33 | return $controller->$action($id, $paging); |
||
34 | } |
||
35 | return !empty($id) ? $controller->$action($id) : $controller->$action(); |
||
36 | } catch (ArgumentCountError $e) { |
||
37 | return \header('Location: index.php'); |
||
0 ignored issues
–
show
Are you sure the usage of
header('Location: index.php') is correct as it seems to always return null .
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
38 | } |
||
39 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.