mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Replace aliases of functions
This commit is contained in:
@ -141,7 +141,7 @@ trait ArrayableTrait
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->fields() as $field => $definition) {
|
foreach ($this->fields() as $field => $definition) {
|
||||||
if (is_integer($field)) {
|
if (is_int($field)) {
|
||||||
$field = $definition;
|
$field = $definition;
|
||||||
}
|
}
|
||||||
if (empty($fields) || in_array($field, $fields, true)) {
|
if (empty($fields) || in_array($field, $fields, true)) {
|
||||||
@ -154,7 +154,7 @@ trait ArrayableTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->extraFields() as $field => $definition) {
|
foreach ($this->extraFields() as $field => $definition) {
|
||||||
if (is_integer($field)) {
|
if (is_int($field)) {
|
||||||
$field = $definition;
|
$field = $definition;
|
||||||
}
|
}
|
||||||
if (in_array($field, $expand, true)) {
|
if (in_array($field, $expand, true)) {
|
||||||
|
|||||||
@ -66,7 +66,7 @@ class DynamicModel extends Model
|
|||||||
public function __construct(array $attributes = [], $config = [])
|
public function __construct(array $attributes = [], $config = [])
|
||||||
{
|
{
|
||||||
foreach ($attributes as $name => $value) {
|
foreach ($attributes as $name => $value) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
$this->_attributes[$value] = null;
|
$this->_attributes[$value] = null;
|
||||||
} else {
|
} else {
|
||||||
$this->_attributes[$name] = $value;
|
$this->_attributes[$name] = $value;
|
||||||
|
|||||||
@ -270,7 +270,7 @@ class Security extends Component
|
|||||||
if (is_string($length) && preg_match('{^\d{1,16}$}', $length)) {
|
if (is_string($length) && preg_match('{^\d{1,16}$}', $length)) {
|
||||||
$length = (int) $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');
|
throw new InvalidParamException('Invalid length');
|
||||||
}
|
}
|
||||||
$blocks = $length !== 0 ? ceil($length / $hashLength) : 1;
|
$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)) {
|
if (is_string($iterations) && preg_match('{^\d{1,16}$}', $iterations)) {
|
||||||
$iterations = (int) $iterations;
|
$iterations = (int) $iterations;
|
||||||
}
|
}
|
||||||
if (!is_integer($iterations) || $iterations < 1) {
|
if (!is_int($iterations) || $iterations < 1) {
|
||||||
throw new InvalidParamException('Invalid iterations');
|
throw new InvalidParamException('Invalid iterations');
|
||||||
}
|
}
|
||||||
if (is_string($length) && preg_match('{^\d{1,16}$}', $length)) {
|
if (is_string($length) && preg_match('{^\d{1,16}$}', $length)) {
|
||||||
$length = (int) $length;
|
$length = (int) $length;
|
||||||
}
|
}
|
||||||
if (!is_integer($length) || $length < 0) {
|
if (!is_int($length) || $length < 0) {
|
||||||
throw new InvalidParamException('Invalid length');
|
throw new InvalidParamException('Invalid length');
|
||||||
}
|
}
|
||||||
$hashLength = StringHelper::byteLength($test);
|
$hashLength = StringHelper::byteLength($test);
|
||||||
|
|||||||
@ -97,7 +97,7 @@ class Application extends \yii\base\Application
|
|||||||
if (!empty($path) && is_file($file = Yii::getAlias($path))) {
|
if (!empty($path) && is_file($file = Yii::getAlias($path))) {
|
||||||
return require($file);
|
return require($file);
|
||||||
} else {
|
} else {
|
||||||
die("The configuration file does not exist: $path\n");
|
exit("The configuration file does not exist: $path\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -408,7 +408,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
|
|
||||||
if (is_array($eagerLoading)) {
|
if (is_array($eagerLoading)) {
|
||||||
foreach ($with as $name => $callback) {
|
foreach ($with as $name => $callback) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
if (!in_array($callback, $eagerLoading, true)) {
|
if (!in_array($callback, $eagerLoading, true)) {
|
||||||
unset($with[$name]);
|
unset($with[$name]);
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
$relations = [];
|
$relations = [];
|
||||||
|
|
||||||
foreach ($with as $name => $callback) {
|
foreach ($with as $name => $callback) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
$name = $callback;
|
$name = $callback;
|
||||||
$callback = null;
|
$callback = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ trait ActiveQueryTrait
|
|||||||
$this->with = $with;
|
$this->with = $with;
|
||||||
} elseif (!empty($with)) {
|
} elseif (!empty($with)) {
|
||||||
foreach ($with as $name => $value) {
|
foreach ($with as $name => $value) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
// repeating relation is fine as normalizeRelations() handle it well
|
// repeating relation is fine as normalizeRelations() handle it well
|
||||||
$this->with[] = $value;
|
$this->with[] = $value;
|
||||||
} else {
|
} else {
|
||||||
@ -180,7 +180,7 @@ trait ActiveQueryTrait
|
|||||||
{
|
{
|
||||||
$relations = [];
|
$relations = [];
|
||||||
foreach ($with as $name => $callback) {
|
foreach ($with as $name => $callback) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
$name = $callback;
|
$name = $callback;
|
||||||
$callback = null;
|
$callback = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -675,7 +675,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
|||||||
{
|
{
|
||||||
$attrs = [];
|
$attrs = [];
|
||||||
foreach ($attributes as $name => $value) {
|
foreach ($attributes as $name => $value) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
$attrs[] = $value;
|
$attrs[] = $value;
|
||||||
} else {
|
} else {
|
||||||
$this->$name = $value;
|
$this->$name = $value;
|
||||||
|
|||||||
@ -790,7 +790,7 @@ class Query extends Component implements QueryInterface
|
|||||||
$this->params = $params;
|
$this->params = $params;
|
||||||
} else {
|
} else {
|
||||||
foreach ($params as $name => $value) {
|
foreach ($params as $name => $value) {
|
||||||
if (is_integer($name)) {
|
if (is_int($name)) {
|
||||||
$this->params[] = $value;
|
$this->params[] = $value;
|
||||||
} else {
|
} else {
|
||||||
$this->params[$name] = $value;
|
$this->params[$name] = $value;
|
||||||
|
|||||||
@ -220,7 +220,7 @@ class ContentNegotiator extends ActionFilter implements BootstrapInterface
|
|||||||
return $this->languages[$language];
|
return $this->languages[$language];
|
||||||
}
|
}
|
||||||
foreach ($this->languages as $key => $supported) {
|
foreach ($this->languages as $key => $supported) {
|
||||||
if (is_integer($key) && $this->isLanguageSupported($language, $supported)) {
|
if (is_int($key) && $this->isLanguageSupported($language, $supported)) {
|
||||||
return $supported;
|
return $supported;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ class ContentNegotiator extends ActionFilter implements BootstrapInterface
|
|||||||
return $this->languages[$language];
|
return $this->languages[$language];
|
||||||
}
|
}
|
||||||
foreach ($this->languages as $key => $supported) {
|
foreach ($this->languages as $key => $supported) {
|
||||||
if (is_integer($key) && $this->isLanguageSupported($language, $supported)) {
|
if (is_int($key) && $this->isLanguageSupported($language, $supported)) {
|
||||||
return $supported;
|
return $supported;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,7 +119,7 @@ class BaseArrayHelper
|
|||||||
while (!empty($args)) {
|
while (!empty($args)) {
|
||||||
$next = array_shift($args);
|
$next = array_shift($args);
|
||||||
foreach ($next as $k => $v) {
|
foreach ($next as $k => $v) {
|
||||||
if (is_integer($k)) {
|
if (is_int($k)) {
|
||||||
if (isset($res[$k])) {
|
if (isset($res[$k])) {
|
||||||
$res[] = $v;
|
$res[] = $v;
|
||||||
} else {
|
} else {
|
||||||
@ -577,7 +577,7 @@ class BaseArrayHelper
|
|||||||
return array_keys($array) === range(0, count($array) - 1);
|
return array_keys($array) === range(0, count($array) - 1);
|
||||||
} else {
|
} else {
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (!is_integer($key)) {
|
if (!is_int($key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,7 +163,7 @@ class BaseVarDumper
|
|||||||
self::$_output .= '[]';
|
self::$_output .= '[]';
|
||||||
} else {
|
} else {
|
||||||
$keys = array_keys($var);
|
$keys = array_keys($var);
|
||||||
$outputKeys = ($keys !== range(0, sizeof($var) - 1));
|
$outputKeys = ($keys !== range(0, count($var) - 1));
|
||||||
$spaces = str_repeat(' ', $level * 4);
|
$spaces = str_repeat(' ', $level * 4);
|
||||||
self::$_output .= '[';
|
self::$_output .= '[';
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
|
|||||||
@ -147,7 +147,7 @@ class UrlRule extends CompositeUrlRule
|
|||||||
|
|
||||||
$controllers = [];
|
$controllers = [];
|
||||||
foreach ((array) $this->controller as $urlName => $controller) {
|
foreach ((array) $this->controller as $urlName => $controller) {
|
||||||
if (is_integer($urlName)) {
|
if (is_int($urlName)) {
|
||||||
$urlName = $this->pluralize ? Inflector::pluralize($controller) : $controller;
|
$urlName = $this->pluralize ? Inflector::pluralize($controller) : $controller;
|
||||||
}
|
}
|
||||||
$controllers[$urlName] = $controller;
|
$controllers[$urlName] = $controller;
|
||||||
|
|||||||
@ -168,7 +168,7 @@ trait FixtureTrait
|
|||||||
if (!is_array($fixture)) {
|
if (!is_array($fixture)) {
|
||||||
$class = ltrim($fixture, '\\');
|
$class = ltrim($fixture, '\\');
|
||||||
$fixtures[$name] = ['class' => $class];
|
$fixtures[$name] = ['class' => $class];
|
||||||
$aliases[$class] = is_integer($name) ? $class : $name;
|
$aliases[$class] = is_int($name) ? $class : $name;
|
||||||
} elseif (isset($fixture['class'])) {
|
} elseif (isset($fixture['class'])) {
|
||||||
$class = ltrim($fixture['class'], '\\');
|
$class = ltrim($fixture['class'], '\\');
|
||||||
$config[$class] = $fixture;
|
$config[$class] = $fixture;
|
||||||
|
|||||||
@ -91,7 +91,7 @@ class ExistValidator extends Validator
|
|||||||
}
|
}
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach ($targetAttribute as $k => $v) {
|
foreach ($targetAttribute as $k => $v) {
|
||||||
$params[$v] = is_integer($k) ? $model->$v : $model->$k;
|
$params[$v] = is_int($k) ? $model->$v : $model->$k;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$params = [$targetAttribute => $model->$attribute];
|
$params = [$targetAttribute => $model->$attribute];
|
||||||
|
|||||||
@ -370,7 +370,7 @@ class FileValidator extends Validator
|
|||||||
$options['mimeTypes'] = $this->mimeTypes;
|
$options['mimeTypes'] = $this->mimeTypes;
|
||||||
$options['wrongMimeType'] = Yii::$app->getI18n()->format($this->wrongMimeType, [
|
$options['wrongMimeType'] = Yii::$app->getI18n()->format($this->wrongMimeType, [
|
||||||
'attribute' => $label,
|
'attribute' => $label,
|
||||||
'mimeTypes' => join(', ', $this->mimeTypes),
|
'mimeTypes' => implode(', ', $this->mimeTypes),
|
||||||
], Yii::$app->language);
|
], Yii::$app->language);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ class FileValidator extends Validator
|
|||||||
$options['extensions'] = $this->extensions;
|
$options['extensions'] = $this->extensions;
|
||||||
$options['wrongExtension'] = Yii::$app->getI18n()->format($this->wrongExtension, [
|
$options['wrongExtension'] = Yii::$app->getI18n()->format($this->wrongExtension, [
|
||||||
'attribute' => $label,
|
'attribute' => $label,
|
||||||
'extensions' => join(', ', $this->extensions),
|
'extensions' => implode(', ', $this->extensions),
|
||||||
], Yii::$app->language);
|
], Yii::$app->language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class UniqueValidator extends Validator
|
|||||||
if (is_array($targetAttribute)) {
|
if (is_array($targetAttribute)) {
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach ($targetAttribute as $k => $v) {
|
foreach ($targetAttribute as $k => $v) {
|
||||||
$params[$v] = is_integer($k) ? $model->$v : $model->$k;
|
$params[$v] = is_int($k) ? $model->$v : $model->$k;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$params = [$targetAttribute => $model->$attribute];
|
$params = [$targetAttribute => $model->$attribute];
|
||||||
|
|||||||
Reference in New Issue
Block a user