mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-13 22:06:51 +08:00
=== array() => empty()
This commit is contained in:
@ -456,7 +456,7 @@ class YiiBase
|
||||
}
|
||||
return $reflection->newInstanceArgs($args);
|
||||
} else {
|
||||
return $config === array() ? new $class : new $class($config);
|
||||
return empty($config) ? new $class : new $class($config);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,8 @@ class MigrateController extends Controller
|
||||
*/
|
||||
public function actionUp($limit = 0)
|
||||
{
|
||||
if (($migrations = $this->getNewMigrations()) === array()) {
|
||||
$migrations = $this->getNewMigrations();
|
||||
if (empty($migrations)) {
|
||||
echo "No new migration found. Your system is up-to-date.\n";
|
||||
Yii::$app->end();
|
||||
}
|
||||
@ -198,7 +199,8 @@ class MigrateController extends Controller
|
||||
throw new Exception("The step argument must be greater than 0.");
|
||||
}
|
||||
|
||||
if (($migrations = $this->getMigrationHistory($limit)) === array()) {
|
||||
$migrations = $this->getMigrationHistory($limit);
|
||||
if (empty($migrations)) {
|
||||
echo "No migration has been done before.\n";
|
||||
return;
|
||||
}
|
||||
@ -244,7 +246,8 @@ class MigrateController extends Controller
|
||||
throw new Exception("The step argument must be greater than 0.");
|
||||
}
|
||||
|
||||
if (($migrations = $this->getMigrationHistory($limit)) === array()) {
|
||||
$migrations = $this->getMigrationHistory($limit);
|
||||
if (empty($migrations)) {
|
||||
echo "No migration has been done before.\n";
|
||||
return;
|
||||
}
|
||||
@ -407,7 +410,7 @@ class MigrateController extends Controller
|
||||
{
|
||||
$limit = (int)$limit;
|
||||
$migrations = $this->getMigrationHistory($limit);
|
||||
if ($migrations === array()) {
|
||||
if (empty($migrations)) {
|
||||
echo "No migration has been done before.\n";
|
||||
} else {
|
||||
$n = count($migrations);
|
||||
@ -441,7 +444,7 @@ class MigrateController extends Controller
|
||||
{
|
||||
$limit = (int)$limit;
|
||||
$migrations = $this->getNewMigrations();
|
||||
if ($migrations === array()) {
|
||||
if (empty($migrations)) {
|
||||
echo "No new migrations found. Your system is up-to-date.\n";
|
||||
} else {
|
||||
$n = count($migrations);
|
||||
|
@ -106,7 +106,7 @@ class Command extends \yii\base\Component
|
||||
*/
|
||||
public function getRawSql()
|
||||
{
|
||||
if ($this->_params === array()) {
|
||||
if (empty($this->_params)) {
|
||||
return $this->_sql;
|
||||
} else {
|
||||
$params = array();
|
||||
|
@ -722,7 +722,7 @@ class QueryBuilder extends \yii\base\Object
|
||||
|
||||
if (!is_array($condition)) {
|
||||
return (string)$condition;
|
||||
} elseif ($condition === array()) {
|
||||
} elseif (empty($condition)) {
|
||||
return '';
|
||||
}
|
||||
if (isset($condition[0])) { // operator format: operator, operand 1, operand 2, ...
|
||||
@ -813,7 +813,7 @@ class QueryBuilder extends \yii\base\Object
|
||||
|
||||
$values = (array)$values;
|
||||
|
||||
if ($values === array() || $column === array()) {
|
||||
if (empty($values) || empty($column)) {
|
||||
return $operator === 'IN' ? '0=1' : '';
|
||||
}
|
||||
|
||||
@ -885,7 +885,7 @@ class QueryBuilder extends \yii\base\Object
|
||||
|
||||
$values = (array)$values;
|
||||
|
||||
if ($values === array()) {
|
||||
if (empty($values)) {
|
||||
return $operator === 'LIKE' || $operator === 'OR LIKE' ? '0=1' : '';
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class Json
|
||||
$expressions = array();
|
||||
$value = static::processData($value, $expressions);
|
||||
$json = json_encode($value, $options);
|
||||
return $expressions === array() ? $json : strtr($json, $expressions);
|
||||
return empty($expressions) ? $json : strtr($json, $expressions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@ class I18N extends Component
|
||||
unset($params[0]);
|
||||
}
|
||||
|
||||
return $params === array() ? $message : strtr($message, $params);
|
||||
return empty($params) ? $message : strtr($message, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +138,7 @@ class FileValidator extends Validator
|
||||
}
|
||||
}
|
||||
$object->$attribute = array_values($files);
|
||||
if ($files === array()) {
|
||||
if (empty($files)) {
|
||||
$this->addError($object, $attribute, $this->uploadRequired);
|
||||
}
|
||||
if (count($files) > $this->maxFiles) {
|
||||
|
@ -262,7 +262,6 @@ abstract class Validator extends Component
|
||||
*/
|
||||
public function isEmpty($value, $trim = false)
|
||||
{
|
||||
return $value === null || $value === array() || $value === ''
|
||||
|| $trim && is_scalar($value) && trim($value) === '';
|
||||
return $value === null || empty($value) || $value === '' || $trim && is_scalar($value) && trim($value) === '';
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class Sort extends \yii\base\Object
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->_attributeOrders === array() && is_array($this->defaults)) {
|
||||
if (empty($this->_attributeOrders) && is_array($this->defaults)) {
|
||||
$this->_attributeOrders = $this->defaults;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class UrlManager extends Component
|
||||
*/
|
||||
protected function compileRules()
|
||||
{
|
||||
if (!$this->enablePrettyUrl || $this->rules === array()) {
|
||||
if (!$this->enablePrettyUrl || empty($this->rules)) {
|
||||
return;
|
||||
}
|
||||
if (is_string($this->cache)) {
|
||||
|
@ -107,7 +107,7 @@ class FragmentCache extends Widget
|
||||
$data = array($content, $this->dynamicPlaceholders);
|
||||
$this->cache->set($this->calculateKey(), $data, $this->duration, $this->dependency);
|
||||
|
||||
if ($this->view->cacheStack === array() && !empty($this->dynamicPlaceholders)) {
|
||||
if (empty($this->view->cacheStack) && !empty($this->dynamicPlaceholders)) {
|
||||
$content = $this->updateDynamicContent($content, $this->dynamicPlaceholders);
|
||||
}
|
||||
echo $content;
|
||||
@ -133,7 +133,7 @@ class FragmentCache extends Widget
|
||||
if (is_array($data) && count($data) === 2) {
|
||||
list ($content, $placeholders) = $data;
|
||||
if (is_array($placeholders) && count($placeholders) > 0) {
|
||||
if ($this->view->cacheStack === array()) {
|
||||
if (empty($this->view->cacheStack)) {
|
||||
// outermost cache: replace placeholder with dynamic content
|
||||
$content = $this->updateDynamicContent($content, $placeholders);
|
||||
}
|
||||
|
Reference in New Issue
Block a user