mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fix some code smells (#18696)
This commit is contained in:
@ -9,7 +9,6 @@ namespace yii\console;
|
|||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ErrorException;
|
use yii\base\ErrorException;
|
||||||
use yii\base\UserException;
|
|
||||||
use yii\helpers\Console;
|
use yii\helpers\Console;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +38,7 @@ class ErrorHandler extends \yii\base\ErrorHandler
|
|||||||
} elseif (count($alternatives) > 1) {
|
} elseif (count($alternatives) > 1) {
|
||||||
$message .= "\n\nDid you mean one of these?\n - " . implode("\n - ", $alternatives);
|
$message .= "\n\nDid you mean one of these?\n - " . implode("\n - ", $alternatives);
|
||||||
}
|
}
|
||||||
} elseif ($exception instanceof Exception && ($exception instanceof UserException || !YII_DEBUG)) {
|
} elseif ($exception instanceof Exception || !YII_DEBUG) {
|
||||||
$message = $this->formatMessage($exception->getName() . ': ') . $exception->getMessage();
|
$message = $this->formatMessage($exception->getName() . ': ') . $exception->getMessage();
|
||||||
} elseif (YII_DEBUG) {
|
} elseif (YII_DEBUG) {
|
||||||
if ($exception instanceof Exception) {
|
if ($exception instanceof Exception) {
|
||||||
|
|||||||
@ -355,7 +355,7 @@ class DataFilter extends Model
|
|||||||
/**
|
/**
|
||||||
* Detect attribute type from given validator.
|
* Detect attribute type from given validator.
|
||||||
*
|
*
|
||||||
* @param Validator validator from which to detect attribute type.
|
* @param Validator $validator validator from which to detect attribute type.
|
||||||
* @return string|null detected attribute type.
|
* @return string|null detected attribute type.
|
||||||
* @since 2.0.14
|
* @since 2.0.14
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -267,10 +267,8 @@ class SqlToken extends BaseObject implements \ArrayAccess
|
|||||||
|
|
||||||
if ($firstMatchIndex === null) {
|
if ($firstMatchIndex === null) {
|
||||||
$firstMatchIndex = $offset;
|
$firstMatchIndex = $offset;
|
||||||
$lastMatchIndex = $offset;
|
|
||||||
} else {
|
|
||||||
$lastMatchIndex = $offset;
|
|
||||||
}
|
}
|
||||||
|
$lastMatchIndex = $offset;
|
||||||
$wildcard = false;
|
$wildcard = false;
|
||||||
$offset++;
|
$offset++;
|
||||||
continue 2;
|
continue 2;
|
||||||
|
|||||||
@ -108,7 +108,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
|
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
|
||||||
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
|
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
|
||||||
* @param array $orderBy the order by columns. See [[\yii\db\Query::orderBy]] for more details on how to specify this parameter.
|
* @param array $orderBy the order by columns. See [[\yii\db\Query::orderBy]] for more details on how to specify this parameter.
|
||||||
* @param int $limit the limit number. See [[\yii\db\Query::limit]] for more details.
|
* @param int|Expression $limit the limit number. See [[\yii\db\Query::limit]] for more details.
|
||||||
* @param int $offset the offset number. See [[\yii\db\Query::offset]] for more details.
|
* @param int $offset the offset number. See [[\yii\db\Query::offset]] for more details.
|
||||||
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
|
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class GettextMessageSource extends MessageSource
|
|||||||
} elseif (!empty($fallbackMessages)) {
|
} elseif (!empty($fallbackMessages)) {
|
||||||
foreach ($fallbackMessages as $key => $value) {
|
foreach ($fallbackMessages as $key => $value) {
|
||||||
if (!empty($value) && empty($messages[$key])) {
|
if (!empty($value) && empty($messages[$key])) {
|
||||||
$messages[$key] = $fallbackMessages[$key];
|
$messages[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,7 +115,7 @@ class PhpMessageSource extends MessageSource
|
|||||||
} elseif (!empty($fallbackMessages)) {
|
} elseif (!empty($fallbackMessages)) {
|
||||||
foreach ($fallbackMessages as $key => $value) {
|
foreach ($fallbackMessages as $key => $value) {
|
||||||
if (!empty($value) && empty($messages[$key])) {
|
if (!empty($value) && empty($messages[$key])) {
|
||||||
$messages[$key] = $fallbackMessages[$key];
|
$messages[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ use Yii;
|
|||||||
use yii\base\Component;
|
use yii\base\Component;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\helpers\StringHelper;
|
|
||||||
use yii\helpers\VarDumper;
|
use yii\helpers\VarDumper;
|
||||||
use yii\web\Request;
|
use yii\web\Request;
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace yii\mutex;
|
namespace yii\mutex;
|
||||||
|
|
||||||
use yii\base\InvalidArgumentException;
|
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -23,7 +23,6 @@ echo str_pad('', strlen($header), '-') . "\n\n";
|
|||||||
foreach ($requirements as $key => $requirement) {
|
foreach ($requirements as $key => $requirement) {
|
||||||
if ($requirement['condition']) {
|
if ($requirement['condition']) {
|
||||||
echo $requirement['name'] . ": OK\n";
|
echo $requirement['name'] . ": OK\n";
|
||||||
echo "\n";
|
|
||||||
} else {
|
} else {
|
||||||
echo $requirement['name'] . ': ' . ($requirement['mandatory'] ? 'FAILED!!!' : 'WARNING!!!') . "\n";
|
echo $requirement['name'] . ': ' . ($requirement['mandatory'] ? 'FAILED!!!' : 'WARNING!!!') . "\n";
|
||||||
echo 'Required by: ' . strip_tags($requirement['by']) . "\n";
|
echo 'Required by: ' . strip_tags($requirement['by']) . "\n";
|
||||||
@ -31,8 +30,8 @@ foreach ($requirements as $key => $requirement) {
|
|||||||
if (!empty($memo)) {
|
if (!empty($memo)) {
|
||||||
echo 'Memo: ' . strip_tags($requirement['memo']) . "\n";
|
echo 'Memo: ' . strip_tags($requirement['memo']) . "\n";
|
||||||
}
|
}
|
||||||
echo "\n";
|
|
||||||
}
|
}
|
||||||
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$summaryString = 'Errors: ' . $summary['errors'] . ' Warnings: ' . $summary['warnings'] . ' Total checks: ' . $summary['total'];
|
$summaryString = 'Errors: ' . $summary['errors'] . ' Warnings: ' . $summary['warnings'] . ' Total checks: ' . $summary['total'];
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
namespace yii\widgets;
|
namespace yii\widgets;
|
||||||
|
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\helpers\Html;
|
|
||||||
use yii\helpers\Json;
|
use yii\helpers\Json;
|
||||||
use yii\web\JsExpression;
|
use yii\web\JsExpression;
|
||||||
use yii\web\View;
|
use yii\web\View;
|
||||||
|
|||||||
Reference in New Issue
Block a user