SuicoCorePreload   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 36
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A eventCoreRegisterStart() 0 4 1
A eventCoreEdituserStart() 0 4 1
A eventCoreIncludeCommonEnd() 0 3 1
A eventCoreUserinfoStart() 0 4 1
1
<?php declare(strict_types=1);
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
/**
13
 * @category        Module
14
 * @copyright       {@link https://xoops.org/ XOOPS Project}
15
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
17
 */
18
19
use Xmf\Request;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

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...
20
21
/**
22
 * Class SuicoCorePreload
23
 */
24
class SuicoCorePreload extends \XoopsPreloadItem
25
{
26
    // to add PSR-4 autoloader
27
    /**
28
     * @param $args
29
     */
30
    public static function eventCoreIncludeCommonEnd($args): void
31
    {
32
        require __DIR__ . '/autoloader.php';
33
    }
34
35
    /**
36
     * @param $args
37
     */
38
    public static function eventCoreEdituserStart($args): void
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
    public static function eventCoreEdituserStart(/** @scrutinizer ignore-unused */ $args): void

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

Loading history...
39
    {
40
        header('location: ./modules/suico/edituser.php' . (Request::getString('QUERY_STRING', '', 'SERVER')));
41
        exit();
42
    }
43
44
    /**
45
     * @param $args
46
     */
47
    public static function eventCoreRegisterStart($args): void
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
    public static function eventCoreRegisterStart(/** @scrutinizer ignore-unused */ $args): void

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

Loading history...
48
    {
49
        header('location: ./modules/suico/user.php?op=register' . (Request::getString('QUERY_STRING', '', 'SERVER')));
50
        exit();
51
    }
52
53
    /**
54
     * @param $args
55
     */
56
    public static function eventCoreUserinfoStart($args): void
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
    public static function eventCoreUserinfoStart(/** @scrutinizer ignore-unused */ $args): void

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

Loading history...
57
    {
58
        header('location: ./modules/suico/index.php?' . (Request::getString('QUERY_STRING', '', 'SERVER')));
59
        exit();
60
    }
61
}
62