bkdotcom/PHPDebugConsole

View on GitHub
src/Debug/Framework/Yii2/EventSubscribers.php

Summary

Maintainability
A
0 mins
Test Coverage

Define a constant instead of duplicating this literal "category" 3 times.
Open

        if (\in_array($error['category'], [Error::CAT_DEPRECATED, Error::CAT_NOTICE, Error::CAT_STRICT], true)) {

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Merge this if statement with the enclosing one.
Open

            if (\strpos($error['file'], YII2_PATH) === 0) {

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if (condition1) {
  if (condition2) {
    ...
  }
}

Compliant Solution

if (condition1 && condition2) {
  ...
}

Unexpected tabs found.
Open

    protected $ignoredErrors = array();

Unexpected tabs found.
Open

    public function __construct(DebugModule $debugModule)

Unexpected tabs found.
Open

            $this->removeSubscribers(EventManager::EVENT_PHP_SHUTDOWN);

Unexpected tabs found.
Open

    {

Unexpected tabs found.
Open

        $this->debugModule = $debugModule;

Unexpected tabs found.
Open

    }

Unexpected tabs found.
Open

    /**

Unexpected tabs found.
Open

        $this->debug = $debugModule->debug;

Unexpected tabs found.
Open

    protected $debugModule;

There are no issues that match your filters.

Category
Status