Missing class import via use statement (line '69', column '23'). Open
throw new \TypeError('$fx must be of type Closure');
- Read upRead up
- Create a ticketCreate a ticket
- 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 _jsRenderIntoModal uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$modal = new Modal(['name' => 'js_callback_' . md5(random_bytes(16))]);
$modal->setApp($this->getApp());
$modal->add($response);
$html = $modal->getHtml();
- 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 unused parameters such as '$mode'. Open
public function getUrl(string $mode = 'callback'): string
- 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
Avoid variables with short names like $fx. Configured minimum length is 3. Open
public function set($fx = null, $args = null)
- 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
Method name "_getProperAction" should not be prefixed with an underscore to indicate visibility Open
private function _getProperAction($response): JsExpressionable
- Create a ticketCreate a ticket
- Exclude checks
Method name "_jsRenderIntoModal" should not be prefixed with an underscore to indicate visibility Open
private function _jsRenderIntoModal(View $response): JsExpressionable
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
return new JsExpression('$([html]).modal(\'show\').data(\'needRemove\', true).addClass(\'atk-callback-response\')', ['html' => $html]);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
* @param \Closure(Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed): (JsExpressionable|View|string|void) $fx
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
return new JsBlock([(new Jquery($this->getOwner() /* TODO element and loader element should be passed explicitly */))->atkAjaxec([
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
* @param array<int|string, string|JsExpressionable> $args
- Create a ticketCreate a ticket
- Exclude checks
The method _getProperAction is not named in camelCase. Open
private function _getProperAction($response): JsExpressionable
{
if ($response instanceof View) {
$response = $this->_jsRenderIntoModal($response);
} elseif (is_string($response)) { // TODO alert() should be removed
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _jsRenderIntoModal is not named in camelCase. Open
private function _jsRenderIntoModal(View $response): JsExpressionable
{
if ($response instanceof Modal) {
$html = $response->getHtml();
} else {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}