app/Db/Command.php
@throws type of query
has undeclared type \App\Db\Exception
(Did you mean class \Exception) Open
Open
public function query()
- Exclude checks
Class extends undeclared class \yii\db\Command
(Did you mean class \App\Db\Command) Open
Open
class Command extends \yii\db\Command
- Exclude checks
@throws type of queryAllByGroup
has undeclared type \App\Db\Exception
(Did you mean class \Exception) Open
Open
public function queryAllByGroup(int $type = 0)
- Exclude checks
Call to undeclared method \App\Db\Command::queryInternal
Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_GROUP | \PDO::FETCH_UNIQUE | \PDO::FETCH_ASSOC);
- Exclude checks
Call to undeclared method \App\Db\Command::queryInternal
Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_KEY_PAIR);
- Exclude checks
Return type of query()
is undeclared type \yii\db\DataReader
Open
Open
public function query()
- Exclude checks
Call to undeclared method \App\Db\Command::queryInternal
Open
Open
return $this->queryInternal('');
- Exclude checks
Call to undeclared method \App\Db\Command::queryInternal
Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_GROUP | \PDO::FETCH_COLUMN | \PDO::FETCH_ASSOC);
- Exclude checks
Define a constant instead of duplicating this literal "fetchAll" 3 times. Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_KEY_PAIR);
- 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.
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function queryAllByGroup(int $type = 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @throws Exception execution failed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return array all rows of the query result. Each array element is an array representing a row of data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* This method is for executing a SQL query that returns result set, such as `SELECT`.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return \yii\db\DataReader the reader object for fetching the query result
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->queryInternal('');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
switch ($type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_KEY_PAIR);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param int $type - fetchMode the result fetch mode. Please refer to [PHP manual](https://secure.php.net/manual/en/function.PDOStatement-setFetchMode.php))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_GROUP | \PDO::FETCH_UNIQUE | \PDO::FETCH_ASSOC);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function query()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* for valid fetch modes. If this parameter is null, the value set in [[fetchMode]] will be used
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Executes the SQL statement and returns ALL rows at once.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
case 0:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Executes the SQL statement and returns query result.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
case 2:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->queryInternal('fetchAll', \PDO::FETCH_GROUP | \PDO::FETCH_COLUMN | \PDO::FETCH_ASSOC);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
case 1:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* An empty array is returned if the query results in nothing
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
Open
* @param int $type - fetchMode the result fetch mode. Please refer to [PHP manual](https://secure.php.net/manual/en/function.PDOStatement-setFetchMode.php))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @throws Exception execution failed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks