These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Configuration file to create router as $di service. |
||
4 | */ |
||
5 | return [ |
||
6 | 6 | "services" => [ |
|
7 | "router" => [ |
||
8 | "shared" => true, |
||
9 | "callback" => function () { |
||
10 | 6 | $router = new \Anax\Route\Router(); |
|
11 | 6 | $router->setDI($this); |
|
0 ignored issues
–
show
|
|||
12 | |||
13 | // Load the configuration files |
||
14 | 6 | $cfg = $this->get("configuration"); |
|
15 | 6 | $config = $cfg->load("router"); |
|
16 | |||
17 | // Set DEVELOPMENT/PRODUCTION mode, if defined |
||
18 | 6 | $mode = $config["config"]["mode"] ?? null; |
|
19 | 6 | if (isset($mode)) { |
|
20 | 2 | $router->setMode($mode); |
|
21 | 4 | } else if (defined("ANAX_PRODUCTION")) { |
|
22 | 1 | $router->setMode(\Anax\Route\Router::PRODUCTION); |
|
23 | } |
||
24 | |||
25 | // Add routes from configuration file |
||
26 | 6 | $file = null; |
|
27 | try { |
||
28 | 6 | $file = $config["file"] ?? null; |
|
29 | 6 | $router->addRoutes($config["config"] ?? []); |
|
30 | 5 | foreach ($config["items"] ?? [] as $routes) { |
|
31 | 3 | $file = $routes["file"]; |
|
32 | 5 | $router->addRoutes($routes["config"]); |
|
33 | } |
||
34 | 1 | } catch (Exception $e) { |
|
35 | 1 | throw new Exception( |
|
36 | 1 | "Configuration file: '$file'. " |
|
37 | 1 | . $e->getMessage() |
|
38 | ); |
||
39 | } |
||
40 | |||
41 | 5 | return $router; |
|
42 | 6 | } |
|
43 | ], |
||
44 | ], |
||
45 | ]; |
||
46 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.