assignTags accesses the super-global variable $GLOBALS. Open
public function assignTags()
{
$this->tags['ECARD_LINK'] = XOOPS_URL . '/modules/extgallery/public-viewecard.php?id=' . $this->ecardId;
$this->tags['EXP_EMAIL'] = $this->fromEmail;
$this->tags['EXP_NAME'] = $this->fromName;
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Remove error control operator '@' on line 134. Open
public function loadTemplate($name)
{
global $xoopsConfig;
if (\file_exists(XOOPS_ROOT_PATH . '/modules/extgallery/language/' . $xoopsConfig['language'] . '/mail_template/' . $name)) {
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
The method loadTemplate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$path = XOOPS_ROOT_PATH . '/modules/extgallery/language/english/mail_template/' . $name;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method imageIncluded uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$photoPath = $this->photo->getVar('photo_serveur') . $this->photo->getVar('photo_name');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method imageLinked uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$photoUrl = $this->photo->getVar('photo_serveur') . $this->photo->getVar('photo_name');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid variables with short names like $fd. Configured minimum length is 3. Open
$fd = @\fopen($path, 'rb');
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 36 and the first side effect is on line 31. Open
<?php
- Exclude checks
There must be one blank line after the last USE statement; 7 found; Open
use XoopsMultiMailer;
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$path = XOOPS_ROOT_PATH . '/modules/extgallery/language/' . $xoopsConfig['language'] . '/mail_template/' . $name;
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$photoPath = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/medium/' . $this->photo->getVar('photo_name');
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
if (\file_exists(XOOPS_ROOT_PATH . '/modules/extgallery/language/' . $xoopsConfig['language'] . '/mail_template/' . $name)) {
- Exclude checks