src/UserAction/BasicExecutor.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using static access to class '\Atk4\Ui\Message' in method 'recursiveRender'.
Open

            Message::addTo($this, ['type' => 'error', $this->disableMsg]);
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

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 '\Atk4\Ui\Header' in method 'addHeader'.
Open

            Header::addTo($this, [$this->action->getCaption(), 'subHeader' => $this->description ?? $this->action->getDescription()]);
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

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

The method recursiveRender uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            Message::addTo($this, ['type' => 'error', $this->disableMsg]);

            return;
        }
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

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 using static access to class '\Atk4\Ui\Js\JsBlock' in method 'executeModelAction'.
Open

        return JsBlock::fromHookResult($this->hook(self::HOOK_AFTER_EXECUTE, [$return]) // @phpstan-ignore ternary.shortNotAllowed
            ?: ($success ?? new JsToast('Success' . (is_string($return) ? (': ' . $return) : ''))));
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

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 '\Atk4\Ui\Message' in method 'initPreview'.
Open

            Message::addTo($this, ['type' => 'error', $this->missingArgsMsg]);
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

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 unused local variables such as '$val'.
Open

        foreach ($this->action->args as $key => $val) {
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid unused local variables such as '$val'.
Open

        foreach ($this->action->args as $key => $val) {
Severity: Minor
Found in src/UserAction/BasicExecutor.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Line exceeds 120 characters; contains 130 characters
Open

        return JsBlock::fromHookResult($this->hook(self::HOOK_AFTER_EXECUTE, [$return]) // @phpstan-ignore ternary.shortNotAllowed

Line exceeds 120 characters; contains 154 characters
Open

    /** @var JsExpressionable|\Closure<T of Model>($this, T): ?JsBlock JS expression to return if action was successful, e.g "new JsToast('Thank you')" */

Line exceeds 120 characters; contains 134 characters
Open

            Header::addTo($this, [$this->action->getCaption(), 'subHeader' => $this->description ?? $this->action->getDescription()]);

There are no issues that match your filters.

Category
Status