updatePayment accesses the super-global variable $_GET. Open
public function updatePayment()
{
$txn_id = $_GET['txn'];
$transaction = new TransactionModel();
$transaction->loadByPK($txn_id);
- 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
updatePayment accesses the super-global variable $_GET. Open
public function updatePayment()
{
$txn_id = $_GET['txn'];
$transaction = new TransactionModel();
$transaction->loadByPK($txn_id);
- 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
Missing class import via use statement (line '33', column '28'). Open
$transaction = new TransactionModel();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method updatePayment uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return [
'success' => false,
'changed' => true,
'transaction' => $transaction,
- 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 unused parameters such as '$description'. Open
public function getRedirectParams($description = null)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$description'. Open
public function getRedirectUrl($description = null)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
The class Ajde_Shop_Transaction_Provider_Iban is not named in CamelCase. Open
class Ajde_Shop_Transaction_Provider_Iban extends Ajde_Shop_Transaction_Provider
{
public function getName()
{
return trans('IBAN bank transfer', 'shop');
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The variable $txn_id is not named in camelCase. Open
public function updatePayment()
{
$txn_id = $_GET['txn'];
$transaction = new TransactionModel();
$transaction->loadByPK($txn_id);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $txn_id is not named in camelCase. Open
public function updatePayment()
{
$txn_id = $_GET['txn'];
$transaction = new TransactionModel();
$transaction->loadByPK($txn_id);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}