These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
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 | * @copyright XOOPS Project https://xoops.org/ |
||
14 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
15 | * @package |
||
16 | * @since |
||
17 | * @author XOOPS Development Team |
||
18 | */ |
||
19 | |||
20 | require_once __DIR__ . '/../../../mainfile.php'; |
||
21 | |||
22 | $moduleDirName = basename(dirname(__DIR__)); |
||
23 | $capsDirName = strtoupper($moduleDirName); |
||
24 | |||
25 | if (!defined($capsDirName . '_DIRNAME')) { |
||
26 | //if (!defined(constant($capsDirName . '_DIRNAME'))) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
62% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
27 | define($capsDirName . '_DIRNAME', $GLOBALS['xoopsModule']->dirname()); |
||
28 | define($capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME')); |
||
29 | define($capsDirName . '_URL', XOOPS_URL . '/modules/' . constant($capsDirName . '_DIRNAME')); |
||
30 | define($capsDirName . '_ADMIN', constant($capsDirName . '_URL') . '/admin/index.php'); |
||
31 | define($capsDirName . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME')); |
||
32 | define($capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png'); |
||
33 | } |
||
34 | |||
35 | // Define here the place where main upload path |
||
36 | |||
37 | //$img_dir = $GLOBALS['xoopsModuleConfig']['uploaddir']; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
38 | |||
39 | define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
||
40 | define($capsDirName . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
||
41 | |||
42 | //constant($cloned_lang . '_CATEGORY_NOTIFY') |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
43 | |||
44 | //$uploadFolders = [ |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
41% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
45 | // constant($capsDirName . '_UPLOAD_PATH'), |
||
46 | // constant($capsDirName . '_UPLOAD_PATH') . '/images', |
||
47 | // constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails' |
||
48 | //]; |
||
49 | // |
||
50 | //$copyFiles = [ |
||
51 | // constant($capsDirName . '_UPLOAD_PATH'), |
||
52 | // constant($capsDirName . '_UPLOAD_PATH') . '/images', |
||
53 | // constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails' |
||
54 | //]; |
||
55 | // |
||
56 | //$oldFiles = [ |
||
57 | // '/include/update_functions.php', |
||
58 | // '/include/install_functions.php' |
||
59 | //]; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Class ModuleConfigurator |
||
64 | */ |
||
65 | class ContactConfigurator |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
Loading history...
|
|||
66 | { |
||
67 | public $uploadFolders = []; |
||
68 | public $blankFiles = []; |
||
69 | public $templateFolders = []; |
||
70 | public $oldFiles = []; |
||
71 | public $oldFolders = []; |
||
72 | public $name; |
||
73 | |||
74 | /** |
||
75 | * ModuleConfigurator constructor. |
||
76 | */ |
||
77 | public function __construct() |
||
78 | { |
||
79 | $moduleDirName = basename(dirname(__DIR__)); |
||
80 | $capsDirName = strtoupper($moduleDirName); |
||
0 ignored issues
–
show
$capsDirName 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
Loading history...
|
|||
81 | $this->name = 'Contact Module Configurator'; |
||
82 | $this->uploadFolders = [ |
||
83 | // constant($capsDirName . '_UPLOAD_PATH'), |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
84 | // constant($capsDirName . '_UPLOAD_PATH') . '/midsize', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
85 | // constant($capsDirName . '_UPLOAD_PATH') . '/thumbs', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
86 | ]; |
||
87 | $this->blankFiles = [ |
||
88 | // constant($capsDirName . '_UPLOAD_PATH'), |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
89 | // constant($capsDirName . '_UPLOAD_PATH') . '/midsize', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
90 | // constant($capsDirName . '_UPLOAD_PATH') . '/thumbs', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
91 | ]; |
||
92 | |||
93 | $this->templateFolders = [ |
||
94 | '/templates/', |
||
95 | '/templates/blocks/', |
||
96 | '/templates/admin/' |
||
97 | |||
98 | ]; |
||
99 | $this->oldFiles = [ |
||
100 | '/include/functions.php', |
||
101 | '/include/functions_update.php', |
||
102 | '/LICENSE', |
||
103 | '/readme.html', |
||
104 | ]; |
||
105 | $this->oldFolders = [ |
||
106 | '/images', |
||
107 | '/css', |
||
108 | '/js', |
||
109 | ]; |
||
110 | } |
||
111 | } |
||
112 | |||
113 | // module information |
||
114 | $modCopyright = "<a href='https://xoops.org' title='XOOPS Project' target='_blank'> |
||
115 | <img src='" . constant($capsDirName . '_AUTHOR_LOGOIMG') . '\' alt=\'XOOPS Project\' /></a>'; |
||
116 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.