Avoid using static access to class '\App\Language' in method 'process'. Open
$differenceOfAmountsDesciption = $differenceOfAmounts > 0 ? \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF') : \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\Double' in method 'process'. Open
$differenceOfAmounts = \App\Fields\Double::formatToDisplay($this->textParser->recordModel->get('sum_gross') -$relatedRecordModel->get('sum_gross') ) . ' ' . $currency['currency_symbol'];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Vtiger_Record_Model' in method 'process'. Open
$relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->textParser->recordModel->get($this->relatedModulesFields[$this->textParser->recordModel->getModuleName()]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\Currency' in method 'process'. Open
$currency = \App\Fields\Currency::getById($rows['currency']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'process'. Open
$differenceOfAmountsDesciption = $differenceOfAmounts > 0 ? \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF') : \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Reference to instance property recordModel
from undeclared class \App\TextParser
Open
$differenceOfAmounts = \App\Fields\Double::formatToDisplay($this->textParser->recordModel->get('sum_gross') -$relatedRecordModel->get('sum_gross') ) . ' ' . $currency['currency_symbol'];
- Exclude checks
Reference to instance property recordModel
from undeclared class \App\TextParser
Open
$relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->textParser->recordModel->get($this->relatedModulesFields[$this->textParser->recordModel->getModuleName()]));
- Exclude checks
Argument 1 (value)
is float|int
but \App\Fields\Double::formatToDisplay()
takes null|string
defined at /code/app/Fields/Double.php:55
Open
$differenceOfAmounts = \App\Fields\Double::formatToDisplay($this->textParser->recordModel->get('sum_gross') -$relatedRecordModel->get('sum_gross') ) . ' ' . $currency['currency_symbol'];
- Exclude checks
Reference to instance property recordModel
from undeclared class \App\TextParser
Open
$inventoryData = $this->textParser->recordModel->getInventoryData();
- Exclude checks
This conditional operation returns the same value whether the condition is "true" or "false". Open
$differenceOfAmountsDesciption = $differenceOfAmounts > 0 ? \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF') : \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF');
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
Avoid excessively long variable names like $differenceOfAmountsDesciption. Keep variable name length under 20. Open
$differenceOfAmountsDesciption = $differenceOfAmounts > 0 ? \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF') : \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF');
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
}
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $type = 'pdf';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Process.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var mixed Parser type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows = reset($inventoryData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '<table cellspacing="0" style="border-collapse:collapse;width:100%;">
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$differenceOfAmounts = \App\Fields\Double::formatToDisplay($this->textParser->recordModel->get('sum_gross') -$relatedRecordModel->get('sum_gross') ) . ' ' . $currency['currency_symbol'];
- Exclude checks
Line exceeds 120 characters; contains 194 characters Open
$differenceOfAmounts = \App\Fields\Double::formatToDisplay($this->textParser->recordModel->get('sum_gross') -$relatedRecordModel->get('sum_gross') ) . ' ' . $currency['currency_symbol'];
- Exclude checks
Line exceeds 120 characters; contains 174 characters Open
<td style="border-color:#dddddd;border-style:solid;border-width:1px;font-size:12px;font-weight:bold;text-align:center;">'.$differenceOfAmounts .'</td>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $relatedModulesFields = ['FCorectingInvoice' => 'finvoiceid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->textParser->recordModel->get($this->relatedModulesFields[$this->textParser->recordModel->getModuleName()]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inventoryData = $this->textParser->recordModel->getInventoryData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currency = \App\Fields\Currency::getById($rows['currency']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$differenceOfAmountsDesciption = $differenceOfAmounts > 0 ? \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF') : \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $name = 'LBL_CORECTION_AMOUNT_SUMMARY';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Allowed modules */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 194 characters Open
$differenceOfAmountsDesciption = $differenceOfAmounts > 0 ? \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF') : \App\Language::translate('LBL_SURCHARGE_AMOUNT', 'Other.PDF');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Related modules fields */
- Exclude checks
Line exceeds 120 characters; contains 183 characters Open
$relatedRecordModel = \Vtiger_Record_Model::getInstanceById($this->textParser->recordModel->get($this->relatedModulesFields[$this->textParser->recordModel->getModuleName()]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $allowedModules = ['FCorectingInvoice'];
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$differenceOfAmounts = \App\Fields\Double::formatToDisplay($this->textParser->recordModel->get('sum_gross') -$relatedRecordModel->get('sum_gross') ) . ' ' . $currency['currency_symbol'];
- Exclude checks