mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Enable no_useless_else
rule in php-cs-fixer (#14420)
This commit is contained in:

committed by
Alexander Makarov

parent
341b8d04c5
commit
fe8a0a6a2e
@ -119,8 +119,8 @@ class Utf8Controller extends Controller
|
||||
return ($h & 0x0F) << 18 | (ord($c[1]) & 0x3F) << 12
|
||||
| (ord($c[2]) & 0x3F) << 6
|
||||
| (ord($c[3]) & 0x3F);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class YiiConfig extends Config
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unused_imports' => true,
|
||||
// 'no_useless_else' => true, // needs more discussion
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
|
@ -95,9 +95,9 @@ class Action extends Component
|
||||
$this->afterRun();
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -651,9 +651,9 @@ abstract class Application extends Module
|
||||
|
||||
if (YII_ENV_TEST) {
|
||||
throw new ExitException($status);
|
||||
} else {
|
||||
exit($status);
|
||||
}
|
||||
|
||||
exit($status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,9 +82,9 @@ class DynamicModel extends Model
|
||||
{
|
||||
if (array_key_exists($name, $this->_attributes)) {
|
||||
return $this->_attributes[$name];
|
||||
} else {
|
||||
return parent::__get($name);
|
||||
}
|
||||
|
||||
return parent::__get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,9 +106,9 @@ class DynamicModel extends Model
|
||||
{
|
||||
if (array_key_exists($name, $this->_attributes)) {
|
||||
return isset($this->_attributes[$name]);
|
||||
} else {
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,9 +134,9 @@ class Object implements Configurable
|
||||
return $this->$getter();
|
||||
} elseif (method_exists($this, 'set' . $name)) {
|
||||
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
|
||||
} else {
|
||||
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
|
||||
}
|
||||
|
||||
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,9 +178,9 @@ class Object implements Configurable
|
||||
$getter = 'get' . $name;
|
||||
if (method_exists($this, $getter)) {
|
||||
return $this->$getter() !== null;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,9 +166,9 @@ class Theme extends Component
|
||||
{
|
||||
if (($baseUrl = $this->getBaseUrl()) !== null) {
|
||||
return $baseUrl . '/' . ltrim($url, '/');
|
||||
} else {
|
||||
throw new InvalidConfigException('The "baseUrl" property must be set.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('The "baseUrl" property must be set.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,8 +181,8 @@ class Theme extends Component
|
||||
{
|
||||
if (($basePath = $this->getBasePath()) !== null) {
|
||||
return $basePath . DIRECTORY_SEPARATOR . ltrim($path, '/\\');
|
||||
} else {
|
||||
throw new InvalidConfigException('The "basePath" property must be set.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('The "basePath" property must be set.');
|
||||
}
|
||||
}
|
||||
|
@ -111,12 +111,12 @@ class Widget extends Component implements ViewContextInterface
|
||||
echo $result;
|
||||
}
|
||||
return $widget;
|
||||
} else {
|
||||
throw new InvalidCallException('Expecting end() of ' . get_class($widget) . ', found ' . get_called_class());
|
||||
}
|
||||
} else {
|
||||
throw new InvalidCallException('Unexpected ' . get_called_class() . '::end() call. A matching begin() is not found.');
|
||||
|
||||
throw new InvalidCallException('Expecting end() of ' . get_class($widget) . ', found ' . get_called_class());
|
||||
}
|
||||
|
||||
throw new InvalidCallException('Unexpected ' . get_called_class() . '::end() call. A matching begin() is not found.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,9 +121,9 @@ abstract class Cache extends Component implements CacheInterface
|
||||
}
|
||||
if (is_array($value) && !($value[1] instanceof Dependency && $value[1]->isChanged($this))) {
|
||||
return $value[0];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,11 +150,11 @@ class FileCache extends Cache
|
||||
}
|
||||
|
||||
return @touch($cacheFile, $duration + time());
|
||||
} else {
|
||||
$error = error_get_last();
|
||||
Yii::warning("Unable to write cache file '{$cacheFile}': {$error['message']}", __METHOD__);
|
||||
return false;
|
||||
}
|
||||
|
||||
$error = error_get_last();
|
||||
Yii::warning("Unable to write cache file '{$cacheFile}': {$error['message']}", __METHOD__);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,9 +206,9 @@ class FileCache extends Cache
|
||||
}
|
||||
|
||||
return $base . DIRECTORY_SEPARATOR . $key . $this->cacheFileSuffix;
|
||||
} else {
|
||||
return $this->cachePath . DIRECTORY_SEPARATOR . $key . $this->cacheFileSuffix;
|
||||
}
|
||||
|
||||
return $this->cachePath . DIRECTORY_SEPARATOR . $key . $this->cacheFileSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,9 +317,9 @@ class MemCache extends Cache
|
||||
// Memcached::setMulti() returns boolean
|
||||
// @see http://php.net/manual/en/memcached.setmulti.php
|
||||
return $this->_cache->setMulti($data, $expire) ? [] : array_keys($data);
|
||||
} else {
|
||||
return parent::setValues($data, $duration);
|
||||
}
|
||||
|
||||
return parent::setValues($data, $duration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,11 +134,12 @@ class CaptchaAction extends Action
|
||||
// when src attribute of image tag is changed
|
||||
'url' => Url::to([$this->id, 'v' => uniqid()]),
|
||||
];
|
||||
} else {
|
||||
$this->setHttpHeaders();
|
||||
Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
return $this->renderImage($this->getVerifyCode());
|
||||
}
|
||||
|
||||
$this->setHttpHeaders();
|
||||
Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
|
||||
return $this->renderImage($this->getVerifyCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,9 +256,9 @@ class CaptchaAction extends Action
|
||||
return $this->renderImageByGD($code);
|
||||
} elseif ($imageLibrary === 'imagick') {
|
||||
return $this->renderImageByImagick($code);
|
||||
} else {
|
||||
throw new InvalidConfigException("Defined library '{$imageLibrary}' is not supported");
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Defined library '{$imageLibrary}' is not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,9 +106,9 @@ class Application extends \yii\base\Application
|
||||
$path = substr($param, strlen($option));
|
||||
if (!empty($path) && is_file($file = Yii::getAlias($path))) {
|
||||
return require($file);
|
||||
} else {
|
||||
exit("The configuration file does not exist: $path\n");
|
||||
}
|
||||
|
||||
exit("The configuration file does not exist: $path\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,12 +147,12 @@ class Application extends \yii\base\Application
|
||||
$result = $this->runAction($route, $params);
|
||||
if ($result instanceof Response) {
|
||||
return $result;
|
||||
} else {
|
||||
$response = $this->getResponse();
|
||||
$response->exitStatus = $result;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response = $this->getResponse();
|
||||
$response->exitStatus = $result;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -320,9 +320,9 @@ class AssetController extends Controller
|
||||
usort($target['depends'], function ($a, $b) use ($bundleOrders) {
|
||||
if ($bundleOrders[$a] == $bundleOrders[$b]) {
|
||||
return 0;
|
||||
} else {
|
||||
return $bundleOrders[$a] > $bundleOrders[$b] ? 1 : -1;
|
||||
}
|
||||
|
||||
return $bundleOrders[$a] > $bundleOrders[$b] ? 1 : -1;
|
||||
});
|
||||
if (!isset($target['class'])) {
|
||||
$target['class'] = $name;
|
||||
@ -732,10 +732,10 @@ EOD;
|
||||
}
|
||||
if (!file_put_contents($configFile, $template)) {
|
||||
throw new Exception("Unable to write template file '{$configFile}'.");
|
||||
} else {
|
||||
$this->stdout("Configuration file template created at '{$configFile}'.\n\n", Console::FG_GREEN);
|
||||
return self::EXIT_CODE_NORMAL;
|
||||
}
|
||||
|
||||
$this->stdout("Configuration file template created at '{$configFile}'.\n\n", Console::FG_GREEN);
|
||||
return self::EXIT_CODE_NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,9 +130,9 @@ abstract class BaseMigrateController extends Controller
|
||||
$this->stdout("Yii Migration Tool (based on Yii v{$version})\n\n");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -673,12 +673,12 @@ abstract class BaseMigrateController extends Controller
|
||||
$this->stdout("*** applied $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_GREEN);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$time = microtime(true) - $start;
|
||||
$this->stdout("*** failed to apply $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_RED);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = microtime(true) - $start;
|
||||
$this->stdout("*** failed to apply $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_RED);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -701,12 +701,12 @@ abstract class BaseMigrateController extends Controller
|
||||
$this->stdout("*** reverted $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_GREEN);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$time = microtime(true) - $start;
|
||||
$this->stdout("*** failed to revert $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_RED);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = microtime(true) - $start;
|
||||
$this->stdout("*** failed to revert $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_RED);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,9 +273,9 @@ class HelpController extends Controller
|
||||
if (class_exists($controllerClass)) {
|
||||
$class = new \ReflectionClass($controllerClass);
|
||||
return !$class->isAbstract() && $class->isSubclassOf('yii\console\Controller');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,9 +170,9 @@ class MigrateController extends BaseMigrateController
|
||||
$this->db = Instance::ensure($this->db, Connection::className());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,9 +152,9 @@ class ActiveDataProvider extends BaseDataProvider
|
||||
}
|
||||
|
||||
return $keys;
|
||||
} else {
|
||||
return array_keys($models);
|
||||
}
|
||||
|
||||
return array_keys($models);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,9 +113,9 @@ class ArrayDataProvider extends BaseDataProvider
|
||||
}
|
||||
|
||||
return $keys;
|
||||
} else {
|
||||
return array_keys($models);
|
||||
}
|
||||
|
||||
return array_keys($models);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,11 +153,11 @@ class Pagination extends Object implements Linkable
|
||||
$pageSize = $this->getPageSize();
|
||||
if ($pageSize < 1) {
|
||||
return $this->totalCount > 0 ? 1 : 0;
|
||||
} else {
|
||||
$totalCount = $this->totalCount < 0 ? 0 : (int) $this->totalCount;
|
||||
|
||||
return (int) (($totalCount + $pageSize - 1) / $pageSize);
|
||||
}
|
||||
|
||||
$totalCount = $this->totalCount < 0 ? 0 : (int) $this->totalCount;
|
||||
|
||||
return (int) (($totalCount + $pageSize - 1) / $pageSize);
|
||||
}
|
||||
|
||||
private $_page;
|
||||
@ -281,9 +281,9 @@ class Pagination extends Object implements Linkable
|
||||
$urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
|
||||
if ($absolute) {
|
||||
return $urlManager->createAbsoluteUrl($params);
|
||||
} else {
|
||||
return $urlManager->createUrl($params);
|
||||
}
|
||||
|
||||
return $urlManager->createUrl($params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,9 +412,9 @@ class Sort extends Object
|
||||
$urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
|
||||
if ($absolute) {
|
||||
return $urlManager->createAbsoluteUrl($params);
|
||||
} else {
|
||||
return $urlManager->createUrl($params);
|
||||
}
|
||||
|
||||
return $urlManager->createUrl($params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,9 +295,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
if ($row !== false) {
|
||||
$models = $this->populate([$row]);
|
||||
return reset($models) ?: null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -545,9 +545,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
{
|
||||
if (is_array($joinType) && isset($joinType[$name])) {
|
||||
return $joinType[$name];
|
||||
} else {
|
||||
return is_string($joinType) ? $joinType : 'INNER JOIN';
|
||||
}
|
||||
|
||||
return is_string($joinType) ? $joinType : 'INNER JOIN';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -564,9 +564,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
foreach ($this->from as $alias => $tableName) {
|
||||
if (is_string($alias)) {
|
||||
return [$tableName, $alias];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,57 +232,57 @@ trait ActiveRelationTrait
|
||||
}
|
||||
|
||||
return [$model];
|
||||
}
|
||||
|
||||
// https://github.com/yiisoft/yii2/issues/3197
|
||||
// delay indexing related models after buckets are built
|
||||
$indexBy = $this->indexBy;
|
||||
$this->indexBy = null;
|
||||
$models = $this->all();
|
||||
|
||||
if (isset($viaModels, $viaQuery)) {
|
||||
$buckets = $this->buildBuckets($models, $this->link, $viaModels, $viaQuery->link);
|
||||
} else {
|
||||
// https://github.com/yiisoft/yii2/issues/3197
|
||||
// delay indexing related models after buckets are built
|
||||
$indexBy = $this->indexBy;
|
||||
$this->indexBy = null;
|
||||
$models = $this->all();
|
||||
$buckets = $this->buildBuckets($models, $this->link);
|
||||
}
|
||||
|
||||
if (isset($viaModels, $viaQuery)) {
|
||||
$buckets = $this->buildBuckets($models, $this->link, $viaModels, $viaQuery->link);
|
||||
} else {
|
||||
$buckets = $this->buildBuckets($models, $this->link);
|
||||
}
|
||||
$this->indexBy = $indexBy;
|
||||
if ($this->indexBy !== null && $this->multiple) {
|
||||
$buckets = $this->indexBuckets($buckets, $this->indexBy);
|
||||
}
|
||||
|
||||
$this->indexBy = $indexBy;
|
||||
if ($this->indexBy !== null && $this->multiple) {
|
||||
$buckets = $this->indexBuckets($buckets, $this->indexBy);
|
||||
}
|
||||
|
||||
$link = array_values(isset($viaQuery) ? $viaQuery->link : $this->link);
|
||||
foreach ($primaryModels as $i => $primaryModel) {
|
||||
if ($this->multiple && count($link) === 1 && is_array($keys = $primaryModel[reset($link)])) {
|
||||
$value = [];
|
||||
foreach ($keys as $key) {
|
||||
$key = $this->normalizeModelKey($key);
|
||||
if (isset($buckets[$key])) {
|
||||
if ($this->indexBy !== null) {
|
||||
// if indexBy is set, array_merge will cause renumbering of numeric array
|
||||
foreach ($buckets[$key] as $bucketKey => $bucketValue) {
|
||||
$value[$bucketKey] = $bucketValue;
|
||||
}
|
||||
} else {
|
||||
$value = array_merge($value, $buckets[$key]);
|
||||
$link = array_values(isset($viaQuery) ? $viaQuery->link : $this->link);
|
||||
foreach ($primaryModels as $i => $primaryModel) {
|
||||
if ($this->multiple && count($link) === 1 && is_array($keys = $primaryModel[reset($link)])) {
|
||||
$value = [];
|
||||
foreach ($keys as $key) {
|
||||
$key = $this->normalizeModelKey($key);
|
||||
if (isset($buckets[$key])) {
|
||||
if ($this->indexBy !== null) {
|
||||
// if indexBy is set, array_merge will cause renumbering of numeric array
|
||||
foreach ($buckets[$key] as $bucketKey => $bucketValue) {
|
||||
$value[$bucketKey] = $bucketValue;
|
||||
}
|
||||
} else {
|
||||
$value = array_merge($value, $buckets[$key]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$key = $this->getModelKey($primaryModel, $link);
|
||||
$value = isset($buckets[$key]) ? $buckets[$key] : ($this->multiple ? [] : null);
|
||||
}
|
||||
if ($primaryModel instanceof ActiveRecordInterface) {
|
||||
$primaryModel->populateRelation($name, $value);
|
||||
} else {
|
||||
$primaryModels[$i][$name] = $value;
|
||||
}
|
||||
} else {
|
||||
$key = $this->getModelKey($primaryModel, $link);
|
||||
$value = isset($buckets[$key]) ? $buckets[$key] : ($this->multiple ? [] : null);
|
||||
}
|
||||
if ($this->inverseOf !== null) {
|
||||
$this->populateInverseRelation($primaryModels, $models, $name, $this->inverseOf);
|
||||
if ($primaryModel instanceof ActiveRecordInterface) {
|
||||
$primaryModel->populateRelation($name, $value);
|
||||
} else {
|
||||
$primaryModels[$i][$name] = $value;
|
||||
}
|
||||
|
||||
return $models;
|
||||
}
|
||||
if ($this->inverseOf !== null) {
|
||||
$this->populateInverseRelation($primaryModels, $models, $name, $this->inverseOf);
|
||||
}
|
||||
|
||||
return $models;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,17 +278,17 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
return $this->_attributes[$name];
|
||||
} elseif ($this->hasAttribute($name)) {
|
||||
return null;
|
||||
} else {
|
||||
if (isset($this->_related[$name]) || array_key_exists($name, $this->_related)) {
|
||||
return $this->_related[$name];
|
||||
}
|
||||
$value = parent::__get($name);
|
||||
if ($value instanceof ActiveQueryInterface) {
|
||||
return $this->_related[$name] = $value->findFor($name, $this);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->_related[$name]) || array_key_exists($name, $this->_related)) {
|
||||
return $this->_related[$name];
|
||||
}
|
||||
$value = parent::__get($name);
|
||||
if ($value instanceof ActiveQueryInterface) {
|
||||
return $this->_related[$name] = $value->findFor($name, $this);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -575,12 +575,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
if (isset($this->_attributes[$name], $this->_oldAttributes[$name])) {
|
||||
if ($identical) {
|
||||
return $this->_attributes[$name] !== $this->_oldAttributes[$name];
|
||||
} else {
|
||||
return $this->_attributes[$name] != $this->_oldAttributes[$name];
|
||||
}
|
||||
} else {
|
||||
return isset($this->_attributes[$name]) || isset($this->_oldAttributes[$name]);
|
||||
|
||||
return $this->_attributes[$name] != $this->_oldAttributes[$name];
|
||||
}
|
||||
|
||||
return isset($this->_attributes[$name]) || isset($this->_oldAttributes[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -641,9 +641,9 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
{
|
||||
if ($this->getIsNewRecord()) {
|
||||
return $this->insert($runValidation, $attributeNames);
|
||||
} else {
|
||||
return $this->update($runValidation, $attributeNames) !== false;
|
||||
}
|
||||
|
||||
return $this->update($runValidation, $attributeNames) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -819,10 +819,11 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
}
|
||||
$this->_oldAttributes[$name] = $this->_attributes[$name];
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1074,14 +1075,14 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
$keys = $this->primaryKey();
|
||||
if (!$asArray && count($keys) === 1) {
|
||||
return isset($this->_attributes[$keys[0]]) ? $this->_attributes[$keys[0]] : null;
|
||||
} else {
|
||||
$values = [];
|
||||
foreach ($keys as $name) {
|
||||
$values[$name] = isset($this->_attributes[$name]) ? $this->_attributes[$name] : null;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($keys as $name) {
|
||||
$values[$name] = isset($this->_attributes[$name]) ? $this->_attributes[$name] : null;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1108,14 +1109,14 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
}
|
||||
if (!$asArray && count($keys) === 1) {
|
||||
return isset($this->_oldAttributes[$keys[0]]) ? $this->_oldAttributes[$keys[0]] : null;
|
||||
} else {
|
||||
$values = [];
|
||||
foreach ($keys as $name) {
|
||||
$values[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($keys as $name) {
|
||||
$values[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1193,16 +1194,16 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
} catch (UnknownMethodException $e) {
|
||||
if ($throwException) {
|
||||
throw new InvalidParamException(get_class($this) . ' has no relation named "' . $name . '".', 0, $e);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
if (!$relation instanceof ActiveQueryInterface) {
|
||||
if ($throwException) {
|
||||
throw new InvalidParamException(get_class($this) . ' has no relation named "' . $name . '".');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (method_exists($this, $getter)) {
|
||||
@ -1212,9 +1213,9 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
if ($realName !== $name) {
|
||||
if ($throwException) {
|
||||
throw new InvalidParamException('Relation names are case sensitive. ' . get_class($this) . " has a relation named \"$realName\" instead of \"$name\".");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,9 +1539,9 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
$pks = static::primaryKey();
|
||||
if (count($keys) === count($pks)) {
|
||||
return count(array_intersect($keys, $pks)) === count($pks);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,9 +312,9 @@ class ColumnSchemaBuilder extends Object
|
||||
return ' NOT NULL';
|
||||
} elseif ($this->isNotNull === false) {
|
||||
return ' NULL';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,9 +388,9 @@ class Command extends Component
|
||||
$result = $this->queryInternal('fetchColumn', 0);
|
||||
if (is_resource($result) && get_resource_type($result) === 'stream') {
|
||||
return stream_get_contents($result);
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -985,9 +985,9 @@ class Command extends Component
|
||||
}
|
||||
if (!$this->db->enableProfiling) {
|
||||
return [false, isset($rawSql) ? $rawSql : null];
|
||||
} else {
|
||||
return [true, isset($rawSql) ? $rawSql : $this->getRawSql()];
|
||||
}
|
||||
|
||||
return [true, isset($rawSql) ? $rawSql : $this->getRawSql()];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -564,9 +564,9 @@ class Connection extends Component
|
||||
if ($db !== null) {
|
||||
$this->pdo = $db->pdo;
|
||||
return;
|
||||
} else {
|
||||
throw new InvalidConfigException('None of the master DB servers is available.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('None of the master DB servers is available.');
|
||||
}
|
||||
|
||||
if (empty($this->dsn)) {
|
||||
@ -768,17 +768,17 @@ class Connection extends Component
|
||||
{
|
||||
if ($this->_schema !== null) {
|
||||
return $this->_schema;
|
||||
} else {
|
||||
$driver = $this->getDriverName();
|
||||
if (isset($this->schemaMap[$driver])) {
|
||||
$config = !is_array($this->schemaMap[$driver]) ? ['class' => $this->schemaMap[$driver]] : $this->schemaMap[$driver];
|
||||
$config['db'] = $this;
|
||||
|
||||
return $this->_schema = Yii::createObject($config);
|
||||
} else {
|
||||
throw new NotSupportedException("Connection does not support reading schema information for '$driver' DBMS.");
|
||||
}
|
||||
}
|
||||
|
||||
$driver = $this->getDriverName();
|
||||
if (isset($this->schemaMap[$driver])) {
|
||||
$config = !is_array($this->schemaMap[$driver]) ? ['class' => $this->schemaMap[$driver]] : $this->schemaMap[$driver];
|
||||
$config['db'] = $this;
|
||||
|
||||
return $this->_schema = Yii::createObject($config);
|
||||
}
|
||||
|
||||
throw new NotSupportedException("Connection does not support reading schema information for '$driver' DBMS.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -866,9 +866,9 @@ class Connection extends Component
|
||||
function ($matches) {
|
||||
if (isset($matches[3])) {
|
||||
return $this->quoteColumnName($matches[3]);
|
||||
} else {
|
||||
return str_replace('%', $this->tablePrefix, $this->quoteTableName($matches[2]));
|
||||
}
|
||||
|
||||
return str_replace('%', $this->tablePrefix, $this->quoteTableName($matches[2]));
|
||||
},
|
||||
$sql
|
||||
);
|
||||
@ -913,9 +913,9 @@ class Connection extends Component
|
||||
$db = $this->getSlave(false);
|
||||
if ($db === null) {
|
||||
return $fallbackToMaster ? $this->getMasterPdo() : null;
|
||||
} else {
|
||||
return $db->pdo;
|
||||
}
|
||||
|
||||
return $db->pdo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -431,12 +431,13 @@ class Query extends Component implements QueryInterface
|
||||
$this->offset = $offset;
|
||||
|
||||
return $command->queryScalar();
|
||||
} else {
|
||||
return (new self())->select([$selectExpression])
|
||||
->from(['c' => $this])
|
||||
->createCommand($db)
|
||||
->queryScalar();
|
||||
}
|
||||
|
||||
return (new self())
|
||||
->select([$selectExpression])
|
||||
->from(['c' => $this])
|
||||
->createCommand($db)
|
||||
->queryScalar();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1135,9 +1135,9 @@ class QueryBuilder extends \yii\base\Object
|
||||
if (!is_array($columns)) {
|
||||
if (strpos($columns, '(') !== false) {
|
||||
return $columns;
|
||||
} else {
|
||||
$columns = preg_split('/\s*,\s*/', $columns, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
$columns = preg_split('/\s*,\s*/', $columns, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
foreach ($columns as $i => $column) {
|
||||
if ($column instanceof Expression) {
|
||||
@ -1179,9 +1179,10 @@ class QueryBuilder extends \yii\base\Object
|
||||
}
|
||||
array_shift($condition);
|
||||
return $this->$method($operator, $condition, $params);
|
||||
} else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ...
|
||||
return $this->buildHashCondition($condition, $params);
|
||||
}
|
||||
|
||||
// hash format: 'column1' => 'value1', 'column2' => 'value2', ...
|
||||
return $this->buildHashCondition($condition, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1244,9 +1245,9 @@ class QueryBuilder extends \yii\base\Object
|
||||
}
|
||||
if (!empty($parts)) {
|
||||
return '(' . implode(") $operator (", $parts) . ')';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1384,10 +1385,10 @@ class QueryBuilder extends \yii\base\Object
|
||||
|
||||
if (count($sqlValues) > 1) {
|
||||
return "$column $operator (" . implode(', ', $sqlValues) . ')';
|
||||
} else {
|
||||
$operator = $operator === 'IN' ? '=' : '<>';
|
||||
return $column . $operator . reset($sqlValues);
|
||||
}
|
||||
|
||||
$operator = $operator === 'IN' ? '=' : '<>';
|
||||
return $column . $operator . reset($sqlValues);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1409,12 +1410,13 @@ class QueryBuilder extends \yii\base\Object
|
||||
}
|
||||
}
|
||||
return '(' . implode(', ', $columns) . ") $operator ($sql)";
|
||||
} else {
|
||||
if (strpos($columns, '(') === false) {
|
||||
$columns = $this->db->quoteColumnName($columns);
|
||||
}
|
||||
return "$columns $operator ($sql)";
|
||||
}
|
||||
|
||||
if (strpos($columns, '(') === false) {
|
||||
$columns = $this->db->quoteColumnName($columns);
|
||||
}
|
||||
|
||||
return "$columns $operator ($sql)";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1539,9 +1541,9 @@ class QueryBuilder extends \yii\base\Object
|
||||
if ($operands[0] instanceof Query) {
|
||||
list($sql, $params) = $this->build($operands[0], $params);
|
||||
return "$operator ($sql)";
|
||||
} else {
|
||||
throw new InvalidParamException('Subquery for EXISTS operator must be a Query object.');
|
||||
}
|
||||
|
||||
throw new InvalidParamException('Subquery for EXISTS operator must be a Query object.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1574,11 +1576,11 @@ class QueryBuilder extends \yii\base\Object
|
||||
} elseif ($value instanceof Query) {
|
||||
list($sql, $params) = $this->build($value, $params);
|
||||
return "$column $operator ($sql)";
|
||||
} else {
|
||||
$phName = self::PARAM_PREFIX . count($params);
|
||||
$params[$phName] = $value;
|
||||
return "$column $operator $phName";
|
||||
}
|
||||
|
||||
$phName = self::PARAM_PREFIX . count($params);
|
||||
$params[$phName] = $value;
|
||||
return "$column $operator $phName";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,18 +360,19 @@ trait QueryTrait
|
||||
return [$columns];
|
||||
} elseif (is_array($columns)) {
|
||||
return $columns;
|
||||
} else {
|
||||
$columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY);
|
||||
$result = [];
|
||||
foreach ($columns as $column) {
|
||||
if (preg_match('/^(.*?)\s+(asc|desc)$/i', $column, $matches)) {
|
||||
$result[$matches[1]] = strcasecmp($matches[2], 'desc') ? SORT_ASC : SORT_DESC;
|
||||
} else {
|
||||
$result[$column] = SORT_ASC;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
$columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY);
|
||||
$result = [];
|
||||
foreach ($columns as $column) {
|
||||
if (preg_match('/^(.*?)\s+(asc|desc)$/i', $column, $matches)) {
|
||||
$result[$matches[1]] = strcasecmp($matches[2], 'desc') ? SORT_ASC : SORT_DESC;
|
||||
} else {
|
||||
$result[$column] = SORT_ASC;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,9 +345,9 @@ abstract class Schema extends Object
|
||||
{
|
||||
if ($this->db->isActive) {
|
||||
return $this->db->pdo->lastInsertId($sequenceName === '' ? null : $this->quoteTableName($sequenceName));
|
||||
} else {
|
||||
throw new InvalidCallException('DB Connection is not active.');
|
||||
}
|
||||
|
||||
throw new InvalidCallException('DB Connection is not active.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,9 +417,9 @@ abstract class Schema extends Object
|
||||
if ($tableSchema->columns[$name]->autoIncrement) {
|
||||
$result[$name] = $this->getLastInsertID($tableSchema->sequenceName);
|
||||
break;
|
||||
} else {
|
||||
$result[$name] = isset($columns[$name]) ? $columns[$name] : $tableSchema->columns[$name]->defaultValue;
|
||||
}
|
||||
|
||||
$result[$name] = isset($columns[$name]) ? $columns[$name] : $tableSchema->columns[$name]->defaultValue;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -439,10 +439,10 @@ abstract class Schema extends Object
|
||||
|
||||
if (($value = $this->db->getSlavePdo()->quote($str)) !== false) {
|
||||
return $value;
|
||||
} else {
|
||||
// the driver doesn't support quote (e.g. oci)
|
||||
return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'";
|
||||
}
|
||||
|
||||
// the driver doesn't support quote (e.g. oci)
|
||||
return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,9 +533,9 @@ abstract class Schema extends Object
|
||||
$name = preg_replace('/\\{\\{(.*?)\\}\\}/', '\1', $name);
|
||||
|
||||
return str_replace('%', $this->db->tablePrefix, $name);
|
||||
} else {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -560,12 +560,12 @@ abstract class Schema extends Object
|
||||
return PHP_INT_SIZE === 8 && !$column->unsigned ? 'integer' : 'string';
|
||||
} elseif ($column->type === 'integer') {
|
||||
return PHP_INT_SIZE === 4 && $column->unsigned ? 'string' : 'integer';
|
||||
} else {
|
||||
return $typeMap[$column->type];
|
||||
}
|
||||
} else {
|
||||
return 'string';
|
||||
|
||||
return $typeMap[$column->type];
|
||||
}
|
||||
|
||||
return 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,9 +84,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
return 'ALTER TABLE ' . $this->db->schema->quoteTableName($tableName) . " AUTO_INCREMENT=$value;";
|
||||
} elseif ($table === null) {
|
||||
throw new InvalidParamException("Table not found: $tableName");
|
||||
} else {
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,9 +69,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
|
||||
if ($this->isOldMssql()) {
|
||||
return $this->oldBuildOrderByAndLimit($sql, $orderBy, $limit, $offset);
|
||||
} else {
|
||||
return $this->newBuildOrderByAndLimit($sql, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
return $this->newBuildOrderByAndLimit($sql, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,9 +220,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
return "DBCC CHECKIDENT ('{$tableName}', RESEED, {$value})";
|
||||
} elseif ($table === null) {
|
||||
throw new InvalidParamException("Table not found: $tableName");
|
||||
} else {
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,9 +171,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
return "ALTER TABLE $tableName AUTO_INCREMENT=$value";
|
||||
} elseif ($table === null) {
|
||||
throw new InvalidParamException("Table not found: $tableName");
|
||||
} else {
|
||||
throw new InvalidParamException("There is no sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
throw new InvalidParamException("There is no sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,9 +173,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
return "SELECT SETVAL('$sequence',$value,false)";
|
||||
} elseif ($table === null) {
|
||||
throw new InvalidParamException("Table not found: $tableName");
|
||||
} else {
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,9 +150,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
return "UPDATE sqlite_sequence SET seq='$value' WHERE name='{$table->name}'";
|
||||
} elseif ($table === null) {
|
||||
throw new InvalidParamException("Table not found: $tableName");
|
||||
} else {
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.'");
|
||||
}
|
||||
|
||||
throw new InvalidParamException("There is not sequence associated with table '$tableName'.'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,9 +334,9 @@ class Container extends Component
|
||||
}
|
||||
}
|
||||
return $definition;
|
||||
} else {
|
||||
throw new InvalidConfigException("Unsupported definition type for \"$class\": " . gettype($definition));
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Unsupported definition type for \"$class\": " . gettype($definition));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -379,13 +379,14 @@ class Container extends Component
|
||||
// set $config as the last parameter (existing one will be overwritten)
|
||||
$dependencies[count($dependencies) - 1] = $config;
|
||||
return $reflection->newInstanceArgs($dependencies);
|
||||
} else {
|
||||
$object = $reflection->newInstanceArgs($dependencies);
|
||||
foreach ($config as $name => $value) {
|
||||
$object->$name = $value;
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
$object = $reflection->newInstanceArgs($dependencies);
|
||||
foreach ($config as $name => $value) {
|
||||
$object->$name = $value;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,13 +401,14 @@ class Container extends Component
|
||||
return $params;
|
||||
} elseif (empty($params)) {
|
||||
return $this->_params[$class];
|
||||
} else {
|
||||
$ps = $this->_params[$class];
|
||||
foreach ($params as $index => $value) {
|
||||
$ps[$index] = $value;
|
||||
}
|
||||
return $ps;
|
||||
}
|
||||
|
||||
$ps = $this->_params[$class];
|
||||
foreach ($params as $index => $value) {
|
||||
$ps[$index] = $value;
|
||||
}
|
||||
|
||||
return $ps;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -494,9 +496,9 @@ class Container extends Component
|
||||
{
|
||||
if (is_callable($callback)) {
|
||||
return call_user_func_array($callback, $this->resolveCallableDependencies($callback, $params));
|
||||
} else {
|
||||
return call_user_func_array($callback, $params);
|
||||
}
|
||||
|
||||
return call_user_func_array($callback, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,9 +119,9 @@ class Instance
|
||||
$component = $container->get($class, [], $reference);
|
||||
if ($type === null || $component instanceof $type) {
|
||||
return $component;
|
||||
} else {
|
||||
throw new InvalidConfigException('Invalid data type: ' . $class . '. ' . $type . ' is expected.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('Invalid data type: ' . $class . '. ' . $type . ' is expected.');
|
||||
} elseif (empty($reference)) {
|
||||
throw new InvalidConfigException('The required component is not specified.');
|
||||
}
|
||||
@ -140,9 +140,9 @@ class Instance
|
||||
}
|
||||
if ($type === null || $component instanceof $type) {
|
||||
return $component;
|
||||
} else {
|
||||
throw new InvalidConfigException('"' . $reference->id . '" refers to a ' . get_class($component) . " component. $type is expected.");
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('"' . $reference->id . '" refers to a ' . get_class($component) . " component. $type is expected.");
|
||||
}
|
||||
|
||||
$valueType = is_object($reference) ? get_class($reference) : gettype($reference);
|
||||
@ -162,9 +162,9 @@ class Instance
|
||||
}
|
||||
if (Yii::$app && Yii::$app->has($this->id)) {
|
||||
return Yii::$app->get($this->id);
|
||||
} else {
|
||||
return Yii::$container->get($this->id);
|
||||
}
|
||||
|
||||
return Yii::$container->get($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,9 +71,9 @@ class ServiceLocator extends Component
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
return $this->get($name);
|
||||
} else {
|
||||
return parent::__get($name);
|
||||
}
|
||||
|
||||
return parent::__get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,9 +86,9 @@ class ServiceLocator extends Component
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
return true;
|
||||
} else {
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,14 +131,14 @@ class ServiceLocator extends Component
|
||||
$definition = $this->_definitions[$id];
|
||||
if (is_object($definition) && !$definition instanceof Closure) {
|
||||
return $this->_components[$id] = $definition;
|
||||
} else {
|
||||
return $this->_components[$id] = Yii::createObject($definition);
|
||||
}
|
||||
|
||||
return $this->_components[$id] = Yii::createObject($definition);
|
||||
} elseif ($throwException) {
|
||||
throw new InvalidConfigException("Unknown component ID: $id");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,9 +176,9 @@ class ContentNegotiator extends ActionFilter implements BootstrapInterface
|
||||
$response->acceptMimeType = null;
|
||||
$response->acceptParams = [];
|
||||
return;
|
||||
} else {
|
||||
throw new UnsupportedMediaTypeHttpException('The requested response format is not supported: ' . $format);
|
||||
}
|
||||
|
||||
throw new UnsupportedMediaTypeHttpException('The requested response format is not supported: ' . $format);
|
||||
}
|
||||
|
||||
$types = $request->getAcceptableContentTypes();
|
||||
|
@ -171,9 +171,9 @@ class HttpCache extends ActionFilter
|
||||
return $etag !== null && in_array($etag, Yii::$app->request->getETags(), true);
|
||||
} elseif (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||
return $lastModified !== null && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,11 +171,11 @@ class PageCache extends ActionFilter
|
||||
$response->on(Response::EVENT_AFTER_SEND, [$this, 'cacheResponse']);
|
||||
Yii::trace('Valid page content is not found in the cache.', __METHOD__);
|
||||
return true;
|
||||
} else {
|
||||
$this->restoreResponse($response, $data);
|
||||
Yii::trace('Valid page content is found in the cache.', __METHOD__);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->restoreResponse($response, $data);
|
||||
Yii::trace('Valid page content is found in the cache.', __METHOD__);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,10 +120,10 @@ class RateLimiter extends ActionFilter
|
||||
$user->saveAllowance($request, $action, 0, $current);
|
||||
$this->addRateLimitHeaders($response, $limit, 0, $window);
|
||||
throw new TooManyRequestsHttpException($this->errorMessage);
|
||||
} else {
|
||||
$user->saveAllowance($request, $action, $allowance - 1, $current);
|
||||
$this->addRateLimitHeaders($response, $limit, $allowance - 1, (int) (($limit - $allowance) * $window / $limit));
|
||||
}
|
||||
|
||||
$user->saveAllowance($request, $action, $allowance - 1, $current);
|
||||
$this->addRateLimitHeaders($response, $limit, $allowance - 1, (int) (($limit - $allowance) * $window / $limit));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,11 +69,12 @@ abstract class AuthMethod extends ActionFilter implements AuthInterface
|
||||
|
||||
if ($identity !== null || $this->isOptional($action)) {
|
||||
return true;
|
||||
} else {
|
||||
$this->challenge($response);
|
||||
$this->handleFailure($response);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->challenge($response);
|
||||
$this->handleFailure($response);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,12 +198,12 @@ class ActionColumn extends Column
|
||||
{
|
||||
if (is_callable($this->urlCreator)) {
|
||||
return call_user_func($this->urlCreator, $action, $model, $key, $index, $this);
|
||||
} else {
|
||||
$params = is_array($key) ? $key : ['id' => (string) $key];
|
||||
$params[0] = $this->controller ? $this->controller . '/' . $action : $action;
|
||||
|
||||
return Url::toRoute($params);
|
||||
}
|
||||
|
||||
$params = is_array($key) ? $key : ['id' => (string) $key];
|
||||
$params[0] = $this->controller ? $this->controller . '/' . $action : $action;
|
||||
|
||||
return Url::toRoute($params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,9 +225,9 @@ class ActionColumn extends Column
|
||||
if ($isVisible && isset($this->buttons[$name])) {
|
||||
$url = $this->createUrl($name, $model, $key, $index);
|
||||
return call_user_func($this->buttons[$name], $url, $model, $key);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}, $this->template);
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ class CheckboxColumn extends Column
|
||||
{
|
||||
if ($this->header !== null || !$this->multiple) {
|
||||
return parent::renderHeaderCellContent();
|
||||
} else {
|
||||
return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']);
|
||||
}
|
||||
|
||||
return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,9 +162,9 @@ class Column extends Object
|
||||
{
|
||||
if ($this->content !== null) {
|
||||
return call_user_func($this->content, $model, $key, $index, $this);
|
||||
} else {
|
||||
return $this->grid->emptyCell;
|
||||
}
|
||||
|
||||
return $this->grid->emptyCell;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,9 +130,9 @@ class DataColumn extends Column
|
||||
if ($this->attribute !== null && $this->enableSorting &&
|
||||
($sort = $this->grid->dataProvider->getSort()) !== false && $sort->hasAttribute($this->attribute)) {
|
||||
return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => $label]));
|
||||
} else {
|
||||
return $label;
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,12 +197,12 @@ class DataColumn extends Column
|
||||
$this->grid->formatter->booleanFormat[0],
|
||||
$this->grid->formatter->booleanFormat[1],
|
||||
], $options) . $error;
|
||||
} else {
|
||||
return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
|
||||
}
|
||||
} else {
|
||||
return parent::renderFilterCellContent();
|
||||
|
||||
return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
|
||||
}
|
||||
|
||||
return parent::renderFilterCellContent();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,9 +217,9 @@ class DataColumn extends Column
|
||||
if ($this->value !== null) {
|
||||
if (is_string($this->value)) {
|
||||
return ArrayHelper::getValue($model, $this->value);
|
||||
} else {
|
||||
return call_user_func($this->value, $model, $key, $index, $this);
|
||||
}
|
||||
|
||||
return call_user_func($this->value, $model, $key, $index, $this);
|
||||
} elseif ($this->attribute !== null) {
|
||||
return ArrayHelper::getValue($model, $this->attribute);
|
||||
}
|
||||
@ -233,8 +233,8 @@ class DataColumn extends Column
|
||||
{
|
||||
if ($this->content === null) {
|
||||
return $this->grid->formatter->format($this->getDataCellValue($model, $key, $index), $this->format);
|
||||
} else {
|
||||
return parent::renderDataCellContent($model, $key, $index);
|
||||
}
|
||||
|
||||
return parent::renderDataCellContent($model, $key, $index);
|
||||
}
|
||||
}
|
||||
|
@ -299,9 +299,9 @@ class GridView extends BaseListView
|
||||
{
|
||||
if ($this->filterModel instanceof Model && $this->filterModel->hasErrors()) {
|
||||
return Html::errorSummary($this->filterModel, $this->filterErrorSummaryOptions);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,9 +365,9 @@ class GridView extends BaseListView
|
||||
{
|
||||
if (!empty($this->caption)) {
|
||||
return Html::tag('caption', $this->caption, $this->captionOptions);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,9 +391,9 @@ class GridView extends BaseListView
|
||||
}
|
||||
|
||||
return Html::tag('colgroup', implode("\n", $cols));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,9 +450,9 @@ class GridView extends BaseListView
|
||||
}
|
||||
|
||||
return Html::tag('tr', implode('', $cells), $this->filterRowOptions);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -487,9 +487,9 @@ class GridView extends BaseListView
|
||||
$colspan = count($this->columns);
|
||||
|
||||
return "<tbody>\n<tr><td colspan=\"$colspan\">" . $this->renderEmpty() . "</td></tr>\n</tbody>";
|
||||
} else {
|
||||
return "<tbody>\n" . implode("\n", $rows) . "\n</tbody>";
|
||||
}
|
||||
|
||||
return "<tbody>\n" . implode("\n", $rows) . "\n</tbody>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,8 +43,8 @@ class SerialColumn extends Column
|
||||
$pagination = $this->grid->dataProvider->getPagination();
|
||||
if ($pagination !== false) {
|
||||
return $pagination->getOffset() + $index + 1;
|
||||
} else {
|
||||
return $index + 1;
|
||||
}
|
||||
|
||||
return $index + 1;
|
||||
}
|
||||
}
|
||||
|
@ -94,9 +94,9 @@ class BaseArrayHelper
|
||||
}
|
||||
|
||||
return $recursive ? static::toArray($result, $properties) : $result;
|
||||
} else {
|
||||
return [$object];
|
||||
}
|
||||
|
||||
return [$object];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,9 +209,9 @@ class BaseArrayHelper
|
||||
return $array->$key;
|
||||
} elseif (is_array($array)) {
|
||||
return (isset($array[$key]) || array_key_exists($key, $array)) ? $array[$key] : $default;
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -526,15 +526,15 @@ class BaseArrayHelper
|
||||
// Function `isset` checks key faster but skips `null`, `array_key_exists` handles this case
|
||||
// http://php.net/manual/en/function.array-key-exists.php#107786
|
||||
return isset($array[$key]) || array_key_exists($key, $array);
|
||||
} else {
|
||||
foreach (array_keys($array) as $k) {
|
||||
if (strcasecmp($key, $k) === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (array_keys($array) as $k) {
|
||||
if (strcasecmp($key, $k) === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -679,14 +679,15 @@ class BaseArrayHelper
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_string($key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_string($key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -714,14 +715,15 @@ class BaseArrayHelper
|
||||
|
||||
if ($consecutive) {
|
||||
return array_keys($array) === range(0, count($array) - 1);
|
||||
} else {
|
||||
foreach ($array as $key => $value) {
|
||||
if (!is_int($key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
if (!is_int($key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -789,10 +791,11 @@ class BaseArrayHelper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
throw new InvalidParamException('Argument $needles must be an array or implement Traversable');
|
||||
}
|
||||
|
||||
throw new InvalidParamException('Argument $needles must be an array or implement Traversable');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,15 +104,15 @@ class BaseFileHelper
|
||||
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . basename($file);
|
||||
if (is_file($desiredFile)) {
|
||||
return $desiredFile;
|
||||
} else {
|
||||
$language = substr($language, 0, 2);
|
||||
if ($language === $sourceLanguage) {
|
||||
return $file;
|
||||
}
|
||||
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . basename($file);
|
||||
|
||||
return is_file($desiredFile) ? $desiredFile : $file;
|
||||
}
|
||||
|
||||
$language = substr($language, 0, 2);
|
||||
if ($language === $sourceLanguage) {
|
||||
return $file;
|
||||
}
|
||||
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . basename($file);
|
||||
|
||||
return is_file($desiredFile) ? $desiredFile : $file;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,9 +138,9 @@ class BaseFileHelper
|
||||
if (!extension_loaded('fileinfo')) {
|
||||
if ($checkExtension) {
|
||||
return static::getMimeTypeByExtension($file, $magicFile);
|
||||
} else {
|
||||
throw new InvalidConfigException('The fileinfo PHP extension is not installed.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('The fileinfo PHP extension is not installed.');
|
||||
}
|
||||
$info = finfo_open(FILEINFO_MIME_TYPE, $magicFile);
|
||||
|
||||
|
@ -243,9 +243,9 @@ class BaseHtml
|
||||
} elseif (isset($options['noscript']) && $options['noscript'] === true) {
|
||||
unset($options['noscript']);
|
||||
return '<noscript>' . static::tag('link', '', $options) . '</noscript>';
|
||||
} else {
|
||||
return static::tag('link', '', $options);
|
||||
}
|
||||
|
||||
return static::tag('link', '', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,9 +270,9 @@ class BaseHtml
|
||||
$condition = $options['condition'];
|
||||
unset($options['condition']);
|
||||
return self::wrapIntoCondition(static::tag('script', '', $options), $condition);
|
||||
} else {
|
||||
return static::tag('script', '', $options);
|
||||
}
|
||||
|
||||
return static::tag('script', '', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -300,9 +300,9 @@ class BaseHtml
|
||||
if ($request instanceof Request && $request->enableCsrfValidation) {
|
||||
return static::tag('meta', '', ['name' => 'csrf-param', 'content' => $request->csrfParam]) . "\n "
|
||||
. static::tag('meta', '', ['name' => 'csrf-token', 'content' => $request->getCsrfToken()]) . "\n";
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -764,9 +764,9 @@ class BaseHtml
|
||||
unset($options['label'], $options['labelOptions']);
|
||||
$content = static::label(static::input($type, $name, $value, $options) . ' ' . $label, null, $labelOptions);
|
||||
return $hidden . $content;
|
||||
} else {
|
||||
return $hidden . static::input($type, $name, $value, $options);
|
||||
}
|
||||
|
||||
return $hidden . static::input($type, $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1556,9 +1556,9 @@ class BaseHtml
|
||||
{
|
||||
if (empty($options['multiple'])) {
|
||||
return static::activeListInput('dropDownList', $model, $attribute, $items, $options);
|
||||
} else {
|
||||
return static::activeListBox($model, $attribute, $items, $options);
|
||||
}
|
||||
|
||||
return static::activeListBox($model, $attribute, $items, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2080,9 +2080,9 @@ class BaseHtml
|
||||
{
|
||||
if (preg_match(static::$attributeRegex, $attribute, $matches)) {
|
||||
return $matches[2];
|
||||
} else {
|
||||
throw new InvalidParamException('Attribute name must contain word characters only.');
|
||||
}
|
||||
|
||||
throw new InvalidParamException('Attribute name must contain word characters only.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2161,9 +2161,9 @@ class BaseHtml
|
||||
return $attribute . $suffix;
|
||||
} elseif ($formName !== '') {
|
||||
return $formName . $prefix . "[$attribute]" . $suffix;
|
||||
} else {
|
||||
throw new InvalidParamException(get_class($model) . '::formName() cannot be empty for tabular inputs.');
|
||||
}
|
||||
|
||||
throw new InvalidParamException(get_class($model) . '::formName() cannot be empty for tabular inputs.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -385,9 +385,9 @@ class BaseInflector
|
||||
$regex = $strict ? '/[A-Z]/' : '/(?<![A-Z])[A-Z]/';
|
||||
if ($separator === '_') {
|
||||
return strtolower(trim(preg_replace($regex, '_\0', $name), '_'));
|
||||
} else {
|
||||
return strtolower(trim(str_replace('_', $separator, preg_replace($regex, $separator . '\0', $name)), $separator));
|
||||
}
|
||||
|
||||
return strtolower(trim(str_replace('_', $separator, preg_replace($regex, $separator . '\0', $name)), $separator));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -496,9 +496,9 @@ class BaseInflector
|
||||
}
|
||||
|
||||
return transliterator_transliterate($transliterator, $string);
|
||||
} else {
|
||||
return strtr($string, static::$transliteration);
|
||||
}
|
||||
|
||||
return strtr($string, static::$transliteration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,9 +86,9 @@ class BaseStringHelper
|
||||
$pos = mb_strrpos(str_replace('\\', '/', $path), '/');
|
||||
if ($pos !== false) {
|
||||
return mb_substr($path, 0, $pos);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,9 +110,9 @@ class BaseStringHelper
|
||||
|
||||
if (mb_strlen($string, $encoding ?: Yii::$app->charset) > $length) {
|
||||
return rtrim(mb_substr($string, 0, $length, $encoding ?: Yii::$app->charset)) . $suffix;
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,9 +134,9 @@ class BaseStringHelper
|
||||
$words = preg_split('/(\s+)/u', trim($string), null, PREG_SPLIT_DELIM_CAPTURE);
|
||||
if (count($words) / 2 > $count) {
|
||||
return implode('', array_slice($words, 0, ($count * 2) - 1)) . $suffix;
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,9 +215,9 @@ class BaseStringHelper
|
||||
}
|
||||
if ($caseSensitive) {
|
||||
return strncmp($string, $with, $bytes) === 0;
|
||||
} else {
|
||||
return mb_strtolower(mb_substr($string, 0, $bytes, '8bit'), Yii::$app->charset) === mb_strtolower($with, Yii::$app->charset);
|
||||
}
|
||||
|
||||
return mb_strtolower(mb_substr($string, 0, $bytes, '8bit'), Yii::$app->charset) === mb_strtolower($with, Yii::$app->charset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,9 +240,9 @@ class BaseStringHelper
|
||||
return false;
|
||||
}
|
||||
return substr_compare($string, $with, -$bytes, $bytes) === 0;
|
||||
} else {
|
||||
return mb_strtolower(mb_substr($string, -$bytes, mb_strlen($string, '8bit'), '8bit'), Yii::$app->charset) === mb_strtolower($with, Yii::$app->charset);
|
||||
}
|
||||
|
||||
return mb_strtolower(mb_substr($string, -$bytes, mb_strlen($string, '8bit'), '8bit'), Yii::$app->charset) === mb_strtolower($with, Yii::$app->charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,9 +100,9 @@ class BaseUrl
|
||||
|
||||
if ($scheme !== false) {
|
||||
return static::getUrlManager()->createAbsoluteUrl($route, is_string($scheme) ? $scheme : null);
|
||||
} else {
|
||||
return static::getUrlManager()->createUrl($route);
|
||||
}
|
||||
|
||||
return static::getUrlManager()->createUrl($route);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,10 +140,10 @@ class BaseUrl
|
||||
if (strpos($route, '/') === false) {
|
||||
// empty or an action ID
|
||||
return $route === '' ? Yii::$app->controller->getRoute() : Yii::$app->controller->getUniqueId() . '/' . $route;
|
||||
} else {
|
||||
// relative to module
|
||||
return ltrim(Yii::$app->controller->module->getUniqueId() . '/' . $route, '/');
|
||||
}
|
||||
|
||||
// relative to module
|
||||
return ltrim(Yii::$app->controller->module->getUniqueId() . '/' . $route, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,9 +320,9 @@ class BaseUrl
|
||||
{
|
||||
if ($name === null) {
|
||||
return Yii::$app->getUser()->getReturnUrl();
|
||||
} else {
|
||||
return Yii::$app->getSession()->get($name);
|
||||
}
|
||||
|
||||
return Yii::$app->getSession()->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,9 +127,9 @@ class DbMessageSource extends MessageSource
|
||||
}
|
||||
|
||||
return $messages;
|
||||
} else {
|
||||
return $this->loadMessagesFromDb($category, $language);
|
||||
}
|
||||
|
||||
return $this->loadMessagesFromDb($category, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,9 +328,9 @@ class Formatter extends Component
|
||||
$method = 'as' . $format;
|
||||
if ($this->hasMethod($method)) {
|
||||
return call_user_func_array([$this, $method], $params);
|
||||
} else {
|
||||
throw new InvalidParamException("Unknown format type: $format");
|
||||
}
|
||||
|
||||
throw new InvalidParamException("Unknown format type: $format");
|
||||
}
|
||||
|
||||
|
||||
@ -649,21 +649,22 @@ class Formatter extends Component
|
||||
$timestamp = new DateTime($timestamp->format(DateTime::ISO8601), $timestamp->getTimezone());
|
||||
}
|
||||
return $formatter->format($timestamp);
|
||||
} else {
|
||||
if (strncmp($format, 'php:', 4) === 0) {
|
||||
$format = substr($format, 4);
|
||||
} else {
|
||||
$format = FormatConverter::convertDateIcuToPhp($format, $type, $this->locale);
|
||||
}
|
||||
if ($timeZone != null) {
|
||||
if ($timestamp instanceof \DateTimeImmutable) {
|
||||
$timestamp = $timestamp->setTimezone(new DateTimeZone($timeZone));
|
||||
} else {
|
||||
$timestamp->setTimezone(new DateTimeZone($timeZone));
|
||||
}
|
||||
}
|
||||
return $timestamp->format($format);
|
||||
}
|
||||
|
||||
if (strncmp($format, 'php:', 4) === 0) {
|
||||
$format = substr($format, 4);
|
||||
} else {
|
||||
$format = FormatConverter::convertDateIcuToPhp($format, $type, $this->locale);
|
||||
}
|
||||
if ($timeZone != null) {
|
||||
if ($timestamp instanceof \DateTimeImmutable) {
|
||||
$timestamp = $timestamp->setTimezone(new DateTimeZone($timeZone));
|
||||
} else {
|
||||
$timestamp->setTimezone(new DateTimeZone($timeZone));
|
||||
}
|
||||
}
|
||||
|
||||
return $timestamp->format($format);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -718,9 +719,9 @@ class Formatter extends Component
|
||||
!($info['hour'] === false && $info['minute'] === false && $info['second'] === false),
|
||||
!($info['year'] === false && $info['month'] === false && $info['day'] === false),
|
||||
];
|
||||
} else {
|
||||
return new DateTime($value, new DateTimeZone($this->defaultTimeZone));
|
||||
}
|
||||
|
||||
return new DateTime($value, new DateTimeZone($this->defaultTimeZone));
|
||||
} catch (\Exception $e) {
|
||||
throw new InvalidParamException("'$value' is not a valid date time value: " . $e->getMessage()
|
||||
. "\n" . print_r(DateTime::getLastErrors(), true), $e->getCode(), $e);
|
||||
@ -826,28 +827,30 @@ class Formatter extends Component
|
||||
if ($interval->s == 0) {
|
||||
return Yii::t('yii', 'just now', [], $this->locale);
|
||||
}
|
||||
|
||||
return Yii::t('yii', 'in {delta, plural, =1{a second} other{# seconds}}', ['delta' => $interval->s], $this->locale);
|
||||
} else {
|
||||
if ($interval->y >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a year} other{# years}} ago', ['delta' => $interval->y], $this->locale);
|
||||
}
|
||||
if ($interval->m >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a month} other{# months}} ago', ['delta' => $interval->m], $this->locale);
|
||||
}
|
||||
if ($interval->d >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a day} other{# days}} ago', ['delta' => $interval->d], $this->locale);
|
||||
}
|
||||
if ($interval->h >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{an hour} other{# hours}} ago', ['delta' => $interval->h], $this->locale);
|
||||
}
|
||||
if ($interval->i >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a minute} other{# minutes}} ago', ['delta' => $interval->i], $this->locale);
|
||||
}
|
||||
if ($interval->s == 0) {
|
||||
return Yii::t('yii', 'just now', [], $this->locale);
|
||||
}
|
||||
return Yii::t('yii', '{delta, plural, =1{a second} other{# seconds}} ago', ['delta' => $interval->s], $this->locale);
|
||||
}
|
||||
|
||||
if ($interval->y >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a year} other{# years}} ago', ['delta' => $interval->y], $this->locale);
|
||||
}
|
||||
if ($interval->m >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a month} other{# months}} ago', ['delta' => $interval->m], $this->locale);
|
||||
}
|
||||
if ($interval->d >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a day} other{# days}} ago', ['delta' => $interval->d], $this->locale);
|
||||
}
|
||||
if ($interval->h >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{an hour} other{# hours}} ago', ['delta' => $interval->h], $this->locale);
|
||||
}
|
||||
if ($interval->i >= 1) {
|
||||
return Yii::t('yii', '{delta, plural, =1{a minute} other{# minutes}} ago', ['delta' => $interval->i], $this->locale);
|
||||
}
|
||||
if ($interval->s == 0) {
|
||||
return Yii::t('yii', 'just now', [], $this->locale);
|
||||
}
|
||||
|
||||
return Yii::t('yii', '{delta, plural, =1{a second} other{# seconds}} ago', ['delta' => $interval->s], $this->locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -941,10 +944,11 @@ class Formatter extends Component
|
||||
if (($result = $f->format($value, NumberFormatter::TYPE_INT64)) === false) {
|
||||
throw new InvalidParamException('Formatting integer value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
return number_format((int) $value, 0, $this->decimalSeparator, $this->thousandSeparator);
|
||||
}
|
||||
|
||||
return number_format((int) $value, 0, $this->decimalSeparator, $this->thousandSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -980,13 +984,15 @@ class Formatter extends Component
|
||||
if (($result = $f->format($value)) === false) {
|
||||
throw new InvalidParamException('Formatting decimal value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
if ($decimals === null) {
|
||||
$decimals = 2;
|
||||
}
|
||||
return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator);
|
||||
}
|
||||
|
||||
if ($decimals === null) {
|
||||
$decimals = 2;
|
||||
}
|
||||
|
||||
return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator);
|
||||
}
|
||||
|
||||
|
||||
@ -1019,13 +1025,14 @@ class Formatter extends Component
|
||||
throw new InvalidParamException('Formatting percent value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
if ($decimals === null) {
|
||||
$decimals = 0;
|
||||
}
|
||||
$value *= 100;
|
||||
return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator) . '%';
|
||||
}
|
||||
|
||||
if ($decimals === null) {
|
||||
$decimals = 0;
|
||||
}
|
||||
|
||||
$value *= 100;
|
||||
return number_format($value, $decimals, $this->decimalSeparator, $this->thousandSeparator) . '%';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1056,14 +1063,15 @@ class Formatter extends Component
|
||||
if (($result = $f->format($value)) === false) {
|
||||
throw new InvalidParamException('Formatting scientific number value failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
if ($decimals !== null) {
|
||||
return sprintf("%.{$decimals}E", $value);
|
||||
} else {
|
||||
return sprintf('%.E', $value);
|
||||
}
|
||||
}
|
||||
|
||||
if ($decimals !== null) {
|
||||
return sprintf("%.{$decimals}E", $value);
|
||||
}
|
||||
|
||||
return sprintf('%.E', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1104,16 +1112,18 @@ class Formatter extends Component
|
||||
if ($result === false) {
|
||||
throw new InvalidParamException('Formatting currency value failed: ' . $formatter->getErrorCode() . ' ' . $formatter->getErrorMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
if ($currency === null) {
|
||||
if ($this->currencyCode === null) {
|
||||
throw new InvalidConfigException('The default currency code for the formatter is not defined and the php intl extension is not installed which could take the default currency from the locale.');
|
||||
}
|
||||
$currency = $this->currencyCode;
|
||||
}
|
||||
return $currency . ' ' . $this->asDecimal($value, 2, $options, $textOptions);
|
||||
}
|
||||
|
||||
if ($currency === null) {
|
||||
if ($this->currencyCode === null) {
|
||||
throw new InvalidConfigException('The default currency code for the formatter is not defined and the php intl extension is not installed which could take the default currency from the locale.');
|
||||
}
|
||||
$currency = $this->currencyCode;
|
||||
}
|
||||
|
||||
return $currency . ' ' . $this->asDecimal($value, 2, $options, $textOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1137,10 +1147,11 @@ class Formatter extends Component
|
||||
if (($result = $f->format($value)) === false) {
|
||||
throw new InvalidParamException('Formatting number as spellout failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
throw new InvalidConfigException('Format as Spellout is only supported when PHP intl extension is installed.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('Format as Spellout is only supported when PHP intl extension is installed.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1164,10 +1175,11 @@ class Formatter extends Component
|
||||
if (($result = $f->format($value)) === false) {
|
||||
throw new InvalidParamException('Formatting number as ordinal failed: ' . $f->getErrorCode() . ' ' . $f->getErrorMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
throw new InvalidConfigException('Format as Ordinal is only supported when PHP intl extension is installed.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('Format as Ordinal is only supported when PHP intl extension is installed.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,8 +162,8 @@ class GettextMessageSource extends MessageSource
|
||||
}
|
||||
|
||||
return $messages;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -207,9 +207,9 @@ class GettextMoFile extends GettextFile
|
||||
{
|
||||
if ($byteCount > 0) {
|
||||
return fread($fileHandle, $byteCount);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,9 +89,9 @@ class I18N extends Component
|
||||
$translation = $messageSource->translate($category, $message, $language);
|
||||
if ($translation === false) {
|
||||
return $this->format($message, $params, $messageSource->sourceLanguage);
|
||||
} else {
|
||||
return $this->format($translation, $params, $language);
|
||||
}
|
||||
|
||||
return $this->format($translation, $params, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,9 +117,9 @@ class I18N extends Component
|
||||
Yii::warning("Formatting message for language '$language' failed with error: $errorMessage. The message being formatted was: $message.", __METHOD__);
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$p = [];
|
||||
@ -172,31 +172,31 @@ class I18N extends Component
|
||||
$source = $this->translations[$category];
|
||||
if ($source instanceof MessageSource) {
|
||||
return $source;
|
||||
} else {
|
||||
return $this->translations[$category] = Yii::createObject($source);
|
||||
}
|
||||
} else {
|
||||
// try wildcard matching
|
||||
foreach ($this->translations as $pattern => $source) {
|
||||
if (strpos($pattern, '*') > 0 && strpos($category, rtrim($pattern, '*')) === 0) {
|
||||
if ($source instanceof MessageSource) {
|
||||
return $source;
|
||||
} else {
|
||||
return $this->translations[$category] = $this->translations[$pattern] = Yii::createObject($source);
|
||||
}
|
||||
}
|
||||
}
|
||||
// match '*' in the last
|
||||
if (isset($this->translations['*'])) {
|
||||
$source = $this->translations['*'];
|
||||
|
||||
return $this->translations[$category] = Yii::createObject($source);
|
||||
}
|
||||
// try wildcard matching
|
||||
foreach ($this->translations as $pattern => $source) {
|
||||
if (strpos($pattern, '*') > 0 && strpos($category, rtrim($pattern, '*')) === 0) {
|
||||
if ($source instanceof MessageSource) {
|
||||
return $source;
|
||||
} else {
|
||||
return $this->translations[$category] = $this->translations['*'] = Yii::createObject($source);
|
||||
}
|
||||
|
||||
return $this->translations[$category] = $this->translations[$pattern] = Yii::createObject($source);
|
||||
}
|
||||
}
|
||||
|
||||
// match '*' in the last
|
||||
if (isset($this->translations['*'])) {
|
||||
$source = $this->translations['*'];
|
||||
if ($source instanceof MessageSource) {
|
||||
return $source;
|
||||
}
|
||||
|
||||
return $this->translations[$category] = $this->translations['*'] = Yii::createObject($source);
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Unable to locate message source for category '$category'.");
|
||||
}
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ class MessageFormatter extends Component
|
||||
$this->_errorCode = $formatter->getErrorCode();
|
||||
$this->_errorMessage = $formatter->getErrorMessage();
|
||||
return false;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,14 +187,14 @@ class MessageFormatter extends Component
|
||||
$this->_errorMessage = $formatter->getErrorMessage();
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$values = [];
|
||||
foreach ($result as $key => $value) {
|
||||
$values[$map[$key]] = $value;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($result as $key => $value) {
|
||||
$values[$map[$key]] = $value;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,9 +85,9 @@ class MessageSource extends Component
|
||||
{
|
||||
if ($this->forceTranslation || $language !== $this->sourceLanguage) {
|
||||
return $this->translateMessage($category, $message, $language);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,8 +159,8 @@ class PhpMessageSource extends MessageSource
|
||||
}
|
||||
|
||||
return $messages;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -301,9 +301,9 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
|
||||
$output = $this->getView()->render($view, $params, $this);
|
||||
if ($layout !== false) {
|
||||
return $this->getView()->render($layout, ['content' => $output, 'message' => $this->_message], $this);
|
||||
} else {
|
||||
return $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,13 +117,13 @@ class FileMutex extends Mutex
|
||||
{
|
||||
if (!isset($this->_files[$name]) || !flock($this->_files[$name], LOCK_UN)) {
|
||||
return false;
|
||||
} else {
|
||||
fclose($this->_files[$name]);
|
||||
unlink($this->getLockFilePath($name));
|
||||
unset($this->_files[$name]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
fclose($this->_files[$name]);
|
||||
unlink($this->getLockFilePath($name));
|
||||
unset($this->_files[$name]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,9 +72,9 @@ abstract class Mutex extends Component
|
||||
$this->_locks[] = $name;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,9 +91,9 @@ abstract class Mutex extends Component
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,9 +128,9 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
return $this->addItem($object);
|
||||
} elseif ($object instanceof Rule) {
|
||||
return $this->addRule($object);
|
||||
} else {
|
||||
throw new InvalidParamException('Adding unsupported object type.');
|
||||
}
|
||||
|
||||
throw new InvalidParamException('Adding unsupported object type.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,9 +142,9 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
return $this->removeItem($object);
|
||||
} elseif ($object instanceof Rule) {
|
||||
return $this->removeRule($object);
|
||||
} else {
|
||||
throw new InvalidParamException('Removing unsupported object type.');
|
||||
}
|
||||
|
||||
throw new InvalidParamException('Removing unsupported object type.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,9 +161,9 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
return $this->updateItem($name, $object);
|
||||
} elseif ($object instanceof Rule) {
|
||||
return $this->updateRule($name, $object);
|
||||
} else {
|
||||
throw new InvalidParamException('Updating unsupported object type.');
|
||||
}
|
||||
|
||||
throw new InvalidParamException('Updating unsupported object type.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,9 +235,9 @@ abstract class BaseManager extends Component implements ManagerInterface
|
||||
$rule = $this->getRule($item->ruleName);
|
||||
if ($rule instanceof Rule) {
|
||||
return $rule->execute($user, $item, $params);
|
||||
} else {
|
||||
throw new InvalidConfigException("Rule not found: {$item->ruleName}");
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Rule not found: {$item->ruleName}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,9 +129,9 @@ class DbManager extends BaseManager
|
||||
$this->loadFromCache();
|
||||
if ($this->items !== null) {
|
||||
return $this->checkAccessFromCache($userId, $permissionName, $params, $assignments);
|
||||
} else {
|
||||
return $this->checkAccessRecursive($userId, $permissionName, $params, $assignments);
|
||||
}
|
||||
|
||||
return $this->checkAccessRecursive($userId, $permissionName, $params, $assignments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,9 +226,9 @@ class PhpManager extends BaseManager
|
||||
unset($this->children[$parent->name][$child->name]);
|
||||
$this->saveItems();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,9 +240,9 @@ class PhpManager extends BaseManager
|
||||
unset($this->children[$parent->name]);
|
||||
$this->saveItems();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,15 +262,16 @@ class PhpManager extends BaseManager
|
||||
throw new InvalidParamException("Unknown role '{$role->name}'.");
|
||||
} elseif (isset($this->assignments[$userId][$role->name])) {
|
||||
throw new InvalidParamException("Authorization item '{$role->name}' has already been assigned to user '$userId'.");
|
||||
} else {
|
||||
$this->assignments[$userId][$role->name] = new Assignment([
|
||||
'userId' => $userId,
|
||||
'roleName' => $role->name,
|
||||
'createdAt' => time(),
|
||||
]);
|
||||
$this->saveAssignments();
|
||||
return $this->assignments[$userId][$role->name];
|
||||
}
|
||||
|
||||
$this->assignments[$userId][$role->name] = new Assignment([
|
||||
'userId' => $userId,
|
||||
'roleName' => $role->name,
|
||||
'createdAt' => time(),
|
||||
]);
|
||||
$this->saveAssignments();
|
||||
|
||||
return $this->assignments[$userId][$role->name];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,9 +283,9 @@ class PhpManager extends BaseManager
|
||||
unset($this->assignments[$userId][$role->name]);
|
||||
$this->saveAssignments();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,9 +299,9 @@ class PhpManager extends BaseManager
|
||||
}
|
||||
$this->saveAssignments();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,9 +346,9 @@ class PhpManager extends BaseManager
|
||||
$this->saveItems();
|
||||
$this->saveAssignments();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -630,9 +631,9 @@ class PhpManager extends BaseManager
|
||||
}
|
||||
$this->saveRules();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -653,29 +654,29 @@ class PhpManager extends BaseManager
|
||||
if ($name !== $item->name) {
|
||||
if (isset($this->items[$item->name])) {
|
||||
throw new InvalidParamException("Unable to change the item name. The name '{$item->name}' is already used by another item.");
|
||||
} else {
|
||||
// Remove old item in case of renaming
|
||||
unset($this->items[$name]);
|
||||
|
||||
if (isset($this->children[$name])) {
|
||||
$this->children[$item->name] = $this->children[$name];
|
||||
unset($this->children[$name]);
|
||||
}
|
||||
foreach ($this->children as &$children) {
|
||||
if (isset($children[$name])) {
|
||||
$children[$item->name] = $children[$name];
|
||||
unset($children[$name]);
|
||||
}
|
||||
}
|
||||
foreach ($this->assignments as &$assignments) {
|
||||
if (isset($assignments[$name])) {
|
||||
$assignments[$item->name] = $assignments[$name];
|
||||
$assignments[$item->name]->roleName = $item->name;
|
||||
unset($assignments[$name]);
|
||||
}
|
||||
}
|
||||
$this->saveAssignments();
|
||||
}
|
||||
|
||||
// Remove old item in case of renaming
|
||||
unset($this->items[$name]);
|
||||
|
||||
if (isset($this->children[$name])) {
|
||||
$this->children[$item->name] = $this->children[$name];
|
||||
unset($this->children[$name]);
|
||||
}
|
||||
foreach ($this->children as &$children) {
|
||||
if (isset($children[$name])) {
|
||||
$children[$item->name] = $children[$name];
|
||||
unset($children[$name]);
|
||||
}
|
||||
}
|
||||
foreach ($this->assignments as &$assignments) {
|
||||
if (isset($assignments[$name])) {
|
||||
$assignments[$item->name] = $assignments[$name];
|
||||
$assignments[$item->name]->roleName = $item->name;
|
||||
unset($assignments[$name]);
|
||||
}
|
||||
}
|
||||
$this->saveAssignments();
|
||||
}
|
||||
|
||||
$this->items[$item->name] = $item;
|
||||
@ -779,9 +780,9 @@ class PhpManager extends BaseManager
|
||||
{
|
||||
if (is_file($file)) {
|
||||
return require($file);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,8 +99,8 @@ class Action extends \yii\base\Action
|
||||
|
||||
if (isset($model)) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException("Object not found: $id");
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException("Object not found: $id");
|
||||
}
|
||||
}
|
||||
|
@ -150,9 +150,9 @@ class Serializer extends Component
|
||||
return $this->serializeModel($data);
|
||||
} elseif ($data instanceof DataProviderInterface) {
|
||||
return $this->serializeDataProvider($data);
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,16 +195,16 @@ class Serializer extends Component
|
||||
return null;
|
||||
} elseif ($this->collectionEnvelope === null) {
|
||||
return $models;
|
||||
} else {
|
||||
$result = [
|
||||
$this->collectionEnvelope => $models,
|
||||
];
|
||||
if ($pagination !== false) {
|
||||
return array_merge($result, $this->serializePagination($pagination));
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
$this->collectionEnvelope => $models,
|
||||
];
|
||||
if ($pagination !== false) {
|
||||
return array_merge($result, $this->serializePagination($pagination));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,10 +254,10 @@ class Serializer extends Component
|
||||
{
|
||||
if ($this->request->getIsHead()) {
|
||||
return null;
|
||||
} else {
|
||||
list($fields, $expand) = $this->getRequestedFields();
|
||||
return $model->toArray($fields, $expand);
|
||||
}
|
||||
|
||||
list($fields, $expand) = $this->getRequestedFields();
|
||||
return $model->toArray($fields, $expand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,9 +99,9 @@ class ActiveFixture extends BaseActiveFixture
|
||||
$dataFile = dirname($class->getFileName()) . '/data/' . $this->getTableSchema()->fullName . '.php';
|
||||
|
||||
return is_file($dataFile) ? require($dataFile) : [];
|
||||
} else {
|
||||
return parent::getData();
|
||||
}
|
||||
|
||||
return parent::getData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,9 +62,9 @@ class ArrayFixture extends Fixture implements \IteratorAggregate, \ArrayAccess,
|
||||
$dataFile = Yii::getAlias($this->dataFile);
|
||||
if (is_file($dataFile)) {
|
||||
return require($dataFile);
|
||||
} else {
|
||||
throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,9 +101,9 @@ abstract class BaseActiveFixture extends DbFixture implements \IteratorAggregate
|
||||
$dataFile = Yii::getAlias($this->dataFile);
|
||||
if (is_file($dataFile)) {
|
||||
return require($dataFile);
|
||||
} else {
|
||||
throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,9 +176,9 @@ class CompareValidator extends Validator
|
||||
'compareValue' => $this->compareValue,
|
||||
'compareValueOrAttribute' => $this->compareValue,
|
||||
]];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,9 +312,9 @@ class DateValidator extends Validator
|
||||
return [$this->tooSmall, ['min' => $this->minString]];
|
||||
} elseif ($this->max !== null && $timestamp > $this->max) {
|
||||
return [$this->tooBig, ['max' => $this->maxString]];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,11 +346,12 @@ class DateValidator extends Validator
|
||||
} else {
|
||||
if (extension_loaded('intl')) {
|
||||
return $this->parseDateValueIntl($value, $format);
|
||||
} else {
|
||||
// fallback to PHP if intl is not installed
|
||||
$format = FormatConverter::convertDateIcuToPhp($format, 'date');
|
||||
}
|
||||
|
||||
// fallback to PHP if intl is not installed
|
||||
$format = FormatConverter::convertDateIcuToPhp($format, 'date');
|
||||
}
|
||||
|
||||
return $this->parseDateValuePHP($value, $format);
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,9 @@ class EachValidator extends Validator
|
||||
$model = new Model(); // mock up context model
|
||||
}
|
||||
return Validator::createValidator($rule[0], $model, $this->attributes, array_slice($rule, 1));
|
||||
} else {
|
||||
throw new InvalidConfigException('Invalid validation rule: a rule must be an array specifying validator type.');
|
||||
}
|
||||
|
||||
throw new InvalidConfigException('Invalid validation rule: a rule must be an array specifying validator type.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,9 +184,9 @@ class EachValidator extends Validator
|
||||
if ($this->allowMessageFromRule) {
|
||||
$result[1]['value'] = $v;
|
||||
return $result;
|
||||
} else {
|
||||
return [$this->message, ['value' => $v]];
|
||||
}
|
||||
|
||||
return [$this->message, ['value' => $v]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,9 +183,9 @@ class ExistValidator extends Validator
|
||||
return [$this->message, []];
|
||||
}
|
||||
return $query->count("DISTINCT [[$this->targetAttribute]]") == count($value) ? null : [$this->message, []];
|
||||
} else {
|
||||
return $query->exists() ? null : [$this->message, []];
|
||||
}
|
||||
|
||||
return $query->exists() ? null : [$this->message, []];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,8 +84,8 @@ class InlineValidator extends Validator
|
||||
}
|
||||
|
||||
return call_user_func($method, $attribute, $this->params, $this);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -297,9 +297,9 @@ class IpValidator extends Validator
|
||||
if (is_array($result)) {
|
||||
$result[1] = array_merge(['ip' => is_array($value) ? 'array()' : $value], $result[1]);
|
||||
return $result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -564,16 +564,17 @@ class IpValidator extends Validator
|
||||
{
|
||||
if ($this->getIpVersion($ip) === 4) {
|
||||
return str_pad(base_convert(ip2long($ip), 10, 2), static::IPV4_ADDRESS_LENGTH, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$unpack = unpack('A16', inet_pton($ip));
|
||||
$binStr = array_shift($unpack);
|
||||
$bytes = static::IPV6_ADDRESS_LENGTH / 8; // 128 bit / 8 = 16 bytes
|
||||
$result = '';
|
||||
while ($bytes-- > 0) {
|
||||
$result = sprintf('%08b', isset($binStr[$bytes]) ? ord($binStr[$bytes]) : '0') . $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
$unpack = unpack('A16', inet_pton($ip));
|
||||
$binStr = array_shift($unpack);
|
||||
$bytes = static::IPV6_ADDRESS_LENGTH / 8; // 128 bit / 8 = 16 bytes
|
||||
$result = '';
|
||||
while ($bytes-- > 0) {
|
||||
$result = sprintf('%08b', isset($binStr[$bytes]) ? ord($binStr[$bytes]) : '0') . $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,9 +113,9 @@ class NumberValidator extends Validator
|
||||
return [$this->tooSmall, ['min' => $this->min]];
|
||||
} elseif ($this->max !== null && $value > $this->max) {
|
||||
return [$this->tooBig, ['max' => $this->max]];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,11 +76,11 @@ class RequiredValidator extends Validator
|
||||
}
|
||||
if ($this->requiredValue === null) {
|
||||
return [$this->message, []];
|
||||
} else {
|
||||
return [$this->message, [
|
||||
'requiredValue' => $this->requiredValue,
|
||||
]];
|
||||
}
|
||||
|
||||
return [$this->message, [
|
||||
'requiredValue' => $this->requiredValue,
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -428,9 +428,9 @@ class Validator extends Component
|
||||
{
|
||||
if ($this->isEmpty !== null) {
|
||||
return call_user_func($this->isEmpty, $value);
|
||||
} else {
|
||||
return $value === null || $value === [] || $value === '';
|
||||
}
|
||||
|
||||
return $value === null || $value === [] || $value === '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,14 +102,14 @@ class Application extends \yii\base\Application
|
||||
$result = $this->runAction($route, $params);
|
||||
if ($result instanceof Response) {
|
||||
return $result;
|
||||
} else {
|
||||
$response = $this->getResponse();
|
||||
if ($result !== null) {
|
||||
$response->data = $result;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response = $this->getResponse();
|
||||
if ($result !== null) {
|
||||
$response->data = $result;
|
||||
}
|
||||
|
||||
return $response;
|
||||
} catch (InvalidRouteException $e) {
|
||||
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
|
||||
}
|
||||
@ -125,12 +125,12 @@ class Application extends \yii\base\Application
|
||||
if ($this->_homeUrl === null) {
|
||||
if ($this->getUrlManager()->showScriptName) {
|
||||
return $this->getRequest()->getScriptUrl();
|
||||
} else {
|
||||
return $this->getRequest()->getBaseUrl() . '/';
|
||||
}
|
||||
} else {
|
||||
return $this->_homeUrl;
|
||||
|
||||
return $this->getRequest()->getBaseUrl() . '/';
|
||||
}
|
||||
|
||||
return $this->_homeUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,9 +213,9 @@ class AssetManager extends Component
|
||||
throw new InvalidConfigException("The directory does not exist: {$this->basePath}");
|
||||
} elseif (!is_writable($this->basePath)) {
|
||||
throw new InvalidConfigException("The directory is not writable by the Web process: {$this->basePath}");
|
||||
} else {
|
||||
$this->basePath = realpath($this->basePath);
|
||||
}
|
||||
|
||||
$this->basePath = realpath($this->basePath);
|
||||
$this->baseUrl = rtrim(Yii::getAlias($this->baseUrl), '/');
|
||||
}
|
||||
|
||||
@ -243,9 +243,9 @@ class AssetManager extends Component
|
||||
return $this->bundles[$name] = $this->loadBundle($name, $this->bundles[$name], $publish);
|
||||
} elseif ($this->bundles[$name] === false) {
|
||||
return $this->loadDummyBundle($name);
|
||||
} else {
|
||||
throw new InvalidConfigException("Invalid asset bundle configuration: $name");
|
||||
}
|
||||
|
||||
throw new InvalidConfigException("Invalid asset bundle configuration: $name");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,9 +319,9 @@ class AssetManager extends Component
|
||||
|
||||
if ($this->appendTimestamp && ($timestamp = @filemtime("$basePath/$asset")) > 0) {
|
||||
return "$baseUrl/$asset?v=$timestamp";
|
||||
} else {
|
||||
return "$baseUrl/$asset";
|
||||
}
|
||||
|
||||
return "$baseUrl/$asset";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -334,9 +334,9 @@ class AssetManager extends Component
|
||||
{
|
||||
if (($actualAsset = $this->resolveAsset($bundle, $asset)) !== false) {
|
||||
return Url::isRelative($actualAsset) ? $this->basePath . '/' . $actualAsset : false;
|
||||
} else {
|
||||
return Url::isRelative($asset) ? $bundle->basePath . '/' . $asset : false;
|
||||
}
|
||||
|
||||
return Url::isRelative($asset) ? $bundle->basePath . '/' . $asset : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -456,9 +456,9 @@ class AssetManager extends Component
|
||||
|
||||
if (is_file($src)) {
|
||||
return $this->_published[$path] = $this->publishFile($src);
|
||||
} else {
|
||||
return $this->_published[$path] = $this->publishDirectory($src, $options);
|
||||
}
|
||||
|
||||
return $this->_published[$path] = $this->publishDirectory($src, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -564,9 +564,9 @@ class AssetManager extends Component
|
||||
}
|
||||
if (is_string($path) && ($path = realpath($path)) !== false) {
|
||||
return $this->basePath . DIRECTORY_SEPARATOR . $this->hash($path) . (is_file($path) ? DIRECTORY_SEPARATOR . basename($path) : '');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -585,9 +585,9 @@ class AssetManager extends Component
|
||||
}
|
||||
if (is_string($path) && ($path = realpath($path)) !== false) {
|
||||
return $this->baseUrl . '/' . $this->hash($path) . (is_file($path) ? '/' . basename($path) : '');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,9 +250,9 @@ class ErrorHandler extends \yii\base\ErrorHandler
|
||||
require(Yii::getAlias($_file_));
|
||||
|
||||
return ob_get_clean();
|
||||
} else {
|
||||
return Yii::$app->getView()->renderFile($_file_, $_params_, $this);
|
||||
}
|
||||
|
||||
return Yii::$app->getView()->renderFile($_file_, $_params_, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,9 +265,9 @@ class ErrorHandler extends \yii\base\ErrorHandler
|
||||
{
|
||||
if (($previous = $exception->getPrevious()) !== null) {
|
||||
return $this->renderFile($this->previousExceptionView, ['exception' => $previous]);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,9 +116,9 @@ class GroupUrlRule extends CompositeUrlRule
|
||||
$pathInfo = $request->getPathInfo();
|
||||
if ($this->prefix === '' || strpos($pathInfo . '/', $this->prefix . '/') === 0) {
|
||||
return parent::parseRequest($manager, $request);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,9 +128,9 @@ class GroupUrlRule extends CompositeUrlRule
|
||||
{
|
||||
if ($this->routePrefix === '' || strpos($route, $this->routePrefix . '/') === 0) {
|
||||
return parent::createUrl($manager, $route, $params);
|
||||
} else {
|
||||
$this->createStatus = UrlRule::CREATE_STATUS_ROUTE_MISMATCH;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->createStatus = UrlRule::CREATE_STATUS_ROUTE_MISMATCH;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ class HeaderCollection extends Object implements \IteratorAggregate, \ArrayAcces
|
||||
$name = strtolower($name);
|
||||
if (isset($this->_headers[$name])) {
|
||||
return $first ? reset($this->_headers[$name]) : $this->_headers[$name];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,9 +151,9 @@ class HeaderCollection extends Object implements \IteratorAggregate, \ArrayAcces
|
||||
$value = $this->_headers[$name];
|
||||
unset($this->_headers[$name]);
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,8 +55,8 @@ class HttpException extends UserException
|
||||
{
|
||||
if (isset(Response::$httpStatuses[$this->statusCode])) {
|
||||
return Response::$httpStatuses[$this->statusCode];
|
||||
} else {
|
||||
return 'Error';
|
||||
}
|
||||
|
||||
return 'Error';
|
||||
}
|
||||
}
|
||||
|
@ -134,8 +134,8 @@ abstract class MultiFieldSession extends Session
|
||||
return session_encode();
|
||||
}
|
||||
return $fields['data'];
|
||||
} else {
|
||||
return isset($fields['data']) ? $fields['data'] : '';
|
||||
}
|
||||
|
||||
return isset($fields['data']) ? $fields['data'] : '';
|
||||
}
|
||||
}
|
||||
|
@ -647,9 +647,9 @@ class Response extends \yii\base\Response
|
||||
}
|
||||
if ($start < 0 || $start > $end) {
|
||||
return false;
|
||||
} else {
|
||||
return [$start, $end];
|
||||
}
|
||||
|
||||
return [$start, $end];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,9 +395,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
return false;
|
||||
} elseif (ini_get('session.use_only_cookies') === '1') {
|
||||
return true;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -622,9 +622,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
unset($_SESSION[$key]);
|
||||
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -697,9 +697,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
}
|
||||
|
||||
return $value;
|
||||
} else {
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,18 +308,18 @@ class UrlManager extends Component
|
||||
if ($normalized) {
|
||||
// pathInfo was changed by normalizer - we need also normalize route
|
||||
return $this->normalizer->normalizeRoute([$pathInfo, []]);
|
||||
} else {
|
||||
return [$pathInfo, []];
|
||||
}
|
||||
} else {
|
||||
Yii::trace('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__);
|
||||
$route = $request->getQueryParam($this->routeParam, '');
|
||||
if (is_array($route)) {
|
||||
$route = '';
|
||||
}
|
||||
|
||||
return [(string) $route, []];
|
||||
return [$pathInfo, []];
|
||||
}
|
||||
|
||||
Yii::trace('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__);
|
||||
$route = $request->getQueryParam($this->routeParam, '');
|
||||
if (is_array($route)) {
|
||||
$route = '';
|
||||
}
|
||||
|
||||
return [(string) $route, []];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,19 +393,19 @@ class UrlManager extends Component
|
||||
if (strpos($url, '://') !== false) {
|
||||
if ($baseUrl !== '' && ($pos = strpos($url, '/', 8)) !== false) {
|
||||
return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor;
|
||||
} else {
|
||||
return $url . $baseUrl . $anchor;
|
||||
}
|
||||
|
||||
return $url . $baseUrl . $anchor;
|
||||
} elseif (strpos($url, '//') === 0) {
|
||||
if ($baseUrl !== '' && ($pos = strpos($url, '/', 2)) !== false) {
|
||||
return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor;
|
||||
} else {
|
||||
return $url . $baseUrl . $anchor;
|
||||
}
|
||||
} else {
|
||||
$url = ltrim($url, '/');
|
||||
return "$baseUrl/{$url}{$anchor}";
|
||||
|
||||
return $url . $baseUrl . $anchor;
|
||||
}
|
||||
|
||||
$url = ltrim($url, '/');
|
||||
return "$baseUrl/{$url}{$anchor}";
|
||||
}
|
||||
|
||||
if ($this->suffix !== null) {
|
||||
@ -417,14 +417,14 @@ class UrlManager extends Component
|
||||
|
||||
$route = ltrim($route, '/');
|
||||
return "$baseUrl/{$route}{$anchor}";
|
||||
} else {
|
||||
$url = "$baseUrl?{$this->routeParam}=" . urlencode($route);
|
||||
if (!empty($params) && ($query = http_build_query($params)) !== '') {
|
||||
$url .= '&' . $query;
|
||||
}
|
||||
|
||||
return $url . $anchor;
|
||||
}
|
||||
|
||||
$url = "$baseUrl?{$this->routeParam}=" . urlencode($route);
|
||||
if (!empty($params) && ($query = http_build_query($params)) !== '') {
|
||||
$url .= '&' . $query;
|
||||
}
|
||||
|
||||
return $url . $anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -353,9 +353,9 @@ class UrlRule extends Object implements UrlRuleInterface
|
||||
{
|
||||
if ($this->normalizer === null) {
|
||||
return $manager->normalizer;
|
||||
} else {
|
||||
return $this->normalizer;
|
||||
}
|
||||
|
||||
return $this->normalizer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -439,9 +439,9 @@ class UrlRule extends Object implements UrlRuleInterface
|
||||
if ($normalized) {
|
||||
// pathInfo was changed by normalizer - we need also normalize route
|
||||
return $this->getNormalizer($manager)->normalizeRoute([$route, $params]);
|
||||
} else {
|
||||
return [$route, $params];
|
||||
}
|
||||
|
||||
return [$route, $params];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,9 +271,9 @@ class User extends Component
|
||||
$identity = $class::findIdentityByAccessToken($token, $type);
|
||||
if ($identity && $this->login($identity)) {
|
||||
return $identity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -363,9 +363,9 @@ class User extends Component
|
||||
if (is_array($url)) {
|
||||
if (isset($url[0])) {
|
||||
return Yii::$app->getUrlManager()->createUrl($url);
|
||||
} else {
|
||||
$url = null;
|
||||
}
|
||||
|
||||
$url = null;
|
||||
}
|
||||
|
||||
return $url === null ? Yii::$app->getHomeUrl() : $url;
|
||||
|
@ -87,11 +87,11 @@ class ViewAction extends Action
|
||||
|
||||
if (YII_DEBUG) {
|
||||
throw new NotFoundHttpException($e->getMessage());
|
||||
} else {
|
||||
throw new NotFoundHttpException(
|
||||
Yii::t('yii', 'The requested view "{name}" was not found.', ['name' => $viewName])
|
||||
);
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException(
|
||||
Yii::t('yii', 'The requested view "{name}" was not found.', ['name' => $viewName])
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
@ -121,9 +121,9 @@ class ViewAction extends Action
|
||||
if (!is_string($viewName) || !preg_match('~^\w(?:(?!\/\.{0,2}\/)[\w\/\-\.])*$~', $viewName)) {
|
||||
if (YII_DEBUG) {
|
||||
throw new NotFoundHttpException("The requested view \"$viewName\" must start with a word character, must not contain /../ or /./, can contain only word characters, forward slashes, dots and dashes.");
|
||||
} else {
|
||||
throw new NotFoundHttpException(Yii::t('yii', 'The requested view "{name}" was not found.', ['name' => $viewName]));
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException(Yii::t('yii', 'The requested view "{name}" was not found.', ['name' => $viewName]));
|
||||
}
|
||||
|
||||
return empty($this->viewPrefix) ? $viewName : $this->viewPrefix . '/' . $viewName;
|
||||
|
@ -342,9 +342,9 @@ class ActiveForm extends Widget
|
||||
$field = array_pop($this->_fields);
|
||||
if ($field instanceof ActiveField) {
|
||||
return $field->end();
|
||||
} else {
|
||||
throw new InvalidCallException('Mismatching endField() call.');
|
||||
}
|
||||
|
||||
throw new InvalidCallException('Mismatching endField() call.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,9 +179,9 @@ class DetailView extends Widget
|
||||
'{captionOptions}' => $captionOptions,
|
||||
'{contentOptions}' => $contentOptions,
|
||||
]);
|
||||
} else {
|
||||
return call_user_func($this->template, $attribute, $index, $this);
|
||||
}
|
||||
|
||||
return call_user_func($this->template, $attribute, $index, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,13 +238,13 @@ class Menu extends Widget
|
||||
'{url}' => Html::encode(Url::to($item['url'])),
|
||||
'{label}' => $item['label'],
|
||||
]);
|
||||
} else {
|
||||
$template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
|
||||
|
||||
return strtr($template, [
|
||||
'{label}' => $item['label'],
|
||||
]);
|
||||
}
|
||||
|
||||
$template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
|
||||
|
||||
return strtr($template, [
|
||||
'{label}' => $item['label'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user