Completed
Push — master ( 089ad5...045fb9 )
by Richard
10:39
created

CommentsPreload::eventSystemModuleUninstall()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %
Metric Value
dl 7
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
use Xoops\Core\PreloadItem;
13
use Xoops\Core\Kernel\Handlers\XoopsModule;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModule.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
14
use Xoops\Module\Plugin;
15
use Xoops\Module\Plugin\ConfigCollector;
16
17
18
/**
19
 * Comments core preloads
20
 *
21
 * @copyright XOOPS Project (http://xoops.org)
22
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
23
 * @author    trabis <[email protected]>
24
 */
25
class CommentsPreload extends PreloadItem
26
{
27
    /**
28
     * listen for core.include.common.classmaps
29
     * add any module specific class map entries
30
     *
31
     * @param mixed $args not used
32
     *
33
     * @return void
34
     */
35
    public static function eventCoreIncludeCommonClassmaps($args)
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        $path = dirname(__DIR__);
38
        XoopsLoad::addMap(array(
39
            'comments'                => $path . '/class/helper.php',
40
            'commentscommentrenderer' => $path . '/class/commentrenderer.php'
41
        ));
42
    }
43
44
    public static function eventCoreFooterStart($args)
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        $helper = \Xoops::getModuleHelper('comments');
47
        $helper->renderView();
48
    }
49
50 View Code Duplication
    public static function eventSystemModuleUpdateConfigs(ConfigCollector $collector)
51
    {
52
        $helper = \Xoops::getModuleHelper('comments');
53
        if ($plugin = Plugin::getPlugin(
0 ignored issues
show
Unused Code introduced by
$plugin is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
54
            $collector->module()->getVar('dirname'),
55
            'comments',
56
            true
57
        )) {
58
            $pluginConfigs = $helper->getPluginableConfigs();
59
            $collector->add($pluginConfigs);
60
        }
61
    }
62
63 View Code Duplication
    public static function eventSystemModuleInstall(XoopsModule $module)
64
    {
65
        $helper = \Xoops::getModuleHelper('comments');
66
        if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments', true)) {
0 ignored issues
show
Unused Code introduced by
$plugin is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
67
            $helper::getInstance()->insertModuleRelations($module);
68
        }
69
    }
70
71
    /**
72
     * remove any comeents for module being uninstalled
73
     *
74
     * @param XoopsModule $module module object
75
     *
76
     * @return void
77
     */
78 View Code Duplication
    public static function eventSystemModuleUninstall(XoopsModule $module)
79
    {
80
        $helper = \Xoops::getModuleHelper('comments');
81
        if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments')) {
0 ignored issues
show
Unused Code introduced by
$plugin is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
82
            $helper->deleteModuleRelations($module);
83
        }
84
    }
85
86 View Code Duplication
    public static function eventSystemPreferencesForm(XoopsModule $module)
87
    {
88
        $helper = \Xoops::getModuleHelper('comments');
89
90
        if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments')) {
0 ignored issues
show
Unused Code introduced by
$plugin is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
91
            $helper->loadLanguage('main');
92
        }
93
    }
94
}
95