src/Form/Control/DropdownCascade.php
Avoid unused parameters such as '$j'. Open
Open
function (Jquery $j) use ($cascadeFromValue) {
- Read upRead up
- Create a ticketCreate a ticket
- 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 method getNewValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$values[] = [
'value' => $this->getApp()->uiPersistence->typecastAttributeSaveField($model->getIdField(), $row->getId()),
'text' => $row->get($model->titleField),
'name' => $row->get($model->titleField),
- Read upRead up
- Create a ticketCreate a ticket
- 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 $j. Configured minimum length is 3. Open
Open
function (Jquery $j) use ($cascadeFromValue) {
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid variables with short names like $id. Configured minimum length is 3. Open
Open
public function getNewValues($id): array
- Read upRead up
- Create a ticketCreate a ticket
- 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
Line exceeds 120 characters; contains 131 characters Open
Open
$this->dropdownOptions['values'] = $this->getJsValues($this->getNewValues($this->cascadeFrom->entityField->get()), $value);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 181 characters Open
Open
? $this->getApp()->uiPersistence->typecastAttributeLoadField($this->cascadeFrom->entityField->getField(), $this->getApp()->getRequestPostParam($this->cascadeFrom->name))
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
$this->dropdownOptions['values'] = $this->getJsValues($this->getNewValues($cascadeFromValue), $this->entityField->get());
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
'value' => $this->getApp()->uiPersistence->typecastAttributeSaveField($model->getIdField(), $row->getId()),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
$this->cascadeFrom->onChange($expr, ['args' => [$this->cascadeFrom->name => $this->cascadeFrom->jsInput()->val()]]);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
'value' => $this->getApp()->uiPersistence->typecastAttributeSaveField($model->getIdField(), $row->getId()),
- Create a ticketCreate a ticket
- Exclude checks