From 68c30c1034c41695049043668e766e2cd7eb56e9 Mon Sep 17 00:00:00 2001 From: Alexander Mohorev Date: Mon, 29 Jun 2015 22:59:22 +0300 Subject: [PATCH] Replace aliases of functions --- framework/base/ArrayableTrait.php | 4 ++-- framework/base/DynamicModel.php | 2 +- framework/base/Security.php | 6 +++--- framework/console/Application.php | 2 +- framework/db/ActiveQuery.php | 4 ++-- framework/db/ActiveQueryTrait.php | 4 ++-- framework/db/BaseActiveRecord.php | 2 +- framework/db/Query.php | 2 +- framework/filters/ContentNegotiator.php | 4 ++-- framework/helpers/BaseArrayHelper.php | 4 ++-- framework/helpers/BaseVarDumper.php | 2 +- framework/rest/UrlRule.php | 2 +- framework/test/FixtureTrait.php | 2 +- framework/validators/ExistValidator.php | 2 +- framework/validators/FileValidator.php | 4 ++-- framework/validators/UniqueValidator.php | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/framework/base/ArrayableTrait.php b/framework/base/ArrayableTrait.php index 8b17323c85..308feeea1b 100644 --- a/framework/base/ArrayableTrait.php +++ b/framework/base/ArrayableTrait.php @@ -141,7 +141,7 @@ trait ArrayableTrait $result = []; foreach ($this->fields() as $field => $definition) { - if (is_integer($field)) { + if (is_int($field)) { $field = $definition; } if (empty($fields) || in_array($field, $fields, true)) { @@ -154,7 +154,7 @@ trait ArrayableTrait } foreach ($this->extraFields() as $field => $definition) { - if (is_integer($field)) { + if (is_int($field)) { $field = $definition; } if (in_array($field, $expand, true)) { diff --git a/framework/base/DynamicModel.php b/framework/base/DynamicModel.php index d1650c0840..69e271aa7f 100644 --- a/framework/base/DynamicModel.php +++ b/framework/base/DynamicModel.php @@ -66,7 +66,7 @@ class DynamicModel extends Model public function __construct(array $attributes = [], $config = []) { foreach ($attributes as $name => $value) { - if (is_integer($name)) { + if (is_int($name)) { $this->_attributes[$value] = null; } else { $this->_attributes[$name] = $value; diff --git a/framework/base/Security.php b/framework/base/Security.php index 436e3cafff..5dc5f1d984 100644 --- a/framework/base/Security.php +++ b/framework/base/Security.php @@ -270,7 +270,7 @@ class Security extends Component if (is_string($length) && preg_match('{^\d{1,16}$}', $length)) { $length = (int) $length; } - if (!is_integer($length) || $length < 0 || $length > 255 * $hashLength) { + if (!is_int($length) || $length < 0 || $length > 255 * $hashLength) { throw new InvalidParamException('Invalid length'); } $blocks = $length !== 0 ? ceil($length / $hashLength) : 1; @@ -325,13 +325,13 @@ class Security extends Component if (is_string($iterations) && preg_match('{^\d{1,16}$}', $iterations)) { $iterations = (int) $iterations; } - if (!is_integer($iterations) || $iterations < 1) { + if (!is_int($iterations) || $iterations < 1) { throw new InvalidParamException('Invalid iterations'); } if (is_string($length) && preg_match('{^\d{1,16}$}', $length)) { $length = (int) $length; } - if (!is_integer($length) || $length < 0) { + if (!is_int($length) || $length < 0) { throw new InvalidParamException('Invalid length'); } $hashLength = StringHelper::byteLength($test); diff --git a/framework/console/Application.php b/framework/console/Application.php index 1314eae6e3..19b41665ab 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -97,7 +97,7 @@ class Application extends \yii\base\Application if (!empty($path) && is_file($file = Yii::getAlias($path))) { return require($file); } else { - die("The configuration file does not exist: $path\n"); + exit("The configuration file does not exist: $path\n"); } } } diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 5088547c0d..098031925b 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -408,7 +408,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface if (is_array($eagerLoading)) { foreach ($with as $name => $callback) { - if (is_integer($name)) { + if (is_int($name)) { if (!in_array($callback, $eagerLoading, true)) { unset($with[$name]); } @@ -463,7 +463,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface $relations = []; foreach ($with as $name => $callback) { - if (is_integer($name)) { + if (is_int($name)) { $name = $callback; $callback = null; } diff --git a/framework/db/ActiveQueryTrait.php b/framework/db/ActiveQueryTrait.php index fa2b18208c..aa1acdbd89 100644 --- a/framework/db/ActiveQueryTrait.php +++ b/framework/db/ActiveQueryTrait.php @@ -91,7 +91,7 @@ trait ActiveQueryTrait $this->with = $with; } elseif (!empty($with)) { foreach ($with as $name => $value) { - if (is_integer($name)) { + if (is_int($name)) { // repeating relation is fine as normalizeRelations() handle it well $this->with[] = $value; } else { @@ -180,7 +180,7 @@ trait ActiveQueryTrait { $relations = []; foreach ($with as $name => $callback) { - if (is_integer($name)) { + if (is_int($name)) { $name = $callback; $callback = null; } diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 8897fcfffb..545a51a7a0 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -675,7 +675,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface { $attrs = []; foreach ($attributes as $name => $value) { - if (is_integer($name)) { + if (is_int($name)) { $attrs[] = $value; } else { $this->$name = $value; diff --git a/framework/db/Query.php b/framework/db/Query.php index da48cb7ee8..92a345bdba 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -790,7 +790,7 @@ class Query extends Component implements QueryInterface $this->params = $params; } else { foreach ($params as $name => $value) { - if (is_integer($name)) { + if (is_int($name)) { $this->params[] = $value; } else { $this->params[$name] = $value; diff --git a/framework/filters/ContentNegotiator.php b/framework/filters/ContentNegotiator.php index 9a34b0f7eb..7d2bfc5d21 100644 --- a/framework/filters/ContentNegotiator.php +++ b/framework/filters/ContentNegotiator.php @@ -220,7 +220,7 @@ class ContentNegotiator extends ActionFilter implements BootstrapInterface return $this->languages[$language]; } foreach ($this->languages as $key => $supported) { - if (is_integer($key) && $this->isLanguageSupported($language, $supported)) { + if (is_int($key) && $this->isLanguageSupported($language, $supported)) { return $supported; } } @@ -232,7 +232,7 @@ class ContentNegotiator extends ActionFilter implements BootstrapInterface return $this->languages[$language]; } foreach ($this->languages as $key => $supported) { - if (is_integer($key) && $this->isLanguageSupported($language, $supported)) { + if (is_int($key) && $this->isLanguageSupported($language, $supported)) { return $supported; } } diff --git a/framework/helpers/BaseArrayHelper.php b/framework/helpers/BaseArrayHelper.php index ca35151616..4d8fdd3c8a 100644 --- a/framework/helpers/BaseArrayHelper.php +++ b/framework/helpers/BaseArrayHelper.php @@ -119,7 +119,7 @@ class BaseArrayHelper while (!empty($args)) { $next = array_shift($args); foreach ($next as $k => $v) { - if (is_integer($k)) { + if (is_int($k)) { if (isset($res[$k])) { $res[] = $v; } else { @@ -577,7 +577,7 @@ class BaseArrayHelper return array_keys($array) === range(0, count($array) - 1); } else { foreach ($array as $key => $value) { - if (!is_integer($key)) { + if (!is_int($key)) { return false; } } diff --git a/framework/helpers/BaseVarDumper.php b/framework/helpers/BaseVarDumper.php index 5697162cba..44daaa247c 100644 --- a/framework/helpers/BaseVarDumper.php +++ b/framework/helpers/BaseVarDumper.php @@ -163,7 +163,7 @@ class BaseVarDumper self::$_output .= '[]'; } else { $keys = array_keys($var); - $outputKeys = ($keys !== range(0, sizeof($var) - 1)); + $outputKeys = ($keys !== range(0, count($var) - 1)); $spaces = str_repeat(' ', $level * 4); self::$_output .= '['; foreach ($keys as $key) { diff --git a/framework/rest/UrlRule.php b/framework/rest/UrlRule.php index f0286d105a..83b3783bb5 100644 --- a/framework/rest/UrlRule.php +++ b/framework/rest/UrlRule.php @@ -147,7 +147,7 @@ class UrlRule extends CompositeUrlRule $controllers = []; foreach ((array) $this->controller as $urlName => $controller) { - if (is_integer($urlName)) { + if (is_int($urlName)) { $urlName = $this->pluralize ? Inflector::pluralize($controller) : $controller; } $controllers[$urlName] = $controller; diff --git a/framework/test/FixtureTrait.php b/framework/test/FixtureTrait.php index e67d12d684..463cc565f7 100644 --- a/framework/test/FixtureTrait.php +++ b/framework/test/FixtureTrait.php @@ -168,7 +168,7 @@ trait FixtureTrait if (!is_array($fixture)) { $class = ltrim($fixture, '\\'); $fixtures[$name] = ['class' => $class]; - $aliases[$class] = is_integer($name) ? $class : $name; + $aliases[$class] = is_int($name) ? $class : $name; } elseif (isset($fixture['class'])) { $class = ltrim($fixture['class'], '\\'); $config[$class] = $fixture; diff --git a/framework/validators/ExistValidator.php b/framework/validators/ExistValidator.php index bc6e7a5095..51be2cb9c7 100644 --- a/framework/validators/ExistValidator.php +++ b/framework/validators/ExistValidator.php @@ -91,7 +91,7 @@ class ExistValidator extends Validator } $params = []; foreach ($targetAttribute as $k => $v) { - $params[$v] = is_integer($k) ? $model->$v : $model->$k; + $params[$v] = is_int($k) ? $model->$v : $model->$k; } } else { $params = [$targetAttribute => $model->$attribute]; diff --git a/framework/validators/FileValidator.php b/framework/validators/FileValidator.php index 337bc4b0ac..f9ba37570c 100644 --- a/framework/validators/FileValidator.php +++ b/framework/validators/FileValidator.php @@ -370,7 +370,7 @@ class FileValidator extends Validator $options['mimeTypes'] = $this->mimeTypes; $options['wrongMimeType'] = Yii::$app->getI18n()->format($this->wrongMimeType, [ 'attribute' => $label, - 'mimeTypes' => join(', ', $this->mimeTypes), + 'mimeTypes' => implode(', ', $this->mimeTypes), ], Yii::$app->language); } @@ -378,7 +378,7 @@ class FileValidator extends Validator $options['extensions'] = $this->extensions; $options['wrongExtension'] = Yii::$app->getI18n()->format($this->wrongExtension, [ 'attribute' => $label, - 'extensions' => join(', ', $this->extensions), + 'extensions' => implode(', ', $this->extensions), ], Yii::$app->language); } diff --git a/framework/validators/UniqueValidator.php b/framework/validators/UniqueValidator.php index 4612405a16..19882c607f 100644 --- a/framework/validators/UniqueValidator.php +++ b/framework/validators/UniqueValidator.php @@ -83,7 +83,7 @@ class UniqueValidator extends Validator if (is_array($targetAttribute)) { $params = []; foreach ($targetAttribute as $k => $v) { - $params[$v] = is_integer($k) ? $model->$v : $model->$k; + $params[$v] = is_int($k) ? $model->$v : $model->$k; } } else { $params = [$targetAttribute => $model->$attribute];