src/Debug/Framework/Yii2/EventSubscribers.php
Define a constant instead of duplicating this literal "category" 3 times. Open
Open
if (\in_array($error['category'], [Error::CAT_DEPRECATED, Error::CAT_NOTICE, Error::CAT_STRICT], true)) {
- Read upRead up
- Exclude checks
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
Open
if (\strpos($error['file'], YII2_PATH) === 0) {
- Read upRead up
- Exclude checks
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
Open
protected $ignoredErrors = array();
- Exclude checks
Unexpected tabs found. Open
Open
public function __construct(DebugModule $debugModule)
- Exclude checks
Unexpected tabs found. Open
Open
$this->removeSubscribers(EventManager::EVENT_PHP_SHUTDOWN);
- Exclude checks
Unexpected tabs found. Open
Open
{
- Exclude checks
Unexpected tabs found. Open
Open
$this->debugModule = $debugModule;
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
/**
- Exclude checks
Unexpected tabs found. Open
Open
$this->debug = $debugModule->debug;
- Exclude checks
Unexpected tabs found. Open
Open
protected $debugModule;
- Exclude checks