Avoid using static access to class '\Yii' in method 'each'. Open
return \Yii::createObject([
'class' => \yii\db\BatchQueryResult::class,
'query' => $this,
'batchSize' => $batchSize,
'db' => $db,
- Read upRead up
- Exclude checks
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 '\App\Db' in method 'each'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
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 '\Yii' in method 'batch'. Open
return \Yii::createObject([
'class' => \yii\db\BatchQueryResult::className(),
'query' => $this,
'batchSize' => $batchSize,
'db' => $db,
- Read upRead up
- Exclude checks
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 '\yii\db\BatchQueryResult' in method 'batch'. Open
'class' => \yii\db\BatchQueryResult::className(),
- Read upRead up
- Exclude checks
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 '\App\Db' in method 'createCommand'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
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 '\App\Db' in method 'batch'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
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
Static call to undeclared method \Yii::createObject
Open
return \Yii::createObject([
- Exclude checks
Reference to undeclared property \App\Db\Query->having
Open
&& empty($this->having)
- Exclude checks
Call to undeclared method \App\Db\Query::setCommandCache
Open
$this->setCommandCache($command);
- Exclude checks
Reference to undeclared property \App\Db\Query->union
Open
&& empty($this->union)) {
- Exclude checks
Call to undeclared method \App\Db::getQueryBuilder
Open
[$sql, $params] = $db->getQueryBuilder()->build($this);
- Exclude checks
Call to method className
from undeclared class \yii\db\BatchQueryResult
Open
'class' => \yii\db\BatchQueryResult::className(),
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$command = (new static())
- Exclude checks
Call to undeclared method \App\Db\Query::limit
Open
return $this->limit(1)->createCommand($db)->queryOne();
- Exclude checks
Reference to undeclared property \App\Db\Query->distinct
Open
if (!$this->distinct
- Exclude checks
Reference to undeclared property \App\Db\Query->groupBy
Open
&& empty($this->groupBy)
- Exclude checks
Static call to undeclared method \Yii::createObject
Open
return \Yii::createObject([
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
return $db->createCommand($sql, $params);
- Exclude checks
Class extends undeclared class \yii\db\Query
(Did you mean class \App\Db\Query) Open
class Query extends \yii\db\Query
- Exclude checks
Reference to constant class
from undeclared class \yii\db\BatchQueryResult
Open
'class' => \yii\db\BatchQueryResult::class,
- Exclude checks
Reference to undeclared class \yii\db\Query
(Did you mean class \App\Db\Query) Open
return parent::queryScalar($selectExpression, $db);
- Exclude checks
Return type of each()
is undeclared type \yii\db\BatchQueryResult
Open
public function each($batchSize = 100, $db = null)
- Exclude checks
Return type of batch()
is undeclared type \yii\db\BatchQueryResult
Open
public function batch($batchSize = 100, $db = null)
- Exclude checks
Call to undeclared method \App\Db\Query::limit
Open
return $this->limit(1)->createCommand($db)->queryScalar();
- Exclude checks
Parameter $selectExpression
has undeclared type \App\Db\ExpressionInterface
Open
protected function queryScalar($selectExpression, $db)
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function batch($batchSize = 100, $db = null)
- Read upRead up
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function one($db = null)
- Read upRead up
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function scalar($db = null)
- Read upRead up
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function createCommand($db = null)
- Read upRead up
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
protected function queryScalar($selectExpression, $db)
- Read upRead up
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function each($batchSize = 100, $db = null)
- Read upRead up
- 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
Spaces must be used to indent lines; tabs are not allowed Open
* and can be traversed to retrieve the data in batches.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \Yii::createObject([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'batchSize' => $batchSize,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Creates a DB command that can be used to execute this query.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createCommand($db = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* A batch query supports fetching data in batches, which can keep the memory usage under a limit.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'query' => $this,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $db) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* and can be traversed to retrieve the data in batches.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $db) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $db->createCommand($sql, $params);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $batchSize the number of records to be fetched in each batch.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \yii\db\BatchQueryResult the batch query result. It implements the [[\Iterator]] interface
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Db $db the database connection used to generate the SQL statement.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This method will return a [[BatchQueryResult]] object which implements the [[\Iterator]] interface
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'db' => $db,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Command the created DB command instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Starts a batch query.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function batch($batchSize = 100, $db = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$sql, $params] = $db->getQueryBuilder()->build($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'class' => \yii\db\BatchQueryResult::className(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'each' => false,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $batchSize the number of records to be fetched in each batch.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \yii\db\BatchQueryResult the batch query result. It implements the [[\Iterator]] interface
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'query' => $this,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|ExpressionInterface $selectExpression
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Db|null $db
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function each($batchSize = 100, $db = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \Yii::createObject([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'db' => $db,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->limit(1)->createCommand($db)->queryOne();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns the query result as a scalar value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Db $db the database connection used to generate the SQL statement.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select([$selectExpression])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand($db);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Db $db the database connection. If not set, the "db" application component will be used.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* only one row of data is returned. For example,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Db $db the database connection. If not set, the "db" application component will be used.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* and can be traversed to retrieve the data in batches.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* If this parameter is not given, the `db` application component will be used.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string|false|null the value of the first column in the first row of the query result.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->distinct
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $command->queryScalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* results in nothing.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Restores the value of select to make this query reusable.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$command = (new static())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'class' => \yii\db\BatchQueryResult::class,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function scalar($db = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $db) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function queryScalar($selectExpression, $db)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& empty($this->union)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from(['c' => $this])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Executes the query and returns a single row of result.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setCommandCache($command);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* If this parameter is not given, the `db` application component will be used.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Queries a scalar value by setting [[select]] first.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* If this parameter is not given, the `db` application component will be used.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'batchSize' => $batchSize,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Db $db the database connection used to generate the SQL statement.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return parent::queryScalar($selectExpression, $db);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* The value returned will be the first column in the first row of the query results.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This method is similar to [[batch()]] except that in each iteration of the result,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'each' => true,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array|bool the first row (in terms of an array) of the query result. False is returned if the query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->limit(1)->createCommand($db)->queryScalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& empty($this->groupBy)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Starts a batch query and retrieves data row by row.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function one($db = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* False is returned if the query result is empty.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& empty($this->having)
- Exclude checks