Commit 76d8e2b5 by Carsten Brandt

code style, fixes #3140

parent e5280470
...@@ -13,10 +13,10 @@ namespace yii\base; ...@@ -13,10 +13,10 @@ namespace yii\base;
* Note that ArrayAccessTrait requires the class using it contain a property named `data` which should be an array. * Note that ArrayAccessTrait requires the class using it contain a property named `data` which should be an array.
* The data will be exposed by ArrayAccessTrait to support accessing the class object like an array. * The data will be exposed by ArrayAccessTrait to support accessing the class object like an array.
* *
* @property array $data
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*
* @property array $data
*/ */
trait ArrayAccessTrait trait ArrayAccessTrait
{ {
......
...@@ -350,6 +350,7 @@ class Formatter extends Component ...@@ -350,6 +350,7 @@ class Formatter extends Component
if (is_string($value)) { if (is_string($value)) {
return is_numeric($value) || $value === '' ? (int) $value : strtotime($value); return is_numeric($value) || $value === '' ? (int) $value : strtotime($value);
} elseif ($value instanceof DateTime || $value instanceof \DateTimeInterface) { } elseif ($value instanceof DateTime || $value instanceof \DateTimeInterface) {
/** @var $value \DateTimeInterface */
return $value->getTimestamp(); return $value->getTimestamp();
} else { } else {
return (int) $value; return (int) $value;
......
...@@ -118,6 +118,7 @@ class FixtureController extends Controller ...@@ -118,6 +118,7 @@ class FixtureController extends Controller
* whitespace between names. * whitespace between names.
* @param array|string $fixtures * @param array|string $fixtures
* @param array|string $except * @param array|string $except
* @throws \yii\console\Exception in case no fixtures are found.
*/ */
public function actionUnload(array $fixtures, array $except = []) public function actionUnload(array $fixtures, array $except = [])
{ {
......
...@@ -257,7 +257,6 @@ trait ActiveRelationTrait ...@@ -257,7 +257,6 @@ trait ActiveRelationTrait
* @param ActiveRecordInterface[] $models models * @param ActiveRecordInterface[] $models models
* @param string $primaryName the primary relation name * @param string $primaryName the primary relation name
* @param string $name the relation name * @param string $name the relation name
* @return null
*/ */
private function populateInverseRelation(&$primaryModels, $models, $primaryName, $name) private function populateInverseRelation(&$primaryModels, $models, $primaryName, $name)
{ {
...@@ -368,6 +367,10 @@ trait ActiveRelationTrait ...@@ -368,6 +367,10 @@ trait ActiveRelationTrait
return $buckets; return $buckets;
} }
/**
* @param array $attributes the attributes to prefix
* @return array
*/
private function prefixKeyColumns($attributes) private function prefixKeyColumns($attributes)
{ {
if ($this instanceof ActiveQuery && (!empty($this->join) || !empty($this->joinWith))) { if ($this instanceof ActiveQuery && (!empty($this->join) || !empty($this->joinWith))) {
......
...@@ -911,7 +911,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface ...@@ -911,7 +911,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
*/ */
public function refresh() public function refresh()
{ {
/** @var ActiveQuery $record */ /** @var BaseActiveRecord $record */
$record = $this->findOne($this->getPrimaryKey(true)); $record = $this->findOne($this->getPrimaryKey(true));
if ($record === null) { if ($record === null) {
return false; return false;
......
...@@ -107,6 +107,7 @@ class Query extends Component implements QueryInterface ...@@ -107,6 +107,7 @@ class Query extends Component implements QueryInterface
*/ */
public $params = []; public $params = [];
/** /**
* Creates a DB command that can be used to execute this query. * Creates a DB command that can be used to execute this query.
* @param Connection $db the database connection used to generate the SQL statement. * @param Connection $db the database connection used to generate the SQL statement.
...@@ -201,7 +202,6 @@ class Query extends Component implements QueryInterface ...@@ -201,7 +202,6 @@ class Query extends Component implements QueryInterface
public function all($db = null) public function all($db = null)
{ {
$rows = $this->createCommand($db)->queryAll(); $rows = $this->createCommand($db)->queryAll();
return $this->prepareResult($rows); return $this->prepareResult($rows);
} }
...@@ -226,7 +226,6 @@ class Query extends Component implements QueryInterface ...@@ -226,7 +226,6 @@ class Query extends Component implements QueryInterface
} }
$result[$key] = $row; $result[$key] = $row;
} }
return $result; return $result;
} }
...@@ -343,7 +342,6 @@ class Query extends Component implements QueryInterface ...@@ -343,7 +342,6 @@ class Query extends Component implements QueryInterface
$this->select = [new Expression('1')]; $this->select = [new Expression('1')];
$command = $this->createCommand($db); $command = $this->createCommand($db);
$this->select = $select; $this->select = $select;
return $command->queryScalar() !== false; return $command->queryScalar() !== false;
} }
...@@ -404,7 +402,6 @@ class Query extends Component implements QueryInterface ...@@ -404,7 +402,6 @@ class Query extends Component implements QueryInterface
} }
$this->select = $columns; $this->select = $columns;
$this->selectOption = $option; $this->selectOption = $option;
return $this; return $this;
} }
...@@ -424,7 +421,6 @@ class Query extends Component implements QueryInterface ...@@ -424,7 +421,6 @@ class Query extends Component implements QueryInterface
} else { } else {
$this->select = array_merge($this->select, $columns); $this->select = array_merge($this->select, $columns);
} }
return $this; return $this;
} }
...@@ -436,7 +432,6 @@ class Query extends Component implements QueryInterface ...@@ -436,7 +432,6 @@ class Query extends Component implements QueryInterface
public function distinct($value = true) public function distinct($value = true)
{ {
$this->distinct = $value; $this->distinct = $value;
return $this; return $this;
} }
...@@ -462,7 +457,6 @@ class Query extends Component implements QueryInterface ...@@ -462,7 +457,6 @@ class Query extends Component implements QueryInterface
$tables = preg_split('/\s*,\s*/', trim($tables), -1, PREG_SPLIT_NO_EMPTY); $tables = preg_split('/\s*,\s*/', trim($tables), -1, PREG_SPLIT_NO_EMPTY);
} }
$this->from = $tables; $this->from = $tables;
return $this; return $this;
} }
...@@ -570,7 +564,6 @@ class Query extends Component implements QueryInterface ...@@ -570,7 +564,6 @@ class Query extends Component implements QueryInterface
$this->where = ['and', $this->where, $condition]; $this->where = ['and', $this->where, $condition];
} }
$this->addParams($params); $this->addParams($params);
return $this; return $this;
} }
...@@ -618,7 +611,6 @@ class Query extends Component implements QueryInterface ...@@ -618,7 +611,6 @@ class Query extends Component implements QueryInterface
public function join($type, $table, $on = '', $params = []) public function join($type, $table, $on = '', $params = [])
{ {
$this->join[] = [$type, $table, $on]; $this->join[] = [$type, $table, $on];
return $this->addParams($params); return $this->addParams($params);
} }
...@@ -643,7 +635,6 @@ class Query extends Component implements QueryInterface ...@@ -643,7 +635,6 @@ class Query extends Component implements QueryInterface
public function innerJoin($table, $on = '', $params = []) public function innerJoin($table, $on = '', $params = [])
{ {
$this->join[] = ['INNER JOIN', $table, $on]; $this->join[] = ['INNER JOIN', $table, $on];
return $this->addParams($params); return $this->addParams($params);
} }
...@@ -668,7 +659,6 @@ class Query extends Component implements QueryInterface ...@@ -668,7 +659,6 @@ class Query extends Component implements QueryInterface
public function leftJoin($table, $on = '', $params = []) public function leftJoin($table, $on = '', $params = [])
{ {
$this->join[] = ['LEFT JOIN', $table, $on]; $this->join[] = ['LEFT JOIN', $table, $on];
return $this->addParams($params); return $this->addParams($params);
} }
...@@ -693,7 +683,6 @@ class Query extends Component implements QueryInterface ...@@ -693,7 +683,6 @@ class Query extends Component implements QueryInterface
public function rightJoin($table, $on = '', $params = []) public function rightJoin($table, $on = '', $params = [])
{ {
$this->join[] = ['RIGHT JOIN', $table, $on]; $this->join[] = ['RIGHT JOIN', $table, $on];
return $this->addParams($params); return $this->addParams($params);
} }
...@@ -712,7 +701,6 @@ class Query extends Component implements QueryInterface ...@@ -712,7 +701,6 @@ class Query extends Component implements QueryInterface
$columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY); $columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY);
} }
$this->groupBy = $columns; $this->groupBy = $columns;
return $this; return $this;
} }
...@@ -735,7 +723,6 @@ class Query extends Component implements QueryInterface ...@@ -735,7 +723,6 @@ class Query extends Component implements QueryInterface
} else { } else {
$this->groupBy = array_merge($this->groupBy, $columns); $this->groupBy = array_merge($this->groupBy, $columns);
} }
return $this; return $this;
} }
...@@ -752,7 +739,6 @@ class Query extends Component implements QueryInterface ...@@ -752,7 +739,6 @@ class Query extends Component implements QueryInterface
{ {
$this->having = $condition; $this->having = $condition;
$this->addParams($params); $this->addParams($params);
return $this; return $this;
} }
...@@ -774,7 +760,6 @@ class Query extends Component implements QueryInterface ...@@ -774,7 +760,6 @@ class Query extends Component implements QueryInterface
$this->having = ['and', $this->having, $condition]; $this->having = ['and', $this->having, $condition];
} }
$this->addParams($params); $this->addParams($params);
return $this; return $this;
} }
...@@ -796,7 +781,6 @@ class Query extends Component implements QueryInterface ...@@ -796,7 +781,6 @@ class Query extends Component implements QueryInterface
$this->having = ['or', $this->having, $condition]; $this->having = ['or', $this->having, $condition];
} }
$this->addParams($params); $this->addParams($params);
return $this; return $this;
} }
...@@ -809,7 +793,6 @@ class Query extends Component implements QueryInterface ...@@ -809,7 +793,6 @@ class Query extends Component implements QueryInterface
public function union($sql, $all = false) public function union($sql, $all = false)
{ {
$this->union[] = [ 'query' => $sql, 'all' => $all ]; $this->union[] = [ 'query' => $sql, 'all' => $all ];
return $this; return $this;
} }
...@@ -823,7 +806,6 @@ class Query extends Component implements QueryInterface ...@@ -823,7 +806,6 @@ class Query extends Component implements QueryInterface
public function params($params) public function params($params)
{ {
$this->params = $params; $this->params = $params;
return $this; return $this;
} }
...@@ -849,7 +831,6 @@ class Query extends Component implements QueryInterface ...@@ -849,7 +831,6 @@ class Query extends Component implements QueryInterface
} }
} }
} }
return $this; return $this;
} }
} }
...@@ -17,7 +17,7 @@ use yii\base\InvalidParamException; ...@@ -17,7 +17,7 @@ use yii\base\InvalidParamException;
*/ */
class QueryBuilder extends \yii\db\QueryBuilder class QueryBuilder extends \yii\db\QueryBuilder
{ {
private $sql; private $_sql;
/** /**
* @inheritdoc * @inheritdoc
...@@ -37,16 +37,16 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -37,16 +37,16 @@ class QueryBuilder extends \yii\db\QueryBuilder
$this->buildHaving($query->having, $params), $this->buildHaving($query->having, $params),
$this->buildOrderBy($query->orderBy), $this->buildOrderBy($query->orderBy),
]; ];
$this->sql = implode($this->separator, array_filter($clauses)); $this->_sql = implode($this->separator, array_filter($clauses));
$this->sql = $this->buildLimit($query->limit, $query->offset); $this->_sql = $this->buildLimit($query->limit, $query->offset);
$union = $this->buildUnion($query->union, $params); $union = $this->buildUnion($query->union, $params);
if ($union !== '') { if ($union !== '') {
$this->sql = "{$this->sql}{$this->separator}$union"; $this->_sql = "{$this->_sql}{$this->separator}$union";
} }
return [$this->sql, $params]; return [$this->_sql, $params];
} }
public function buildLimit($limit, $offset) public function buildLimit($limit, $offset)
...@@ -64,14 +64,14 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -64,14 +64,14 @@ class QueryBuilder extends \yii\db\QueryBuilder
$filter = implode(' and ', $filters); $filter = implode(' and ', $filters);
return <<<EOD return <<<EOD
WITH USER_SQL AS ({$this->sql}), WITH USER_SQL AS ({$this->_sql}),
PAGINATION AS (SELECT USER_SQL.*, rownum as rowNumId FROM USER_SQL) PAGINATION AS (SELECT USER_SQL.*, rownum as rowNumId FROM USER_SQL)
SELECT * SELECT *
FROM PAGINATION FROM PAGINATION
WHERE $filter WHERE $filter
EOD; EOD;
} else { } else {
return $this->sql; return $this->_sql;
} }
} }
......
...@@ -679,7 +679,8 @@ class Request extends \yii\base\Request ...@@ -679,7 +679,8 @@ class Request extends \yii\base\Request
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $pathInfo)) { )*$%xs', $pathInfo)
) {
$pathInfo = utf8_encode($pathInfo); $pathInfo = utf8_encode($pathInfo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment