diff --git a/framework/YiiBase.php b/framework/YiiBase.php index c911f78..aeed6f5 100644 --- a/framework/YiiBase.php +++ b/framework/YiiBase.php @@ -451,12 +451,12 @@ class YiiBase } $args = func_get_args(); array_shift($args); // remove $config - if ($config !== array()) { + if (!empty($config)) { $args[] = $config; } return $reflection->newInstanceArgs($args); } else { - return $config === array() ? new $class : new $class($config); + return empty($config) ? new $class : new $class($config); } } diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 583de60..87f5b0e 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -183,7 +183,7 @@ class Controller extends Component } } - if ($missing !== array()) { + if (!empty($missing)) { throw new InvalidRequestException(Yii::t('yii|Missing required parameters: {params}', array( '{params}' => implode(', ', $missing), ))); diff --git a/framework/base/Dictionary.php b/framework/base/Dictionary.php index 52262cb..5807d93 100644 --- a/framework/base/Dictionary.php +++ b/framework/base/Dictionary.php @@ -51,7 +51,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co */ public function __construct($data = array(), $config = array()) { - if ($data !== array()) { + if (!empty($data)) { $this->copyFrom($data); } parent::__construct($config); @@ -187,7 +187,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co public function copyFrom($data) { if (is_array($data) || $data instanceof \Traversable) { - if ($this->_d !== array()) { + if (!empty($this->_d)) { $this->removeAll(); } if ($data instanceof self) { diff --git a/framework/base/Vector.php b/framework/base/Vector.php index 7d43fdb..6418077 100644 --- a/framework/base/Vector.php +++ b/framework/base/Vector.php @@ -58,7 +58,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta */ public function __construct($data = array(), $config = array()) { - if ($data !== array()) { + if (!empty($data)) { $this->copyFrom($data); } parent::__construct($config); diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 2eaf4b8..b168ff1 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -45,7 +45,7 @@ class Controller extends \yii\base\Controller */ public function runAction($id, $params = array()) { - if ($params !== array()) { + if (!empty($params)) { $options = $this->globalOptions(); foreach ($params as $name => $value) { if (in_array($name, $options, true)) { @@ -69,7 +69,7 @@ class Controller extends \yii\base\Controller */ public function bindActionParams($action, $params) { - if ($params !== array()) { + if (!empty($params)) { $options = $this->globalOptions(); foreach ($params as $name => $value) { if (in_array($name, $options, true)) { @@ -81,7 +81,7 @@ class Controller extends \yii\base\Controller $args = isset($params[Request::ANONYMOUS_PARAMS]) ? $params[Request::ANONYMOUS_PARAMS] : array(); unset($params[Request::ANONYMOUS_PARAMS]); - if ($params !== array()) { + if (!empty($params)) { throw new Exception(Yii::t('yii|Unknown options: {params}', array( '{params}' => implode(', ', array_keys($params)), ))); @@ -105,7 +105,7 @@ class Controller extends \yii\base\Controller } } - if ($missing !== array()) { + if (!empty($missing)) { throw new Exception(Yii::t('yii|Missing required arguments: {params}', array( '{params}' => implode(', ', $missing), ))); diff --git a/framework/console/controllers/HelpController.php b/framework/console/controllers/HelpController.php index 82bd6fe..6a66fd0 100644 --- a/framework/console/controllers/HelpController.php +++ b/framework/console/controllers/HelpController.php @@ -142,7 +142,7 @@ class HelpController extends Controller protected function getHelp() { $commands = $this->getCommands(); - if ($commands !== array()) { + if (!empty($commands)) { echo "The following commands are available:\n\n"; foreach ($commands as $command) { echo "* $command\n"; @@ -172,7 +172,7 @@ class HelpController extends Controller } $actions = $this->getActions($controller); - if ($actions !== array()) { + if (!empty($actions)) { echo "\nSUB-COMMANDS\n\n"; $prefix = $controller->getUniqueId(); foreach ($actions as $action) { @@ -280,7 +280,7 @@ class HelpController extends Controller } $options = $this->getOptionHelps($controller); - if ($options !== array()) { + if (!empty($options)) { echo "\nOPTIONS\n\n"; echo implode("\n\n", $options) . "\n\n"; } diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index 3f816f1..fb06c66 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -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); diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 3999600..dac94c8 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -103,7 +103,7 @@ class ActiveQuery extends Query { $command = $this->createCommand(); $rows = $command->queryAll(); - if ($rows !== array()) { + if (!empty($rows)) { $models = $this->createModels($rows); if (!empty($this->with)) { $this->populateRelations($models, $this->with); diff --git a/framework/db/Command.php b/framework/db/Command.php index dc6c972..a117685 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -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(); diff --git a/framework/db/Query.php b/framework/db/Query.php index 6f76265..b1fc718 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -589,7 +589,7 @@ class Query extends \yii\base\Component */ public function addParams($params) { - if ($params !== array()) { + if (!empty($params)) { if ($this->params === null) { $this->params = $params; } else { diff --git a/framework/db/QueryBuilder.php b/framework/db/QueryBuilder.php index 441d287..5c5584e 100644 --- a/framework/db/QueryBuilder.php +++ b/framework/db/QueryBuilder.php @@ -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, ... @@ -777,7 +777,7 @@ class QueryBuilder extends \yii\base\Object $parts[] = $operand; } } - if ($parts !== array()) { + if (!empty($parts)) { return '(' . implode(") $operator (", $parts) . ')'; } else { return ''; @@ -813,7 +813,7 @@ class QueryBuilder extends \yii\base\Object $values = (array)$values; - if ($values === array() || $column === array()) { + if (empty($values) || $column === array()) { 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' : ''; } diff --git a/framework/helpers/base/ArrayHelper.php b/framework/helpers/base/ArrayHelper.php index 86445d7..672c7b9 100644 --- a/framework/helpers/base/ArrayHelper.php +++ b/framework/helpers/base/ArrayHelper.php @@ -36,7 +36,7 @@ class ArrayHelper { $args = func_get_args(); $res = array_shift($args); - while ($args !== array()) { + while (!empty($args)) { $next = array_shift($args); foreach ($next as $k => $v) { if (is_integer($k)) { diff --git a/framework/helpers/base/Html.php b/framework/helpers/base/Html.php index 15db823..f601772 100644 --- a/framework/helpers/base/Html.php +++ b/framework/helpers/base/Html.php @@ -324,7 +324,7 @@ class Html $options['action'] = $action; $options['method'] = $method; $form = static::beginTag('form', $options); - if ($hiddenInputs !== array()) { + if (!empty($hiddenInputs)) { $form .= "\n" . implode("\n", $hiddenInputs); } @@ -618,7 +618,7 @@ class Html * is present, a hidden input will be generated so that if the radio button is not checked and is submitted, * the value of this attribute will still be submitted to the server via the hidden input. * - * The rest of the options will be rendered as the attributes of the resulting tag. The values will + * The rest of the options will be rendered as the attributes of the resulting tag. The values will * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. * * @return string the generated radio button tag @@ -647,7 +647,7 @@ class Html * is present, a hidden input will be generated so that if the checkbox is not checked and is submitted, * the value of this attribute will still be submitted to the server via the hidden input. * - * The rest of the options will be rendered as the attributes of the resulting tag. The values will + * The rest of the options will be rendered as the attributes of the resulting tag. The values will * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. * * @return string the generated checkbox tag @@ -694,9 +694,9 @@ class Html * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', * except that the array keys represent the optgroup labels specified in $items. * - * The rest of the options will be rendered as the attributes of the resulting tag. The values will + * The rest of the options will be rendered as the attributes of the resulting tag. The values will * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. - * + * * @return string the generated drop-down list tag */ public static function dropDownList($name, $selection = null, $items = array(), $options = array()) @@ -737,9 +737,9 @@ class Html * When this attribute is set, a hidden field will be generated so that if no option is selected in multiple * mode, we can still obtain the posted unselect value. * - * The rest of the options will be rendered as the attributes of the resulting tag. The values will + * The rest of the options will be rendered as the attributes of the resulting tag. The values will * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. - * + * * @return string the generated list box tag */ public static function listBox($name, $selection = null, $items = array(), $options = array()) diff --git a/framework/helpers/base/Json.php b/framework/helpers/base/Json.php index 262dd81..8de55f9 100644 --- a/framework/helpers/base/Json.php +++ b/framework/helpers/base/Json.php @@ -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); } /** diff --git a/framework/i18n/I18N.php b/framework/i18n/I18N.php index 8667abc..7fae5b0 100644 --- a/framework/i18n/I18N.php +++ b/framework/i18n/I18N.php @@ -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); } /** diff --git a/framework/validators/FileValidator.php b/framework/validators/FileValidator.php index ebe6cad..cc36d07 100644 --- a/framework/validators/FileValidator.php +++ b/framework/validators/FileValidator.php @@ -116,7 +116,7 @@ class FileValidator extends Validator } if (!is_array($this->types)) { $this->types = preg_split('/[\s,]+/', strtolower($this->types), -1, PREG_SPLIT_NO_EMPTY); - } + } } /** @@ -138,8 +138,8 @@ class FileValidator extends Validator } } $object->$attribute = array_values($files); - if ($files === array()) { - $this->addError($object, $attribute, $this->uploadRequired); + if (empty($files)) { + $this->addError($object, $attribute, $this->uploadRequired); } if (count($files) > $this->maxFiles) { $this->addError($object, $attribute, $this->tooMany, array('{attribute}' => $attribute, '{limit}' => $this->maxFiles)); @@ -153,7 +153,7 @@ class FileValidator extends Validator if ($file instanceof UploadedFile && $file->getError() != UPLOAD_ERR_NO_FILE) { $this->validateFile($object, $attribute, $file); } else { - $this->addError($object, $attribute, $this->uploadRequired); + $this->addError($object, $attribute, $this->uploadRequired); } } } diff --git a/framework/web/Sort.php b/framework/web/Sort.php index 99084c1..324e733 100644 --- a/framework/web/Sort.php +++ b/framework/web/Sort.php @@ -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; } } diff --git a/framework/web/UrlManager.php b/framework/web/UrlManager.php index a300033..aab7979 100644 --- a/framework/web/UrlManager.php +++ b/framework/web/UrlManager.php @@ -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)) { @@ -190,13 +190,13 @@ class UrlManager extends Component if ($this->suffix !== null) { $route .= $this->suffix; } - if ($params !== array()) { + if (!empty($params)) { $route .= '?' . http_build_query($params); } return rtrim($baseUrl, '/') . '/' . $route . $anchor; } else { $url = $baseUrl . '?' . $this->routeVar . '=' . $route; - if ($params !== array()) { + if (!empty($params)) { $url .= '&' . http_build_query($params); } return $url; diff --git a/framework/web/UrlRule.php b/framework/web/UrlRule.php index d9cb4fd..53bd747 100644 --- a/framework/web/UrlRule.php +++ b/framework/web/UrlRule.php @@ -144,7 +144,7 @@ class UrlRule extends Object $this->_template = preg_replace('/<(\w+):?([^>]+)?>/', '<$1>', $this->pattern); $this->pattern = '#^' . trim(strtr($this->_template, $tr), '/') . '$#u'; - if ($this->_routeParams !== array()) { + if (!empty($this->_routeParams)) { $this->_routeRule = '#^' . strtr($this->route, $tr2) . '$#u'; } } @@ -275,7 +275,7 @@ class UrlRule extends Object $url .= ($this->suffix === null ? $manager->suffix : $this->suffix); } - if ($params !== array()) { + if (!empty($params)) { $url .= '?' . http_build_query($params); } return $url; diff --git a/framework/widgets/ActiveField.php b/framework/widgets/ActiveField.php index 0e0381f..aaa9470 100644 --- a/framework/widgets/ActiveField.php +++ b/framework/widgets/ActiveField.php @@ -104,7 +104,7 @@ class ActiveField extends Component public function begin() { $options = $this->getClientOptions(); - if ($options !== array()) { + if (!empty($options)) { $this->form->attributes[$this->attribute] = $options; } @@ -123,7 +123,7 @@ class ActiveField extends Component return Html::beginTag($this->tag, $options); } - + public function end() { return Html::endTag($this->tag); @@ -143,7 +143,7 @@ class ActiveField extends Component $validators[] = $js; } } - if ($validators !== array()) { + if (!empty($validators)) { $options['validate'] = new JsExpression("function(attribute,value,messages){" . implode('', $validators) . '}'); } } diff --git a/framework/widgets/ActiveForm.php b/framework/widgets/ActiveForm.php index 61416e2..24451b9 100644 --- a/framework/widgets/ActiveForm.php +++ b/framework/widgets/ActiveForm.php @@ -130,7 +130,7 @@ class ActiveForm extends Widget */ public function run() { - if ($this->attributes !== array()) { + if (!empty($this->attributes)) { $id = $this->options['id']; $options = Json::encode($this->getClientOptions()); $attributes = Json::encode($this->attributes); @@ -197,7 +197,7 @@ class ActiveForm extends Widget $options['class'] .= ' ' . $this->errorSummaryCssClass; } - if ($lines !== array()) { + if (!empty($lines)) { $content = "