Completed
Push — master ( 0a3d23...5fac45 )
by Michael
02:58
created

include/functions.config.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * NewBB 5.0x,  the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (https://xoops.org)
6
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
8
 * @since          4.00
9
 * @package        module::newbb
10
 */
11
12
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
13
14
defined('NEWBB_FUNCTIONS_INI') || include_once __DIR__ . '/functions.ini.php';
15
define('NEWBB_FUNCTIONS_CONFIG_LOADED', true);
16
17
if (!defined('NEWBB_FUNCTIONS_CONFIG')) {
18
    define('NEWBB_FUNCTIONS_CONFIG', 1);
19
20
    /**
21
     * @return array
22
     * @internal param string $category
23
     * @internal param string $dirname
24
     */
25
    function newbbLoadConfig()
0 ignored issues
show
newbbLoadConfig uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
26
    {
27
        include_once dirname(__DIR__) . '/class/helper.php';
28
        $helper = NewBB::getInstance();
29
        static $configs = null;
30
31
        if (null !== $configs) {
32
            return $configs;
33
        }
34
35
        $configs = is_object($helper) ? $helper->getConfig() : [];
36
        $plugins = include __DIR__ . '/plugin.php';
37
        if (is_array($configs) && is_array($plugins)) {
38
            $configs = array_merge($configs, $plugins);
39
        }
40
        if (!isset($GLOBALS['xoopsModuleConfig'])) {
41
            $GLOBALS['xoopsModuleConfig'] = [];
42
        }
43
        if (is_array($configs)) {
44
            $GLOBALS['xoopsModuleConfig']= array_merge( $GLOBALS['xoopsModuleConfig'], $configs);
45
        }
46
47
        return $configs;
48
    }
49
}
50